cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in setting default values if the dropdown comes from the same node

Former Member
0 Kudos

Hi,

I have a page where I display 3 dropdowns from the same model node. But I cannot get different default values set for the dropdowns, as when I do leadSelection set for 1 dropdown, its sets the same leadSelection for all the dropdowns. So, I have created another context node and copy the model node to the context node.But, my problem is that I know only at runtime, how many items to be created (hence how many dropdowns would be created), so I have created a node

-Item (node) -


> List (node) (for dropdowns)---->attribute (attribute) (for values to be stored)

When I set the items (which I know at runtime), I copy the model node into List node (for each item).. so I have different list for each item.

But I am not able to display the dropdown. It shows me error:

java.lang.NullPointerException

at com.sap.tc.webdynpro.clientimpl.mobile.uradapter.DropDownByIndexAdapter.getSelectedKey

Please tell me the right approach to do this.

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

wdContext.nodeEx_State_List().moveFirst();

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

{

if(wdContext.currentEx_State_ListElement().getState_Desc().equals(wdContext.currentEx_Project_Search_ResultsElement().getState_Desc()))

{

wdContext.nodeEx_State_List().setLeadSelection(i);

break;

}

wdContext.nodeEx_State_List().moveNext();

}

Change the code according to your Context. it will set default value.

Regards

Ravi

Former Member
0 Kudos

Hi

Create 3 different nodes

1.Node1 -- key

-


Value

2.Node2 -- key

---Value

3.Node3 ---key

-


Value

<b>write 3 supply functions fill above nodes with Model Node</b> and change node properties cardinality 0….n selection mode : 1-n

Take 3 DropdownByIndex’s bind with above nodes.

Rgds

SS

Former Member
0 Kudos

Thanks for replying. But my problem is that only at runtime, I come to know how many dropdowns have to be created.

So, I cannot create a hardcoded node for each item.

Please help me.

Thanks

ChrisPaine
Active Contributor
0 Kudos

Hello,

looks like you might need to dynamically define your structures.

refer to the tutorial on this:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c8780... [original link is broken] [original link is broken]

Depending on how flexible your application is you may want to actually code up n context elements to hold the dropdowns and just hide/unhide the ones you use (easier!) or dynamically create all of it.

Good luck,

Chris

Former Member
0 Kudos

Hi ,

It is possible with <b>only DynamicProgramming.</b>.

In sample applications one DynamicProgramming example is there try to do first that one. After that implement accroding to you.

All the best and GoodLuck.

Rgds

SS

Former Member
0 Kudos

Hi,

What i suggest is create node (DDBINode) and don't add any attributes to the node.

During runtime create attributes equal to the number of dropdowns and map the attributes to dropdown "texts" property while

creating the dropdowns dynamically.In this way each drop down will have its own context attribute.

For data copy the data from Model node to the dynamically created attributes under node (DDBINode) by creating elements under the node.

When you select value in one drop down it will not effect the value in other drop down.

former_member751941
Active Contributor
0 Kudos