cancel
Showing results for 
Search instead for 
Did you mean: 

Null pointer exception

Former Member
0 Kudos

Hi Forum,

In the code below I am getting null pointer exception, as such my functionality is working fine but at the end of function my control goes into catch block can someone suggest me why its so.

public void additionalValidations( )

{

//@@begin additionalValidations()

boolean blnLRequiredFieldFlag=true;

boolean blnLEmailIdFlag=true;

boolean blnLEmailIdFormatFlag=true;

MessageManager msgMgr = null;

try

{

msgMgr = (MessageManager)wdThis.wdGetAPI().getComponent().getMessageManager();

blnLEmailIdFlag= wdThis.wdGetAgency_AddUserController().validateEmptyString(wdContext.currentVn_AddNewUserParametersElement().getVa_EmailAddress());

if(blnLEmailIdFlag==false)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("emailflag false"+blnLEmailIdFlag);

blnLRequiredFieldFlag=wdThis.wdGetAgency_AddUserController().validateEmptyString(wdContext.currentVn_AddNewUserParametersElement().getVa_ContactEmailId());

//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("1");

if(blnLRequiredFieldFlag==false)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("2");

msgMgr.reportMessage(IMessageAgency_AddUser.WARNING__REQUIRED_CONTACT_EMAIL_ID,null,false);

}

if(blnLRequiredFieldFlag==true)

{

//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("3");

blnLEmailIdFlag= wdThis.wdGetAgency_AddUserController().validateEmailAddress(wdContext.currentVn_AddNewUserParametersElement().getVa_ContactEmailId());

if(blnLEmailIdFlag==false)

{

//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("4");

msgMgr.reportMessage(IMessageAgency_AddUser.WARNING__IMPROPER_CONTACT_EMAIL_ID,null,false);

}

if(blnLEmailIdFlag==true)

{

//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("5");

blnLRequiredFieldFlag=wdThis.wdGetAgency_AddUserController().validateEmptyString(wdContext.currentVn_AddNewUserParametersElement().getVa_ContactPhNo());

if(blnLRequiredFieldFlag==false)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("6");

msgMgr.reportMessage(IMessageAgency_AddUser.WARNING__REQUIRED_CONTACT_PH_NO,null,false);

}

if(blnLRequiredFieldFlag==true)

{

//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("7");

wdThis.addNewUserConfirmation();

//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("7end");

}

}

}

}

if(blnLEmailIdFlag==true)

{

blnLEmailIdFormatFlag=wdThis.wdGetAgency_AddUserController().validateEmailAddress(wdContext.currentVn_AddNewUserParametersElement().getVa_EmailAddress());

if(blnLEmailIdFormatFlag==false)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("8");

msgMgr.reportMessage(IMessageAgency_AddUser.WARNING__IMPROPER_EMAIL_ID,null,false);

}

if(blnLEmailIdFormatFlag==true)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("9");

blnLRequiredFieldFlag=wdThis.wdGetAgency_AddUserController().validateEmptyString(wdContext.currentVn_AddNewUserParametersElement().getVa_ContactEmailId());

if(blnLRequiredFieldFlag==false)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("10");

msgMgr.reportMessage(IMessageAgency_AddUser.WARNING__REQUIRED_CONTACT_EMAIL_ID,null,false);

}

if(blnLRequiredFieldFlag==true)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("11");

blnLEmailIdFlag= wdThis.wdGetAgency_AddUserController().validateEmailAddress(wdContext.currentVn_AddNewUserParametersElement().getVa_ContactEmailId());

if(blnLEmailIdFlag==false)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("12");

msgMgr.reportMessage(IMessageAgency_AddUser.WARNING__IMPROPER_CONTACT_EMAIL_ID,null,false);

}

if(blnLEmailIdFlag==true)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("13");

blnLRequiredFieldFlag=wdThis.wdGetAgency_AddUserController().validateEmptyString(wdContext.currentVn_AddNewUserParametersElement().getVa_ContactPhNo());

if(blnLRequiredFieldFlag==false)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("14");

msgMgr.reportMessage(IMessageAgency_AddUser.WARNING__REQUIRED_CONTACT_PH_NO,null,false);

}

if(blnLRequiredFieldFlag==true)

{//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("15");

wdThis.addNewUserConfirmation();

}

}

}

}

}

}

catch(Exception e)

{

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Error in the method additionalvalidation, please consult the administrator"+e);

}

//@@end

}

it is also goin into this method wdThis.addNewUserConfirmation(); but its also goin to catch block.

Thanks & Regards

Jaspreet Kaur

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Remove all try/catch blocks and run your application.

Then post the stack.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyapparaj

You mean in all my views n controller for this particular application.

Thanks & Regards

Jaspreet Kaur

Former Member
0 Kudos

Hi,

Where you suspect the call goes to the catch block.

Regards

Ayapparaj

Former Member
0 Kudos

Hi

I removed the try catch from this function. Now wut is happening is as follows:

There is no affect on functionality.

My onactioncontinue calls this function ie additionalvalidation then in this fuction i am calling confirmation dialog box as soon as my confirmation dialog box appears i get null ptr exception if i dont provide the email address. Now its still functioning fine but goin into the catch of onactioncontinue.

Thanks & Regards

Jaspreet Kaur

Former Member
0 Kudos

hi,

Check in side the following functions

validateEmptyString

validateEmailAddress

that the parameter passed is not null

and

before accessing any values check the currentElement exists.

Ex :wdContext.currentVn_AddNewUserParametersElement().getVa_EmailAddress() before this call check wdContext.currentVn_AddNewUserParametersElement() is not null.

Regards

Ayyapparaj

Former Member
0 Kudos

hi

I found my mistake. As I am using same boolean variable n not using else its goin into the true condition n as email id is null throwing the exception.

Thanks & Regards

Jaspreet Kaur

Former Member
0 Kudos

Hi,

Which line is error ,Please paste error message.....

Regards

Karthik

Former Member
0 Kudos

There is no error in any of the lines as i have checked by placing report success msgs...only thing is if i keep email adress as empty it gives tht exception although the code is stilll running successfully my data is goin into the backend n the this particular view navigates to my success view n everything but i guess aftr executing the whole method it display the exception.The thing is this exception is not affection my modules functionality, but as it is cummin i need to get rid of it..

Thanks & Regards

Jaspreet Kaur