on 05-30-2007 5:43 PM
I have the below context structure and am trying to create DropDown UI objects and lists dynmically. Further below is the code I have
thus far; most of it taken from the example. I think I understand what is happening up to this point however I don't undstand
what to pass to the bindSelectedKey to get the "response_text" shown in the picklist but have the "response_value" stored as the
selected option.
Any help would be much appreciated.
/Greg
C_Quest_Resp (0..n, s=true)
- question_text
- ...
- ...
+ Responses (0..n, s=true)
- response_text
- response_value
- ...
// Multiple questions each having an element (Responses) which contains list of applicable responses.
if (firstTime) {
IC_quest_respElement qNode;
int noQuestions = wdContext.nodeC_quest_resp().size();
for ( int i = 0; i < noQuestions; i++ ) {
qNode = wdContext.nodeC_quest_resp().getC_quest_respElementAt(i);
IWDDropDownByKey dropDown = (IWDDropDownByKey)view.createElement(IWDDropDownByKey.class,
"inp" + i );
/** Trying to understand how I will handling binding. **/
// dropDown.bindSelectedKey()
}
}
Hi,
1. Map the context attribute "response_text" to the bindSelectedKey property of DDBK.
if(firstTime)
{
IWDAttributeInfo attributeInfo = wdContext.nodeResponses().getNodeInfo().getAttribute(IPrivate<view>.IResponsesElement.RESPONSE_TEXT);
IWDDropDownByKey DDBK = (IWDDropDownByKey)view.createElement(IWDDropDownByKey.class,"DDBKsample");
DDBK.bindSelectedKey(attributeInfo);
IWDTransparentContainer container = (IWDTransparentContainer)view.getRootElement();
container.addChild(DDBK);
// now call the method of component controller to populate the data inside the DDBK
wdThis.getComponentController.populateDDBK();
}
//create a method in component controller say "populateDDBK"
// use simple value set to populate the values in the DDBk with 'response_text' as the list value and
// 'response_value' as the key of the selected 'response_text'
public void populateDDBK()
{
IWDAttributeInfo atrInfo = wdContext.nodeResponses().getNodeInfo().getAttribute(IPrivateTest_DDBK_View.IResponsesElement.RESPONSE_TEXT);
IModifiableSimpleValueSet ValueSet = atrInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
for(int i = 0; i < wdContext.nodeResponses().size();i++)
{
ValueSet.put(wdContext.nodeResponses().getResponsesElementAt(i).getresponse_value(), wdContext.nodeResponses().getResponsesElementAt(i).getresponse_text());
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you both those were very helpful and exactly what I was looking for. I've awarded points to both.
Thanks again!!!!!
/Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you are on the wrong track.
You want to display the list of possible responses for a question in a dropdown list, right?
Change your context structure into something like this:
Questions (node, card=0:N)
- Text (attribute, string)
- Responses (node, card=0:N, singleton=false)
-- Text (attribute, string)
Now, to create questions and responses, you can use code like:
IQuestionsElement q1 = wdContext.createAndAddQuestionsElement();
q1.setText("First question");
IResponsesElement r11 = q1.nodeResponses().createAndAddResponsesElement();
r11.setText("First response to first question");
IResponsesElement r12 = q1.nodeResponses().createAndAddResponsesElement();
r12.setText("Second response to first question");
Now you can use a dropdown list for selecting a question and a second dropdown list for selecting a response by code like this (or better, create them in the IDE):
IWDDropDownByIndex questionSelector = (IWDDropDownByIndex) view.createElement(IWDDropDownByIndex.class, "QuestionSelector");
questionSelector.bindTexts("Questions.Text");
IWDDropDownByIndex responseSelector = (IWDDropDownByIndex) view.createElement(IWDDropDownByIndex.class, "ResponseSelector");
responseSelector.bindTexts("Questions.Responses.Text");
Additionally, assign an action to the "onSelect" event of the question selector to trigger a server roundtrip when the selection changes. This leads to a change of the lead selection in node "Questions" which in turn leads to filling the second dropdown list with the responses for the selected question.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.