cancel
Showing results for 
Search instead for 
Did you mean: 

Read Source from IWDCustomEvent

Former Member
0 Kudos

Hello,

I have in webdynpro ABAP an action, which opening a confirmation-dialog with two Buttons "yes" / "no".

I can check in wdEvent from the action of destination, which button clicked.

For Example: wd_Event->getParameter("ID"). The returnValue ist btn_yes, if clicked "Yes" and btn_no, if clicked "No". The issue is, I can use the same action for Yes and No and check with an abstract function the ButtonID.

Now, I'm search the same function in Webdynpro JAVA.

How I can get the called ID from com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent in an action?

IWDCustomEvent has a few getter (getString(""), getObject("")...). But I don't know the name of the getter-parameter for the ID.

Or, how I can open the confirmation dialog with a parameter and get it in the event?

I hope, your have a nice answer.

Regards

Maik

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello,

that is the standard way to create a confirmation dialog with 2 actions.

I know it.

I'm searching an answer, how I do it with one action.

//Example


boolean gv_checkId = false;

public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
   String btnKey = wdEvent.getObject("?????");
   if(btnKey == null || !btnKey.equals("btn_ok"))
      gv_checkId = false;
   else if(btnKey.equals("btn_cancel"))
   {
     gv_checkId = false;
     return;
   }
  else 
       gv_checkId = true;

   if(!gv_checked)
  {
     IWDConfirmationDialog window = wdComponentAPI.getWindowManager().createConfirmationWindow  ("Save it?", wdThis.wdGetCloseAction(), "Close");
    window.addChoice(wdThis.WD_EVENTHANDLER_ON_SAVE, "Cancel");
    window.addChoice(wdThis.WD_EVENTHANDLER_ON_SAVE, "OK");
    window.open();
    return;
  }
  
  save();
}

It works fine in Webdynpros ABAP, but Webdynpro JAVA?

Regards

Maik

Edited by: Maik Sturm on Jun 25, 2009 2:13 PM

Former Member
0 Kudos

you have to rethink your approach on Java

you gonna have a save button with the method save that only opens the confirmation window

public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ){
     IWDConfirmationDialog window = wdComponentAPI.getWindowManager().createConfirmationWindow  ("Save it?", wdThis.WD_EVENTHANDLER_ON_CANCEL, "Cancel");
    window.addChoice(wdThis.WD_EVENTHANDLER_ON_SAVE, "OK");
    window.open(); ///..or show
  }
}

then you have two other methods (event handlers): onSave and on Cancel:

public void onSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ){
   save();
}

public void onCancel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ){
   //do other stuff
}

...

about your solution, I think this:

onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

is not this:

wdThis.WD_EVENTHANDLER_ON_SAVE,

I think it would be:

wdThis.WD_EVENTHANDLER_ON_ACTION_SAVE,

...also print the wdEvent.getName() to see whats there

Edited by: Jean Carlo Abreu on Jun 25, 2009 2:26 PM

Former Member
0 Kudos

Hello,

it was a small error in my code.

Here the code with the right Action:


boolean gv_checkId = false;
 
public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
   String btnKey = wdEvent.getObject("?????");
   if(btnKey == null || !btnKey.equals("btn_ok"))
      gv_checkId = false;
   else if(btnKey.equals("btn_cancel"))
   {
     gv_checkId = false;
     return;
   }
  else 
       gv_checkId = true;
 
   if(!gv_checked)
  {
     IWDConfirmationDialog window = wdComponentAPI.getWindowManager().createConfirmationWindow  ("Save it?", wdThis.wdGetCloseAction(), "Close");
    window.addChoice(wdThis.WD_EVENTHANDLER_ON_ACTION_SAVE, "Cancel");
    window.addChoice(wdThis.WD_EVENTHANDLER_ON_ACTION_SAVE, "OK");
    window.open();
    return;
  }
  
  save();
}

But, I look at your answers, that I must used in WD4J for each action a second "checkAction".

Regards

Maik

Former Member
0 Kudos
pravesh_verma
Active Contributor
0 Kudos

Hi Maik,

You need to follow these steps.

1) Create 2 actions. OK and Cancel in the action tab.

2) Use this code:


IWDConfirmationDialog window = wdComponentAPI.getWindowManager().createConfirmationWindow("<Your Message>", wdThis.wdGetCloseAction(), "Close");
window.addChoice(wdThis.WD_EVENTHANDLER_ON_CANCEL, "Cancel");
window.addChoice(wdThis.WD_EVENTHANDLER_ON_OK, "OK");

Please note that the parameters are case sensitive. So make sure you enter the correct action name. In this case it is the last parameter. i.e.: OK and Cancel.

When you click these buttons corresponsding action will be called automatically by the framework. handle whatever you want in the respective action.

I hope this solves the issues. Please revert back in case you need any further information on this.

Thanks and Regards,

Pravesh