cancel
Showing results for 
Search instead for 
Did you mean: 

NullpointerException while creating ConfirmationDialogBox

Former Member
0 Kudos

Hi all

i want to pop up a confirmationDialogBox on date selection in a DateNavigator

so in actionhandler onDayselect() for DateNavigator i have written following code

String dialogText = "abc";

IWDControllerInfo info =

wdControllerAPI.getViewInfo().getViewController();

IWDConfirmationDialog dialog = wdComponentAPI.

getWindowManager().

createConfirmationWindow (dialogText,info.findInEventHandlers("HdayDialog"),"OK");

dialog.show();

but i am getting nullpointerException in this code for the line createconfirmationDialog

regarding action handlers i have created the same handler as mentioned here with exact name

can anyone tell me the reason??

plz help

Deepak

Accepted Solutions (1)

Accepted Solutions (1)

former_member201361
Active Contributor
0 Kudos

hi,

Use this code for tyhe confirmation window popup

public void onActionSubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionSubmit(ServerEvent)

IWDControllerInfo controllerInfo =

wdControllerAPI.getViewInfo().getViewController();

String dialogText = "welcome to the new pop up window";

IWDConfirmationDialog dialog =(IWDConfirmationDialog) wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText,controllerInfo.findInEventHandlers("submit"),"ok");

dialog.open();

//@@end

}

here on clicking submit a new window is opened

thanks and regards

fazal

Former Member
0 Kudos

hi fazal

thanks for reply.

this is the same code am using only that you have used dialog.open() function.

but actually that function is deprecated so i have used dialog.show().

and code execution won't reach till that line since it is getting nulpointer exception at line createconfirmationdialog .

Deepak

Former Member
0 Kudos

hi deepak,

please use this code, it has worked for me


public void onActiondialog(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActiondialog(ServerEvent)
 IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
 String text = "Do you want to proceed";
 
 IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow
                                       (text,controllerInfo.findInEventHandlers("yes"),"yes");
 dialog.addChoice(controllerInfo.findInEventHandlers("no"),"no");
 dialog.show();
    //@@end
}
  

regards,

pinki

Former Member
0 Kudos

hi pinki

thanks for reply.

actually the code upto createconfirmationdialog line is same in both of case of us.and thats where i am getting nullpointerexception.

even that had worked for me in some different program

but now i don't know what has gone wrong

Deepak

former_member201361
Active Contributor
0 Kudos

hi,

in my code "submit " is the event handler which i have created for the window .

please check whether u have created a eventhandler for the confirmation window.

thanks and regards

fazal

former_member182294
Active Contributor
0 Kudos

Hi Deepak,

IWDConfirmationDialog dialog =(IWDConfirmationDialog) wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText,controllerInfo.findInEventHandlers("onActionHdayDialog"),"ok");
dialog.open();

Change the event handler name from HdayDialog to onActionHdayDialog. Please recheck the spelling of onActionHdayDialog.

//your code is

info.findInEventhandlers("HdayDialog")

//change it to

info.findInEventhandlers("onActionHdayDialog")

Regards

Abhilash

Former Member
0 Kudos

hi abhilash

thank you for help.

can you do me another favor?

i want to pass on date as an attribute to this eventhandler.

how do i achieve that??

Deepak

former_member182294
Active Contributor
0 Kudos

Hi,

You can read the date from context attribute to which its binded. You can also pass as the parameter but that binding should be done in wdModifyView. Please elaborate your requirement.

Regards

Abhilash

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Try to post the stack trace to get a better understanding of the problem

Regards,

Sudhir

Former Member
0 Kudos

Hi Deepak,

I think you have not specified the Event handler with name HdayDialog or could be info.findInEventHandlers("HdayDialog") returning null value

Try this code


IWDControllerInfo contInfo = wdControllerAPI.getViewInfo().getViewController();   	
IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow( "Event String", contInfo.findInEventHandlers( "ok"), "OK");
   	dialog.addChoice( contInfo.findInEventHandlers( "cancel"), "Cancel");
 dialog.show();

// Later create two methods with names ok and cancel

Regards

- Vinod

*

Former Member
0 Kudos

hi vinod

actually the info.findInEventhandlers("HdayDialog") is returning me null value.

while as there is such eventhandler in my program. i can see it in my code and still it'is returning me null value

Deepak