This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 13, 2011, 10:57 AM
13 Posts
topic has been resolvedResolved

Getting the current component's name

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 2
 Now, you might remember the good old @ThisValue and @ThisName in the Notes client.  @ThisName was useful, because you could use it to generate another field name for calculation purposes, or whatever.  The point is, @ThisName  was an easy way to get a handle on the current field's name.
 
I'm sure there must be a similar ability within XPages.  Where in SSJS you can refer to the current component, but for the life of me, I can't see it.  I've checked the documentation read the XPages manual, etc etc, but haven't been able to come up with anything. 
 
Anyone able to help me out with this? 
 
Cheers 
 
Mar 13, 2011, 1:33 PM
261 Posts
Re: Getting the current component's name
Hi,
 
Have you tried the "this" object?
 
A check to what "this" refers to (e.g. in a SSJS event) you could print the type to the server console:

print( "this is " + typeof this);
 
If "this" refers to the current event, you can use this.getParent() to retrieve the event's parent (e.g. a button control).

To get code completion when refering to this, you have to assign it to a local variable and specify its clas:
 
var t:<object-class-here> = this;
 
then you enter t. and get a list of all properties/ methods
 
Mark
 
Mar 13, 2011, 4:36 PM
13 Posts
Re: Getting the current component's name
 Hi Mark - thanks for your help.  And on a Sunday, too :)
 
Following your advice, I found that when using a computed text field, the type is com.ibm.xsp.component.xp.XspOutputText
 
Checking the type hierarchy,  this is a subclass of  javax.faces.component.UIComponent
 
so a general solution to this problem is :
 
var v:javax.faces.component.UIComponent = this;
v.getId();
  
Which does the trick nicely. 
 
Mind you, I do miss the old @ThisValue (just kidding :)
 
Cheers 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal