Skip to Content
0
Former Member
Jun 06, 2005 at 11:41 AM

Problems with dynamic IWDDropDownByIndex generation / context binding

101 Views

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