cancel
Showing results for 
Search instead for 
Did you mean: 

Binding values to DropDown at runtime

Former Member
0 Kudos

Hello,

I am on EP7.0 ERP05 and NW04s and trying to add values to a dropdownbyIndex at runtime using the following code:

String[] exempt_status= new String[] {"Exempt,reportable","Not Exempt"

};

List ListOfExempts = new ArrayList();

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

{

IPrivateDetailView.IExemptNodeElement ex=wdContext.createExemptNodeElement();

ex.setExemptAttribute(exempt_status<i>);

ListOfExempts.add(ex);

}

wdContext.nodeExemptNode().bind(ListOfExempts);

for (int e = 0; e < wdContext.nodeExemptNode().size(); ++e)

{

wdContext.nodeExemptNode().setSelected(e, e>=0 && e<=1 );

}

wdContext.nodeExemptNode().setLeadSelection(1);

//@@end

}

This creates a dropdown fine with default value as "Not Exempt" but also inserts a blank value after that and then the other 2 and when the user selects this blank value it results in a Null pointer exception ... when I debug and check if it's null it says "Attribute value passed to non-object value"

How can I rectify this by removing the blank option altogether...

Any help would be highly appreciated,.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Thanks for the reply. I changed the cardinality to 1..n still it didn't help/

Please help.

Former Member
0 Kudos

Hi,

If your DDBI node cardinality is 0..n then the DDBI will have a Empty

element at the start else if cardinality 1..n then their is no blank element in DDBI.

String[] exempt_status= new String[] {"Exempt,reportable","Not Exempt"};

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

{

IPrivateDetailView.IExemptNodeElement ex=wdContext.createExemptNodeElement();

ex.setExemptAttribute(exempt_status);

wdContext.nodeExemptNode.addElement(ex);

}

wdContext.nodeExemptNode().setLeadSelection(1);

//@@end

}

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks

Former Member
0 Kudos

Thanks guys for your help. I modified the selection of the node to 1...n and it worked ..

Thanks

Former Member
0 Kudos

Hi,

If your issue is solved please close the thread and award points to the responsible person.

Former Member
0 Kudos

Hello Sriram,

Thanks for the reply. I tried to change the cardinality to 1...n but still it didn't help , even if it has a blank value how do we handle it because when we select it it results in a null pointer exception....

Looking forward to your reply.

Former Member
0 Kudos

The empty value denotes the empty selection and appears if the context node has <b>selection </b>cardinality 0:1. If you want to have always a selected element, change the selection of the context node to 1:1.

Armin

Former Member
0 Kudos

Hi Subhash,

DDIndex always display one blank entry. Use DDKey instead

Create a context variable (not inside a node) and bind it to value of DDKey.

Let the variable name be DDVal.

To put the values to DDKey, try the following code

IWDAttributeInfo approverInfo=wdContext.getNodeInfo().getAttribute(IPrivate<View>.IContxetElement.DDVAL);

ISimpleTypeModifiable stf=approverInfo.getModifiableSimpleType();

IModifiableSimpleValueSet svs=stf.getSVServices().getModifiableSimpleValueSet();

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

{

String key=masterEl.get<Key>().toString();

String value=masterEl.get<KeyValue>().toString();

svs.put(key,value);

}

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi,

Change the cardinality of the node from 0..n to 1..n.

Regards

Ayyapparaj