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 comment
10|10000 characters needed characters exceeded

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 comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      You create nodeRole_Output node inside component controller, because you didn't use Custom controller. Map nodeRole_Output node into view and bind into dropdown UI Element.

      Kind Regards,

      S.Saravanan.

  • 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 comment
    10|10000 characters needed characters exceeded