public final class ClientUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ClientUtil.DialogConfiguration
A configuration object that holds all the settings to be used for presenting the requested dialog on the clientside
|
Modifier and Type | Method and Description |
---|---|
static Pair<String,JSONObject> |
getAsJSON(ActivityInstance ai)
Get a JSONObject from an ActivityInstance in the context of a worklist node.
|
static JSONObject |
getAsJSON(HttpServletRequest req,
Persistent object)
Builds a
JSONObject representation for an object as it's expected by the client side store. |
static JSONObject |
getAsJSON(Map<String,Object> row)
Builds a
JSONObject from a Map of data for a table row. |
static JSONObject |
getAsJSON(String wlNodeId,
ActivityInstance ai)
Get a JSONObject from an ActivityInstance in the context of a worklist node.
|
static JSONObject |
getAsJSON(String nodeId,
HttpServletRequest req,
String objectId)
Builds a
JSONObject representation for an object as it's expected by the client side store. |
static JSONObject |
getChangesAsJSON()
Get a JSONObject suitable for sending the threads own changes back to the Gui.
|
static JSONObject |
getChangesAsJSON(boolean avoidAutoNotification)
Get a JSONObject suitable for sending the threads own changes back to the Gui.
|
static JSONObject |
getChangesAsJSON(String guiId)
Get a JSONObject suitable for sending the threads own changes back to the Gui.
|
static JSONObject |
getChangesAsJSON(String guiId,
boolean avoidAutoNotification)
Get a JSONObject suitable for sending the threads own changes back to the Gui.
|
static JSONObject |
getChangesAsJSON(String guiId,
Set<Pair<Long,Long>> additionalChangeSet)
Get a JSONObject suitable for sending the threads own changes back to the Gui.
|
static JSONObject |
getChangesAsJSON(String guiId,
Set<Pair<Long,Long>> additionalChangeSet,
boolean avoidAutoNotification)
Get a JSONObject suitable for sending the threads own changes back to the Gui.
|
static String |
getGuiId()
Get the id of the current gui.
|
static String |
getGuiId(HttpServletRequest req)
Get the id of the current gui from the HttpServletRequest
|
static Set<Pair<Long,Long>> |
toChangeSet(Collection<ActivityInstance> ais)
Transform a collection of ActivityInstances to a suitable structure for
getChangesAsJSON(String, Set) . |
static String |
userInput(String parameterName,
Supplier<ClientUtil.DialogConfiguration> builder)
Can be used to request input from the user during interactive transactions.
|
public static String getGuiId()
public static String getGuiId(HttpServletRequest req)
req
- the requestpublic static JSONObject getChangesAsJSON()
getGuiId()
.getChangesAsJSON(String, Set, boolean)
public static JSONObject getChangesAsJSON(boolean avoidAutoNotification)
getGuiId()
.avoidAutoNotification
- if true, the changes will not be send back to the originating client session via notification.getChangesAsJSON(String, Set, boolean)
public static JSONObject getChangesAsJSON(String guiId)
guiId
- the id of the XMLGui to usegetChangesAsJSON(String, Set, boolean)
public static JSONObject getChangesAsJSON(String guiId, boolean avoidAutoNotification)
guiId
- the id of the XMLGui to useavoidAutoNotification
- if true, the changes will not be send back to the originating client session via notification.getChangesAsJSON(String, Set, boolean)
public static Set<Pair<Long,Long>> toChangeSet(Collection<ActivityInstance> ais)
getChangesAsJSON(String, Set)
.ais
- the collection of ActivityInstancespublic static JSONObject getChangesAsJSON(String guiId, Set<Pair<Long,Long>> additionalChangeSet)
Beware: this call commits the actions.
guiId
- the id of the XMLGui to use; can also be nodeId, then the guiId prefix will be extracted.additionalChangeSet
- additional information about changes to activityinstances that could not be automatically detected by the system. Can be null.getChangesAsJSON(String, Set, boolean)
public static JSONObject getChangesAsJSON(String guiId, Set<Pair<Long,Long>> additionalChangeSet, boolean avoidAutoNotification)
Beware: this call commits the actions.
According the additionalChangeSet
parameter: sometimes the activityinstances do not change, but nevertheless they may end up in different worklists (e.g. movement),
since there are no updates associated with this activityinstances, there are no detectable storage events for this activityinstances.
The additionalChangeSet
parameter can be used to inform this method about such changes. It is a set of pairs of oids and transactionids
of such activityinstances that did not change in terms of the database but in terms of gui representation (see: toChangeSet(Collection)
).
N.B.Changes specified via additionalChangeSet
will only be reflected in the result of this function and not in notifications for other sessions.
If other sessions should be notified about such undetectable changes too,
use WfEngine.propagateChange(ActivityInstance)
before calling this function.
guiId
- the id of the XMLGui to use; can also be nodeId, then the guiId prefix will be extracted.additionalChangeSet
- additional information about changes to activityinstances that could not be automatically detected by the system. Can be null.avoidAutoNotification
- if true, the changes will not be send back to the originating client session via notification.
In this case the it is the responsibility of the caller to send the changes back itself.public static Pair<String,JSONObject> getAsJSON(ActivityInstance ai)
ai
- the ActivityInstancepublic static JSONObject getAsJSON(String wlNodeId, ActivityInstance ai)
wlNodeId
- the id of the worklist node in the the XMLGui to use. Must be prefixed by a gui id (e.g. standard.wl).ai
- the ActivityInstancepublic static JSONObject getAsJSON(String nodeId, HttpServletRequest req, String objectId) throws Exception
JSONObject
representation for an object as it's expected by the client side store.nodeId
- the XML node id. Must be prefixed by the gui id (e.g. standard.mynode).req
- the current servlet request. Required for initializing the data provider of the node.objectId
- the id of the object (in the form of classname:oid)Exception
public static JSONObject getAsJSON(HttpServletRequest req, Persistent object) throws Exception
JSONObject
representation for an object as it's expected by the client side store.
The content depends on the store definition. The request parameter "nodeid" should
contain the GUI-id of a table (alternative, deprecated parameter name: node).req
- a servlet requestobject
- a persistent objectException
public static JSONObject getAsJSON(Map<String,Object> row) throws Exception
JSONObject
from a Map
of data for a table row.
Performs all the serialization (handles CellValue
, Persistent
, Date
...)row
- the dataException
public static String userInput(String parameterName, Supplier<ClientUtil.DialogConfiguration> builder)
ThreadContext.getThreadRequest()
the current transaction is aborted by throwing an exception, and a dialog is presented to the user. After providing a value, the same request is performed a second time.
A common use case would be to request data or confirm proceeding in a workflow-postcondition/preprocessing or when saving a form.
String name = ClientUtil.userInput("promptTest", () -> new DialogConfiguration()
.setMessage("whats your name")
.setType(Type.PROMPT));
ClientUtil.userInput("confirmTest", () -> new DialogConfiguration()
.setMessage("Do you really want to continue?"));
String gender = ClientUtil.userInput("genderTest", () -> new DialogConfiguration()
.setMessage("Choose your gender:")
.setOptions(Arrays.asList(new Pair<>("male","male"), new Pair<>("female","female"), new Pair<>("other","other"))));
BeanManager
-transaction handling kicks in and performs a clean BeanManager.rollback()
.
userInput(String, Supplier)
doesn't perform any explicit transaction-handling.parameterName
- the parametername to be used on ServletRequest.getParameter(String)
builder
- usually a lambda expression, that provides a ClientUtil.DialogConfiguration
to be used@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.