cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByIndex

Former Member
0 Kudos

Hi All,

I have a dropdown byIndex which is being populated by calling a bapi.

I set that cardinality to 0..n

So I am getting blank row in that DD.

I dont want to change the cardinality to 1..1

But If the user selects the blank row in dropdown,on click of one button I want to show the error message saying that "Plz fill all Madatory fields".

But on action I am getting the Value of the attribute which is bind with the drop down.But that is giving null pointer exception. Tell me the proper way to do this..

Thankx and Regards,

Karthick

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

the problem seems to be that you have no "currentElement" in your context. You should check whether the currentElement return null. In general its bad practice to catch an exception instead of check for null values where you expect one. To throw and catch an exception is a hundred times more costly then a simple if-check.

Also have a look at:

http://help.sap.com/saphelp_erp2004/helpdata/en/95/93fe1e71a2e44691b1f041e67f71aa/content.htm

Frank

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi karthick,

do one thing.if user selects blank row.it will raise nullpoiner exception.catch that null pointer exception.

display error message.

like

try{

//ur coode

}catch(NullPointerException e)

{

wdComponentAPI.getMessageManager().reportException("select any value",true);

}

hope this will work

regards

Naidu

Former Member
0 Kudos

Hi Karthick,

Inside the action handler, just write:

if(null==wdContext.current<node>Element.get<DD_Attribute>())

{

wdComponentAPI.getmessageManager().reportWarning("Plz fill all Madatory fields");

return;

}

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

Still I am getting Null pointer exception in that line where i have written the code ...

if(null==wdContext.current<node>Element.get<DD_Attribute>()).

Is there any other way?

Regards,

karthick

Former Member
0 Kudos

Karthik,

check for

wdContext.current<node>Element()==null...

Not the actual attribute...

I hope it works