cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with dynamic IWDDropDownByIndex generation / context binding

Former Member
0 Kudos

Hello everybody,

I am dynamically generating IWDDropDownByIndex elements from the context. As many Question nodes do exist, IWDDropDownByIndex elements are created. For the first element it works fine, but after generating the second one, the first element has the same texts to select than the second one.

I am using the following context:

root

+++Question(Node)

+++

+++Caption(Attribute, String)

+++

+++++AnswerOptions(Node)

+++++

+++++Answer(Attribute, String)

(Question is a singleton node with parent root and attribute Caption, AnswerOptions is a non-singleton node with parent Question and attribute Answer - both cardinalities are 0..n)

For generating the UI elements I use:

//one loop each question

for (int i=0; i < wdContext.nodeQuestions().size(); i++) {

wdContext.nodeQuestions().setLeadSelection(i);

IWDDropDownByIndex dropDown = (IWDDropDownByIndex)view.createElement(IWDDropDownByIndex.class, (i+1) + "Drop Down" + 1);

//the number of DropDown texts to select is determined by the number of AnsweringOptions

dropDown.bindTexts("Questions.AnswerOptions.Answer"); dropDown.setOnSelect(wdThis.wdCreateAction(IPrivateTestPrototypeView.WDActionEventHandler.DROP_DOWN_SELECTION,""));

dropDown.mappingOfOnSelect().addSourceMapping("index","SelectedIndex");

questionGroup.addChild(dropDown);

}

It seems that bindTexts("Questions.AnswerOptions.Answer") always points to the same question node and therefore even previously added DropDown elements change their texts. How can I prevent already added IWDDropDownByIndex elements from changing their texts?

Thank you for your help!

Tom

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Tom,

I think u will not be able to bind different instances of a node to different UI elements.Even at Design time u will not be able bind different instances so it will not be possible at runtime also.All the dropdowns u r creating is binded to a single instance .so with change in one dropdown it is also getting reflected in others.

It is possible when u use table UI element bcoz each row of a table will have diffrent instances.

Regards,

Sowjanya.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Tom,

What you want to do IS possible. You have to ensure that you create a unique NodeInfo for every question node.