cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a Dropdown in webdynpro

Former Member
0 Kudos

Hi ,

I am a beginner in Webdynpro , Java . Request you to plz help me ..

My requirements -

1. How to create a dropdownbyindex in a view and populate it with some static values passed to the Context .

2. Upon selection of a value from the dropdown and clicking on the Submit button , how to save the value?

Context -

Node - Season

Attribute - Seasonofyear

Kindly Reply

Thanks in Advance!!

Regards

Smita

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi smitha,

Context -

Node - Season

Attribute - Seasonofyear

I had worked out ur same requirement with dropdownbykey and added the following code.

public void wdDoInit()

{

IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(IPrivateMain.IseasonElement.season);

ISimpleTypeModifiable sea = attributeInfo.getModifiableSimpleType();

sea.setFieldLabel("SEASON");

IModifiableSimpleValueSet valueSet =sea.getSVServices().getModifiableSimpleValueSet();

valueSet.put(0, AAA);

valueSet.put(1,BBB);

valueSet.put(2,CCC);

}

I think this may help you.

Edited by: kandha mugundhan on Sep 25, 2008 7:50 PM

Edited by: kandha mugundhan on Sep 25, 2008 7:52 PM

Former Member
0 Kudos

Hi ...thnx for the reply

But I dont know anything about simpletype.

Former Member
0 Kudos

Hi smitha,

I had checked out.. this is working fine for ur requirement

public void wdDoInit()

{

IPrivateSamView.ISeasonNode snode = wdContext.nodeSeason();

IPrivateSamView.ISeasonElement sele = snode.createSeasonElement();

snode.addElement(sele);

IWDAttributeInfo attributeInfo = wdContext.nodeseason().getNodeInfo().getAttribute(IPrivateMain.IseasonElement.season);

ISimpleTypeModifiable sea = attributeInfo.getModifiableSimpleType();

sea.setFieldLabel("SEASON");

IModifiableSimpleValueSet valueSet =sea.getSVServices().getModifiableSimpleValueSet();

valueSet.put("0"," AAA");

valueSet.put("1","BBB");

valueSet.put("2","CCC");

}

i had created a attribute called copy under the node "season". Now i copied from the season attribute to copy attribute.

then onaction save

{

IModifiableSimpleValueSet rea = wdThis.wdGetContext().getContext().getModifiableTypeOf("season.season").getSVServices().getModifiableSimpleValueSet();

wdContext.currentSeasonElement().setCopy(rea.getText(wdContext.currentSeasonElement().getSeason()));

}

Former Member
0 Kudos

Hi

Thnx a lot for solving it out.

Answers (2)

Answers (2)

Former Member
0 Kudos

go thru this link to get an an idea for binding data incase of index and key

http://help.sap.com/saphelp_nw04/helpdata/en/74/450e8af57065468e88e4b86de47e4b/frameset.htm

namrata_d
Active Participant
0 Kudos

Hi smitha,

Firstly in the view layout in the RootUIContainer

right click -> select Insert child - > select DropDownByIndex. Bind the Value property

of dropdown with ur node Seasons- Seasonofyear.

Then in the implementation write:-

IPrivat<>View.ISeasonNodeElement Season_element - wdcontext.createseasonElement();

Season_element.setseasonofyear("Summer"); //insert all the values like using Set method

wdcontext.nodeSeason().addElement(Season_element);

This shall populate all the values in the dropdown.

On selecting a particular value from the dropdown if u want to retrieve

the value . Bind an event handler with the onSelect Action of dropdown UI

element. In the event handler just write :-

String seasonofyr = wdcontext.currentseasionNodeElement().getseasionofyear();

This strin variable shall collect the value of season currently selected.

Hoep this helps you.

Thanks

Namrata

Former Member
0 Kudos

Hi ......... ur solution was just great.......it worked

Thanx !!