cancel
Showing results for 
Search instead for 
Did you mean: 

Populating Drop Down Lists

Former Member
0 Kudos

I am new to WebDynpro for Java and looking for some direction in populating down lists based on the selection of another drop down list.

In a simple case, I have two items in the primary list (Maintenance and Personnel). Depending on what is selected I want to populate a second dropdown list with (MaintReason1, MaintReason2 or PersonnelReason1, PersonnelReason2). I have been looking for some sample code on how to do this but so far have been unsuccessful. I would appreciate any help.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member286976
Active Participant
0 Kudos

Hello William,

Just to add to my previous post.

You must add two dropdown in your view and bind the first dropdown to Attrib1 of Node1 and bind the second one to Attrib2 of Node2.

Regards,

Sudeep.

former_member286976
Active Participant
0 Kudos

Hello William,

As per my understanding your requirement is to do context based filtering in your application; say you have two drop down list in your application, based on the country selected in the first dropdown, you want to display the corresponding states for the country.

To achive this create the following structure in your web dynpro context.

Context
   |-Node1 (cardinality: 0..n, singleton; true)
       |-Attrib1
       |-Node2 (cardinality: 0..n, singleton; false)
           |-Attrib2

Write the logic to put data in the created nodes. Sample code given below.

IWDNode n1 = wdContext.nodeNode1();
	  IWDNodeElement ne = n1.createAndAddElement();
	  ne.setAttributeValue("Attrib1","Country1");
	  n1.setLeadSelection(ne.index());

	  IWDNode n2 = n1.getChildNode("Node2",n1.LEAD_SELECTION);
	  IWDNodeElement neX = n2.createAndAddElement();
	  neX.setAttributeValue("Attrib2","State1");

	  IWDNode n1T = wdContext.nodeNode1();
	  IWDNodeElement neT = n1T.createAndAddElement();
	  neT.setAttributeValue("Attrib1","Country2");
	  n1T.setLeadSelection(neT.index());

	  IWDNode n2T = n1T.getChildNode("Node2",n1T.LEAD_SELECTION);
	  IWDNodeElement neXT = n2T.createAndAddElement();
	  neXT.setAttributeValue("Attrib2","State2");

Define one action for the first dropdown onSelect event. There is no need to write any logic there. Our only purpose in doing so is to call the doModifyView. Any action after execution will call doModifyView.

Once this is done, you are through. Based on selection on first dropdown, the second dropdown will get populated.

I don't know whether there are any better methods to do this. But this will work for sure.

Regards,

Sudeep.

Former Member
0 Kudos

This has nothing to do with calling wdDoModifyView().

The action assigned to event "onSelect" is only needed to trigger a server roundtrip for the HTML client to be able to process the lead selection change. A "smart" client would not need this.

Armin

Former Member
0 Kudos

Hi William,

Create The UI element DropDown by Index. In the Properties of the drop down Event OnSelect is available .You can create a new action for the first drop down selection. Implement the part here .

use this links

https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/91c5e990-0201-0010-4981-9b2075751da5

https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/documents/a1-8-4/tutorial on internationalization of web dynpro applications.htm

Kind Regards

Mukesh.

Former Member
0 Kudos

Hi William,

Please find this thread useful.

Thanks,

Raj.