cancel
Showing results for 
Search instead for 
Did you mean: 

Null pointer exception

Former Member
0 Kudos

Dear SDN,

I am trying to retrieve the attribute value of an attribute by using the following line of code

wdContext.nodenumberABC().getCurrentElement().getAttributeValue("number1").toString();

if when there is some value in the attribute it is able to retrieve the value, but when there is no value it is throwing the nullpointer exception.

I tried using try and catch to get hold of this but application is having poor performance taking some time to load.

can somebody please point me in a correct way of handling the null values without effecting the performance of the application

Appriciate your help

Thanks

RAD

Accepted Solutions (1)

Accepted Solutions (1)

former_member214651
Active Contributor
0 Kudos

Hi,

Check if the object is null before u write this statement:

if(wdContext.nodenumberABC().getCurrentElement() != null)
{
     wdContext.nodenumberABC().getCurrentElement().getAttributeValue("number1").toString();
}

or even try this code:

if(wdContext.currentnumberABCElement() != null)
{
     wdContext.currentnumberABCElement() .getAttributeValue("number1").toString();
}

Regards,

Poojith MV

Answers (0)