Search code examples
xpages

Xpages - Custom control getting a custom property from another custom control


I've searched google and stack but can't seem to find a definitive answer. What I would like to do, is something like this:

Say I have custom control A, within which, is a radio button, when I click it, I want it to grab a custom property that is set on custom control B, lets say compositeData.Name as an example. Can I do this?

If I give custom control B an ID, lets say ccB, can the radio button in custom control A do something like, getComponent("ccB").getValue().compositeData.Name so I can get the value of the property I passed into custom control B using the custom property 'Name'?

If its a straight no, at least I know to stop playing around with the idea! Thanks


Solution

  • Reaching from one control into the inside of another control would break component isolation. You might want to take a different approach:

    Option a - client side: Your control emits a JavaScript event that bubbles up until it reaches a parent element that contains the control you want to change (presumably the parent Dom element). There you set the property of that element.

    Option b - server side: As Urs suggested: bind both to a bean and handle the updates inside the bean