cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate values dynamically in dropdownbykey

Former Member
0 Kudos

Hi All,

My requirement is to populate the dropdown filled in with values( and key) which are coming from the ZBAPI call ie web service model.

How do i achieve this ?

Kindly provide me with some pseudo code.

Reg/Venkat

Accepted Solutions (1)

Accepted Solutions (1)

sridhar_k2
Active Contributor
0 Kudos

Hi,

Create a context Variable in your View with empcode.

IContextElement contextElement = wdContext.currentContextElement();

IWDNodeInfo nodeInfo = wdContext.getNodeInfo();

IWDAttributeInfo dateAttributeInfo = nodeInfo.getAttribute(contextElement.empCode);

IModifiableSimpleValueSet dropValueSet = dateAttributeInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

String empCodeTxt=null;

//Gives the Size of the List, which is coming from Model

int nodeLength = wdContext.node<BAPIList>().size();

for (int i = 0; i < nodeLength; i++) {

// Gives the Value, Which you want to show in Drop Down List Box.. Change it according to your need.

empCodeTxt=String.valueOf(((IPrivate<viewname>.I<BAPIList>Element)(wdContext.node<BAPIList>().getElementAt(i))).get<Parameter>());

dropValueSet.put(empCodeTxt, empCodeTxt);

}

Regards,

Sridhar

Former Member
0 Kudos

Hi All,

Thanks for all your support. After using the following code, i am now able to populate the values dynamically in the drop down box

IWDNodeInfo nodeInfo = wdContext.getNodeInfo();

IWDAttributeInfo addressAttributeInfo = nodeInfo.getAttribute("addressDropDown");

IModifiableSimpleValueSet dropValueSet = addressAttributeInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

int nodeSize = this.wdContext.nodeABC_ADDRESS_1().size();

for(int i=0;i<nodeSize;i++){

dropValueSet.put(this.wdContext.nodeABC_ADDRESS_1().getElementAt(i).getAttributeAsText("NO"),this.wdContext.nodeABC_ADDRESS_1().getElementAt(i).getAttributeAsText("DSC"));

}

Reg/Venkat

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Venkat,

You can populate dropdown values from webservice using the following steps. I assume you gave idea about custom controller.

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. find thr size of value node.

After execute web service you can find size using the following code. create value node and model node 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 x=0;x<modelnode.size();x++){

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

<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

vijayakhanna_raman
Active Contributor
0 Kudos

Hi.

Check this code,

ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf(<Attribute name>);

IModifiableSimpleValueSet val=myType.getSVServices().getModifiableSimpleValueSet();

val.put("3","ddd");

val.put("1","aaa");

val.put("5","bbb");

val.put("2","ccc");

Regards,

Vijayakhanna Raman

Former Member
0 Kudos

Hi,

you can use this code :

ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf(<Attribute name>);

IModifiableSimpleValueSet val=myType.getSVServices().getModifiableSimpleValueSet();

to obtain the value set of the DropDownByKey.

then access it like an HashMap (val.put, val.remove, val.clear()....)