0
votes

I have an xPage with multiple instances of the same custom control. How do I get to the value of a field on a specific custom control from a button on my xPage.

Normally I would do something like:

ctlName = "radioGroupCMBUAction"; var changeType = getComponent(ctlName).getValue();

If there was only one instance of the control. How would I do this with multiple instances of the control?

2
Bruce, can you add some example code so that we can see how you assign ids to the individual custom controls?Per Henrik Lausten
Per, That is my question. To be able to assign a unique id to each control with a unique ID. Folks helped me here with the binding stackoverflow.com/questions/9913331/dynamic-data-binding. But I would rather not dynamically create an ID. I can't believe this is this hard to do. You would think I could just reference the custom control id to get to the individual controls.Bruce Stemplewski

2 Answers

0
votes

Without the code I'm not sure if .getValue() will work as in order for this to happen it will have to pull out a field where as a custom control could have a repeat inside it etc.

Assuming that it will work if each of the customControl instances have an id that is unique from each other it should work fine as each instance should have its own vriables inside it.

Other ideas however could be to pass in a string and use this string as the name of a scoped variable inside the custom control that can be pulled out from anywhere. I've done this before where I created a property on the custom control for a String and inside the custom control use

viewScope[compositeData.customProperty] = value.

then outside the context of the custom control I am aware of the string I passed in so I would be able to pull this value back out. Passing it in means multiple instances won't over write each other.

Or you could write the field in he custom control to a document, either to get it out or as the end solution to your problem of saving it.

0
votes

Not sure if this can help you..? A while back, I wrote a tip regarding "private" scoped variables:

http://dontpanic82.blogspot.com/2010/03/xpages-tip-regarding-private-scoped.html