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



May 4, 2011, 5:46 PM
33 Posts

How to get current component ID from withing server side event

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 2
There is is beforeRenderResponse event associated with custom control. I would like to place the script there and read custom control property. It seems that compositeData object is not instantiated at that time. To overcome that I am using PropertyMap as shown in the code below. Although the solution works fine there is hard coded custom control ID (ID is assigned on XPage where cc is embedded to, mycustomcontrolID in the code snippet below) which makes its portability quite limited.
My question is if there is a way how to compute the current component ID from within the event?
 
 
 
var thisCCComponent = getComponent( "mycustomcontrolID" );

if ( thisCCComponent != null ){

    var componentProps = thisCCComponent.getPropertyMap();

    if  ( componentProps != null ) {
       
        var auxComponent = getComponent( componentProps.getProperty( "firstNameID" ) );
        viewScope.firstName = auxComponent.getValue() ;
       
    }
}
May 5, 2011, 6:40 AM
33 Posts
Re: How to get current component ID from withing server side event
Additional information
 
 
According to information published here http://www.youatnotes.de/web/youatnotes/wiki-xpages.nsf/dx/Work_with_events (it's a valuable resource of information btw)


this                                                  ... should return event handler object

this.getParent()                             ... should return the component that owns the event
 
 
 
But it seems not to be true at least in this particular case (e.g. beforeRenderResponse of a custom control). If I check the type of the object and its ID I get the following:
 
 
typeof this                                        ... com.ibm.xsp.component.UIViewRootEx2
 
this.getId()                                       ... null

typeof this.getParent()                  ... object

this.getParent().getId()                 ... com.ibm.xsp.exception.EvaluationExceptionEx error
 
May 31, 2011, 5:21 PM
129 Posts
Re: How to get current component ID from withing server side event
Take a look at the submittedBy function in this blogpost:
http://dontpanic82.blogspot.com/2010/03/xpages-making-validation-behave.html 

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