Start page / Tutorials / Workflows / Messages

Example: Outputting messages in workflows

Within a workflow, messages can be output to the user running it. Messages are output by means of scripts within the workflow. The script displays a dialog to the editor who is responsible for performing the corresponding action within the workflow. Specific information from the context of the workflow can be shown in this dialog.

Creating pop-up dialogs

Popup dialogs can be created using the RequestOperation interface (FirstSpirit Developer API, package de.espirit.firstspirit.ui.operations) (see also Plugins/Message Boxes).

Different kinds of messages can be created using RequestOperation.Kind (FirstSpirit Developer API, package de.espirit.firstspirit.ui.operations):

  • WARN
  • INFO
  • QUESTION
  • ERROR

For example, SiteArchitect and ServerManager display pop-up dialogs of kind WARN with an exclamation mark icon and pop-up dialogs of kind INFO with an “i” icon.

The ContentCreator does not differentiate between pop-up dialogs of kind WARN or INFO. Both kinds are displayed identically with an exclamation mark symbol.

Example (rendering of a WARN message):

import de.espirit.firstspirit.agency.OperationAgent; 
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.ui.operations.RequestOperation.Kind;

opAgent = context.requireSpecialist(OperationAgent.TYPE);
if (opAgent != null) {
RequestOperation requestOp = opAgent.getOperation(RequestOperation.TYPE);
requestOp.setKind(Kind.WARN);
requestOp.setTitle("Whoa, there!");
requestOp.perform("Once you delete this content, there's no getting it back. Make sure you want to do this!");
}
else {
context.logInfo("...");
}

"transitionMessage" script

In this example workflow (“transitionMessage”), an information dialog with the output “Hello $USER” appears before and after a transition is switched.

Once the transition dialog has been activated, another information dialog appears. This contains the output “You have selected transition $TRANSITION. Thank you for the comment $COMMENT”:

//!Beanshell
import de.espirit.firstspirit.common.gui.*;
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.agency.OperationAgent;
 
userName = context.getGuiHost().getUserService().getUser().getLoginName();
 
text = "Hello " + userName + ". Please select a transition.";
 
requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
           requestOperation.setKind(RequestOperation.Kind.INFO);
           requestOperation.addOk();
           requestOperation.perform(text);
 
context.showActionDialog();
transition = context.getTransitionParameters();
 
if (transition.getTransition() != null) {
 
           text="You have selected transition '" + transition.getTransition() + "'.
A good choice.\nThank you for the comment '" + transition.getComment() + "'";
           requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
           requestOperation.setKind(RequestOperation.Kind.INFO);
           requestOperation.addOk();
           requestOperation.perform(text);
           context.doTransition(transition.getTransition());
} else {
           requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
           requestOperation.setKind(RequestOperation.Kind.INFO);
           requestOperation.perform("You have not selected a transition.");
}

The information which is shown to the editor within the dialogs is retrieved in the script via the workflow context (WorkflowScriptContext), e.g. the transition parameters (see example script):    

context.getTransitionParameters();

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.13 | Data privacy