Beruflich Dokumente
Kultur Dokumente
Motivation
Before performing some operation you want a confirmation from the user that he/she really wants to complete the task (e.g.
navigate away without saving changes). Ask the user by means of a confirmation dialog box. A standard lightwight popup sufficiates
for this simple task; hence, no custom window, destroyment, message area disabler/enabler etc. for popup is requried.
Required elements
You need a confirmation window (created upon your order by a factory) with some texts (defined by yourself) and at least one button
(defined by yourself). Furthermore, you need at least one event handler (created by yourself) to make the button work.
Step by Step
First, create one EventHandler for each button. Open tab "Methods", click "New", choose type "EventHandler", enter a name
(e.g. GoHome_Canceled and GoHome_Confirmed), click "Finish". Go to tab "Implementation", go to the method(s) just created, add
a short meaningful JavaDoc and implement the activities to be performed.
Second, if creating an international application, add the texts to the MessagePool so they can be translated with ease. See
screenshot for example setting of Message Key and Type.
Third and last, add the following coding for the popup into the onAction-method of the button where you require the confirmation
from the user (or whereever you want to call the popup). Don't forget to perform OrganizeImports after pasting.
//START: lightwight popup window
IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
//let factory create window with first button
IWDEventHandlerInfo evtHndlr = controllerInfo.findInEventHandlers("GoHome_Canceled"); //
<-- Name of event handler, has to match exactly, see step 1 / Methods tab
IWDConfirmationDialog confDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(
/* dialogText, evtHndlr, buttonText OR evtHndlr.getName() */
wdComponentAPI.getTextAccessor().getText("GoHomeConfQuestion"),
evtHndlr,
wdComponentAPI.getTextAccessor().getText("GoHomeConfCancel")
);
//add optional second (or 3rd, 4th,...) button
evtHndlr = controllerInfo.findInEventHandlers("GoHome_Confirmed"); //
<-- Name of event handler, has to match exactly, see step 1 / Methods tab
confDialog.addChoice(evtHndlr, wdComponentAPI.getTextAccessor().getText("GoHomeConfConfirm"));