cancel
Showing results for 
Search instead for 
Did you mean: 

how to get the selected value/key of a drop down list box in webdynpro Java

Former Member
0 Kudos

Dear SDN Members,

I have added some static data into a drop down list box by key UI element using the procedure specified in value help tutorial.

Now i want to display the value selected in a dropdown list box on view whenever i select an item in a dropdown list box.

Can any one put here the code part relating to this.

Your help will be awarded.

Thanks in advance,

Regards,

Sireesha.B

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I think you can all the attributes in pirticular node.

Suppose NodeX contains your fropdownkey elements.

Simple doing this code.

String value=wdContext.currentNodeXElement.get<yourattributeName>();

wdComponentAPI.getMessageManager().reportSuccess(value);

This would be helps you.

Thanks,

Lohi.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Sireesha,

You want to display value based on the key selected in dropdown list. If you want to do like that

1) Create a context attribute for ex: key_value

2)In the properties of the attribute select the calculated as true.

3)It will create getter and setter methods for your attribute.

4)Go to implementation add the following code in getter method of your attribute

String attributeName = IPrivateCreate.IContextElement.KEY;

//KEY is your dropdown key attribute not the value attribute.

IWDAttributeInfo attributeInfo = element.node().getNodeInfo().getAttribute(attributeName);

ISimpleTypeModifiable simpleType = attributeInfo.getModifiableSimpleType();

IModifiableSimpleValueSet valueset = simpleType.getSVServices().getModifiableSimpleValueSet();

Object key = element.getAttributeAsText(attributeName);

return valueset.getText(key);

Regards

Suresh

Former Member
0 Kudos

Hi,

Assuming that you have used a simple type enumeration to prepare your value set and that you have created a context attribute of that simple type, you can use this code:

String key = wdContext.currentContextElement().get<your attribute name>();
		
Map enumVal = wdContext.getContext().getRootNode().getNodeInfo().getAttribute("<your attribute name>").getSimpleType().getEnumerationTexts();
wdComponentAPI.getMessageManager().reportSuccess(enumVal.get(key).toString());

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

You can use selectedKey API for this.

Check http://help.sap.com/saphelp_nw04/helpdata/en/3d/1eef3d5e10af5ee10000000a114084/frameset.htm

Regards, Anilkumar