cancel
Showing results for 
Search instead for 
Did you mean: 

WD for Java: How to I retrieve key and value for DropDownbyKey selection

Former Member
0 Kudos

Dear All

I thought this was going to be straightfoward and am obviously missing something.

I have created a simple modifiable value set to create a dropdown list to select a country:

public void GetCountryDropDownValues( )

{

//@@begin GetCountryDropDownValues()

Y_Tf_Npf_Get_Countries_Input countriesInput = new Y_Tf_Npf_Get_Countries_Input();

wdContext.nodeY_Tf_Npf_Get_Countries_Input().bind(countriesInput);

try {

countriesInput.execute();

wdContext.nodeY_Tf_Npf_Get_Countries_Input().nodeOutput_countries().invalidate();

} catch (WDRFCException ex) {

// TODO: handle exception

}

IPrivateNonPersonalisedLearnAdminReq.IContextElement elem = wdContext.currentContextElement();

String strObjElem0 = elem.COUNTRY;

IWDAttributeInfo i_ObjType0 = wdContext.getNodeInfo().getAttribute(strObjElem0);

ISimpleTypeModifiable w_ObjType0 = i_ObjType0.getModifiableSimpleType();

IModifiableSimpleValueSet s_ObjType0 = w_ObjType0.getSVServices().getModifiableSimpleValueSet();

s_ObjType0.clear();

for(int i=0;i<wdContext.nodeEt_Countries().size();i++)

{

IPublicNonPersonalisedLearnAdminReq.IEt_CountriesElement elemOrg = wdContext.nodeEt_Countries().getEt_CountriesElementAt(i);

s_ObjType0.put(elemOrg.getLand1(),elemOrg.getLandx50());

}

//@@end

}

This is bound to a new context element attribute:

Country of type string

When value is selected from dropdown, it is stored in string

What I want to be able to do is to retrieve the text as well as the key from the selected object.

At the moment I can only return the key.

i.e. wdContext.currentContextElement().getCountry();

Any pointers will be greatfully received and maximum points awarded to the first complete

answer that works for me.

Many thanks in advance

Mike

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use the following code.



ISimpleValueSet valueset = attInfo.getModifiableSimpleType().getSVServices().getValues();

if(valueset.containsKey(key)){           // Give your key here, which you already know to retrieve
String value = valueset.getText(key);             // Here you will get the value

Hope it helps.

Regards,

Manoj

Answers (0)