cancel
Showing results for 
Search instead for 
Did you mean: 

filling dropdown listbox, how?

Former Member
0 Kudos

Hi,

is there sample code for filling drop-down listbox?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Cemil Bozlagan,

Create a context variable and bind it to the DropdownByKey element.

Use this coding in wdDoInit()

IWDAttributeInfo attInf =  wdContext.getNodeInfo().getAttribute(wdContext.currentContextElement().ATTRIBUTENAME);// Name of the attribute  
ISimpleTypeModifiable stm = nameInf.getModifiableSimpleType();
   IModifiableSimpleValueSet svs= stm.getSVServices().getModifiableSimpleValueSet();
   svs.put("key1", "Value1");
   svs.put("key2", "Value2");
   svs.put("key3", "Value3");
// like this add as many values as you want

Regards,

Siva

Former Member
0 Kudos

Hi,

Problem at line below.

ISimpleTypeModifiable stm = nameInf.getModifiableSimpleType();

it says: nameInf can not be resolved.

Thanks.

Former Member
0 Kudos

Hi Cemil Bozlagan ,

Use attInf inplace of nameInf.Because IWDAttributeInfo object is attInf

Regards,

srikanth

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Step 1. Creating a web dynpro project. ex(Extended_Value_Selectoru2019)

Step 2. Creating a simple type u2018Objectu2019.

Web dynpro explorer->Extended_Value_Selector->Dictionaries->local dictionary->data types->simple types.

Confirm by choosing finish.

Let the data type be string.

Choose the tab Enumeration.

Add value and text for the new element.

Confirm by choosing finish.

Populate the enumeration with some elements.

Step 3. Creating a web dynpro component.

step 4.

write this code,

IWDAttributeInfo attr=wdContext.getNodeInfo().getAttribute(IPrivate<view>View.IContextElement.DYNAMIC);

ISimpleTypeModifiable mtype=attr.getModifiableSimpleType();

IModifiableSimpleValueSet value=mytype.getServices().getModifiableSimpleValueSet(0;

value.put("111","aaa");

value.put("222","bbb");

......

Regards,

Sunaina Reddy T

Former Member
0 Kudos

Hi Cemil Bozlagan ,

Dropdown list box gets the value from Simple type EnmerationIn .

Using EVS u can dynamicaly create Enumeration.

Here is the SAP technical link which describes Creating Extended Value Selector (EVS) - Static and Dynamic in Web Dynpro for Java.

Search in SAP technical.com by giving the string Dynamic Enumeration

Follow the procedure:-

Create a context attribute dynamic of type String.

write the code for dynamic enumaration

IPrivate<view>View.ICOntextElement ele=wdContext.createContextElement();

IWDAttributeInfo attr=wdContext.getNodeInfo().getAttribute(IPrivate<view>View.IContextElement.DYNAMIC);

ISimpleTypeModifiable mtype=attr.getModifiableSimpleType();

IModifiableSimpleValueSet value=mytype.getServices().getModifiableSimpleValueSet(0;

value.put("pen-1","pen");

value.put("book-1","book");

Regards,

srikanth