Example: Persistent content within workflows
Within workflows, content can also be saved via the session and read out again after switching a transition.
Within the “DoSelectCounting” activity, a counter can be incremented by a value of 1 each time a workflow is run. The value of the counter is saved and incremented by 1 as soon as the workflow is started again. The value is shown to the user within an information dialog.
"counter" script
//!Beanshell
import de.espirit.firstspirit.common.gui.*;
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.agency.OperationAgent;
session = context.getSession();
counter = session.get("counter");
if (counter == null) {
counter = new Integer(1);
}
text = "Counter: " + counter;
requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
requestOperation.setKind(RequestOperation.Kind.INFO);
requestOperation.addOk();
requestOperation.perform(text);
session.put("counter", new Integer(counter + 1));
context.doTransition("->Start");