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, 1:33 PM
261 Posts

Re: Getting the current component's name

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 2
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