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

Dynamicaly adding values to DropDownByKey

Hi

I am want to add the values in DropDownByKey dynamicaly which are returned by a WebService so how can we do that please give me the steps or code if possible

Thanks

Ninad

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2006 at 06:39 AM

    Hi,

    You can populate dropdown values from webservice using the following steps. I assume you have idea about custom controller and better you have to use DropdownbyIndex intead of DropdowmByKey.

    step1:

    Create custom controller.Inside custom controller Bind input value then execute webservice.

    step2:

    Now you have value node which is returned from web service. After execute web service you can find size using the following code. create value(Role_Output) node and modelnode(Role_result) object using the code.

    Step3:

    <custom controller name>.IRole_ResultNode modelnode=wdContext.nodeRole_Result();

    <custom controller name>.IRole_OutputNode valuenode=wdContext.nodeRole_Output();

    valuenode.invalidate();

    int size=modelnode.size();

    Step4:

    After find size using loop fetch values from model node into value node.Asume in this value node contains key and value.

    for(int j=0;j<modelnode.size();j++){

    <custom controller name>.IRole_ResultElement modelElement=modelnode.getRole_ResultElementAt(j);

    <custom controller name>.IRole_OutputElement valueElement=wdContext.createRole_OutputElement();

    valueElement.setId(modelElement.getKey());

    valueElement.setText(modelElement.getValue());

    valuenode.addElement(valueElement);

    }

    step5:

    After that bind this value node(Role_Output) into Component controller. Then Bind value node(Role_Output) from component controller into view.

    Step6:

    Finally bind dropdown UI Element into Role_Output node's attribute(ID).

    Kind Regards,

    S.Saravanan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2006 at 07:40 AM

    Hi,

    You can create a key on your own. You don't strictly need it from the webservice.

    Quoting previously submitted code:

    valueElement.setId("Key_" + loopIndex);//or whatever you might want to put.
    

    Regards,

    Satyajit.

    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.