cancel
Showing results for 
Search instead for 
Did you mean: 

Error using DropDownByIndex

MG3
Contributor
0 Kudos

Hi

I'm trying to use DropDownByIndex element. I have a node and one attribute in it. The cardinality of the node is 0...n.

When I deploy the application, I get an error saying:

<i>com.sap.tc.webdynpro.progmodel.context.ContextException: Node(ManojView): must not bind more than one element to a Node of cardinality 0..1 or 1..1</i>

The code I am using is:

String[] ddval = new String[] {"Select Value", "PVal", "QVal", "RVal", "SVal", "TVal"};

	List NodeElements = new ArrayList();
	for(int i=0;i<ddval.length;i++ )
	{
		IPrivateMyView.IDropDownValuesElement el = wdContext.createDropDownValuesElement();
		el.setValue(ddval<i>);
		NodeElements.add(el); 
	}
	  
	wdContext.bind(NodeElements);
    wdContext.nodeDropDownValues().setLeadSelection(1);

I am using <b>NWDS 7.0</b> and deploying on NW2004s. What could be wrong?

Thanks

Manoj

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use this code it will work:

String[] ddval = new String[] {"Select Value", "PVal", "QVal", "RVal", "SVal", "TVal"};

List NodeElements = new ArrayList();

for(int i=0;i<ddval.length;i++ )

{

IPrivateMyView.IDropDownValuesElement el = wdContext.createDropDownValuesElement();

el.setValues(ddval<i>);

NodeElements.add(el);

}

wdContext.nodeDropDownValues().bind(NodeElements);//change made here

wdContext.nodeDropDownValues().setLeadSelection(1);

Regards,

Rajeev

Answers (2)

Answers (2)

Former Member
0 Kudos

Change your code to:


String[] ddval = {"Select Value", "PVal", "QVal", "RVal", "SVal", "TVal"};
 
for (int ix = 0; ix < ddval.length; ix++)
{
  IPrivateMyView.IDropDownValuesElement el = wdContext.nodeDropDownValues().createDropDownValuesElement();
  el.setValue(ddval[ix]);
  wdContext.nodeDropDownValues().addElement(el);
}
wdContext.nodeDropDownValues().setLeadSelection(1);

Armin

Former Member
0 Kudos

Hi OJ,

As suggested Rajeev, replace the line

"<b>wdContext.bind(NodeElements)</b>);" to

"<b>wdContext.nodeDropDownValues().bind(NodeElements)</b>".

U were trying to bind directly to Main context which is not allowed. also make sure that the NodeDropDownValues has cardinality of 0..n or 1..n

Thanks

Srikant