Start page / Tutorials / Workflows / Persistent content

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.

For information on pop-up dialogs, see Workflows / Messages and Plug-In Development / Message Boxes.

"counter" script

import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.agency.OperationAgent;
import java.util.concurrent.atomic.AtomicInteger;

session = context.getSession();
counter = session.get("counter");
if (counter == null) {
counter = new AtomicInteger();
session.put("counter", counter);
}

message = "Counter value: " + counter.incrementAndGet();

operationAgent = context.requireSpecialist(OperationAgent.TYPE);

requestOperation = operationAgent.getOperation(RequestOperation.TYPE);
requestOperation.setKind(RequestOperation.Kind.INFO);
requestOperation.addOk();
requestOperation.perform(message);

context.doTransition("->Start");

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