Skip to Content
author's profile photo Former Member
Former Member

bindSelectedKey Question

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()
			
			
		}
    	
    }

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 31, 2007 at 08:07 AM

    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());

    }

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2007 at 11:13 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 31, 2007 at 01:41 PM

    Thank you both those were very helpful and exactly what I was looking for. I've awarded points to both.

    Thanks again!!!!!

    /Greg

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.