cancel
Showing results for 
Search instead for 
Did you mean: 

confirm dialog box

Former Member
0 Kudos

I want to show confirmation dialog box when user clicks on the delete button. Need some code samples on how to implement it.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Create two events named "ok" and "cancel" respectively using method tab on your view screen.

Now add following lines in your delete action on which you want to show the confirm dialog box.


 public void onActionDelete(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionSimulateOrder(ServerEvent)
    IWDControllerInfo cinfo = wdControllerAPI.getViewInfo().getViewController();
    IWDConfirmationDialog confirmDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(
    "Are you sure you wish to delete?", cinfo.findInEventHandlers("ok"), "Yes");
	confirmDialog.addChoice(cinfo.findInEventHandlers("cancel"), "No");
	confirmDialog.show();
    //@@end
  }

  //@@begin javadoc:ok(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void ok(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin ok(ServerEvent)
    //@@end
  }

  //@@begin javadoc:cancel(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void cancel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin cancel(ServerEvent)
    //@@end
  }

When you click on your action a confirm dialob box will appear with message text "Are you sure you wish to delete?" and two buttons "Yes" and "No" mapped to ok and cancel events respectively. Write code in your ok and cancel event to implement the functionality of the buttons.

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

1. Open your view>Methods(Tab)>new event handler and name it as Ok

add one more event handler with the name Cancel

2. Write this code in the action for your delete button.

IWDEventHandlerInfo eventhandler = wdControllerAPI.getViewInfo().getViewController().findinEventhandlers("Ok");

IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationDialog("Are you sure you want to delete?",eventhandler,"Ok");

eventhandler = wdControllerAPI.getViewInfo().getViewController().findinEventhandlers("Cancel");

dialog.addChoice(eventhandler,"Cancel");

dialog.show();

Regards,

Murtuza