cancel
Showing results for 
Search instead for 
Did you mean: 

Centralizing standard Confirmations Dialog in external Component

Former Member
0 Kudos

Hello Community,

i'm developing on an application consisting of several different development-components, each containing again different wd-components. the component design of wd is a great advantage for reuse components.

but i still have a problem to achive better reuseability.

so i have one development-component which contains a component which at the moment contains methods (in the component-controller of that component) for outputing standard-messages. no view controllers or windows are defined.

But i also have some Stanard-Confirmation Dialogs which i want to reuse.

So i declared a new method in that central component-controller which i also declared in the interface controller of the component:


  //@@begin javadoc:dialogWarningNotYetSaved()
  /**
   * Method declared by application.
   */
  //@@end
  public void dialogWarningNotYetSaved( com.sap.tc.webdynpro.progmodel.api.IWDAction contUnsavedEvent, com.sap.tc.webdynpro.progmodel.api.IWDAction contSavedEvent, com.sap.tc.webdynpro.progmodel.api.IWDAction abortEvent )  {
    //@@begin dialogWarningNotYetSaved()
	  /*
	  IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
	  msgMgr.reportMessage(IMessageMessages.NOT_YET_SAVED, null);
	  */
	  String dialogText = wdComponentAPI.getTextAccessor().getText(IMessageMessages.NOT_YET_SAVED, null);
	  IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText, contUnsavedEvent, "Continue Unsaved");
	  dialog.addChoice(contSavedEvent, "Save and Continue");
	  dialog.addChoice(abortEvent, "Abort");
	  dialog.show();
    //@@end
  }

The main problem is, that the dialog does not return a value but instead does fires an action or event, attached to a choice.

But it seems, that such an event has to be one declared in the component. But i want to call the method containing the Confirmation-Dialog from another component and so, in my opinion, it has to trigger the event or action in the calling component. to reach this, i put the actions into parameters of the central method in the external component and put this action-parameters in the dialog.addChoise Method.

But doing so, WD-Runtime throws an exception, that the actions are not known in the repository of the component???

does anybody has an idea what i have to do to make it work correctly?

regards and thanx in advance

Matthias

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Create one event "SaveAndContinueEvent" with some parameters in your Common Component's Component Controller.

SaveAndContinueEvent(String param1, String param2).

And create one more method as "saveAndContinue(String param1, String param2)" in the same Component Controller with same parameters and

fire the event "SaveAndContinueEvent" in that method as below.

wdThis.wdFireSaveAndContinueEvent(param1, param2);

Now in the "contSavedEvent" event handler of the View invoke the method saveAndContinue() of Component Controller as below.

wdThis.wdGetCommonCompController().saveAndContinue(param1, param2);

Now in the Other Components, from where you are invoking this Common Component to open the dialog box, in the corresponding Views create the eventHandler as

"SaveAndContinueEventHandler" and while creating this eventHandler select "SaveAndContinueEvent" of Common Component as a source event to that eventHandler.

Now when ever user clicks on SaveAndContinue button the "SaveAndContinueEvent" event of Common Component will be fired and that even will be handled by "SaveAndContinueEventHandler" of the main view.

Regards,

Charan

Answers (3)

Answers (3)

Former Member
0 Kudos

I ment send the component itself as a parameter and then use findInEvents in 'dialogWarningNotYetSaved'.

Former Member
0 Kudos

Hello,

could you be a little more precise?

reagards

Matthias

Former Member
0 Kudos

pass the event you want to activate to the central function