User control's composite compositeData undefined in beforeRenderResponse event

When transferring data to a user control, I always used the compositeData object to access this data from inside the control. This works fine except for the beforeRenderResponse event of the custom control. Take this code as an example:

<xp:this.afterPageLoad><![CDATA[#{javascript:getComponent("lbl0").setValue(typeof(compositeData));}]]></xp:this.afterPageLoad>
<xp:this.beforeRenderResponse><![CDATA[#{javascript:getComponent("lbl1").setValue(typeof(compositeData));}]]></xp:this.beforeRenderResponse>
<xp:label value="" id="lbl0"/>
<xp:label value="" id="lbl1"/>

In the afterPageLoad event, the typeof complexData is "com.ibm.xsp.binding.PropertyMap". However, in the beforeRenderResponse event, the same type returns undefined. "

How can I access composite data in a beforeRenderResponse event?

+5
source share
1 answer

beforePageLoad afterPageLoad SSJS compositeData:

<xp:this.beforePageLoad>
   <![CDATA[#{javascript:
      var hlp=compositeData;
   }]]>
</xp:this.beforePageLoad>

PropertyMap . , :

<xp:this.afterRenderResponse>
   <![CDATA[#{javascript:
      print( hlp.test );
   }]]>
</xp:this.afterRenderResponse>

EDIT: , (pageLoad). , . , :

-, :

<xc:ccWithId test="I am your property" id="ccWithId" />

getComponent(). propertyMap , :

<xp:this.beforeRenderResponse>
   <![CDATA[#{javascript:
      var cmp:com.ibm.xsp.component.UIIncludeComposite = getComponent("ccWithId");
      print("Value of 'test' -> " + cmp.getPropertyMap().getString("test") )
   }]]>
</xp:this.beforeRenderResponse>

xpages-noob. . get map . , :

 var thisData:com.ibm.xsp.binding.PropertyMap=getComponent("ccWithId").getPropertyMap();
function getPara(key) {
    var x=thisData.get(key);
    if (@Ends(typeof(x),"ValueBinding")) return x.getValue(facesContext);
    else return x
}

, , "test", getPara ( "test" ). complexData.test.

+6

All Articles