cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByIndex causes crash if empty slot selected

Former Member
0 Kudos

I hope somebody could give me some advice.

I have a dropdown by index in my WD app which has an action bound to it. This action gets the current selection as a string. If the user happens to select the empty slot which the dropdown has by default at the top, the app crashes and displays a NullPointerException. No help if I try to validate whether the string var is null or try to calculate the length or anything. Every time the app tries to get the current selection (when the empty slot is selected) and put it in to a variable or perform some other operation on it, it crashes.

How to circumvent this?

Regards,

Erno

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check the value of dropwown by Index like this

if(wdContext.node<Node>().getLeadSelection()==-1)

{

wdComponentAPI.getMessageManager().reportWarning("Select a value");

}

Regards

Fahad Hamsa

Answers (2)

Answers (2)

Former Member
0 Kudos

If you don't want the empy entry at all, set selection cardinality of the node to 1:1 instead of 0:1.

Armin

Former Member
0 Kudos

Great! Thanks for the hint.

Problem solved and points assigned..

-e