@Named @ConversationScoped public class WorkflowController extends AbstractDataController implements Serializable
The WorkflowController fires CDI events from the type WorkflowEvent. A CDI bean can observe these events to participate in the processing life cycle.
To load a workitem the methods load(id) and onLoad() can be used. The method load expects a valid uniqueId of a workItem to be loaded. The onLoad() method extracts the uniqueid from the query parameter 'id'. This is the recommended way to support bookmarkable URLs when opening a JSF page with the data of a workitem. The onLoad method can be triggered by an jsf viewAction placed in the header of a JSF page:
<f:metadata>
<f:viewAction action="... workflowController.onLoad()" />
</f:metadata>
A bookmarkable URL looks like this:
/myForm.xthml?id=[UNIQUEID]
In combination with the viewAction the WorkflowController is automatically initialized.
After a workitem is loaded, a new conversation is started and the CDI event WorkflowEvent.WORKITEM_CHANGED is fired.
After a workitem was processed, the conversation is automatically closed. Stale conversations will automatically timeout with the default session timeout.
After each call of the method process the Post-Redirect-Get is initialized with the default URL from the start of the conversation. If an alternative action result is provided by the workflow engine, the WorkflowController automatically redirects the user to the new form outcome. This guarantees bookmarkable URLs.
Call the close() method when the workitem data is no longer needed.
Within a JSF form, the items of a workitem can be accessed by the getter method getWorkitem().
#{workflowController.workitem.item['$workflowstatus']}
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_TYPE |
data| Constructor and Description |
|---|
WorkflowController() |
| Modifier and Type | Method and Description |
|---|---|
void |
create()
This action method is used to initialize a new workitem with the initial
values of the assigned workflow task.
|
void |
create(String modelVersion,
int taskID,
String uniqueIdRef)
This method creates a new empty workitem.
|
List<org.imixs.workflow.ItemCollection> |
getEvents()
This method returns a List of workflow events assigned to the corresponding
'$taskid' and '$modelversion' of the current WorkItem.
|
org.imixs.workflow.ItemCollection |
getWorkitem()
Returns the current workItem.
|
void |
load(String uniqueid)
Loads a workitem by a given $uniqueid and starts a new conversaton.
|
String |
process()
This method processes the current workItem and returns a new action result.
|
String |
process(int id)
This method processes the current workItem with the provided eventID.
|
void |
setWorkitem(org.imixs.workflow.ItemCollection workitem)
Set the current worktItem
|
addMessage, close, getDefaultType, isNewWorkitem, onLoad, reset, setDefaultType, startConversationpublic static final String DEFAULT_TYPE
public org.imixs.workflow.ItemCollection getWorkitem()
public void setWorkitem(org.imixs.workflow.ItemCollection workitem)
workitem - - new reference or null to clear the current workItem.public void create()
throws org.imixs.workflow.exceptions.ModelException
action - - the action returned by this methodorg.imixs.workflow.exceptions.ModelException - is thrown in case not valid worklfow task if defined by the
current model.public void create(String modelVersion, int taskID, String uniqueIdRef) throws org.imixs.workflow.exceptions.ModelException
modelVersion - - model versionprocessID - - processIDprocessRef - - uniqueid reforg.imixs.workflow.exceptions.ModelExceptionpublic String process() throws org.imixs.workflow.exceptions.PluginException, org.imixs.workflow.exceptions.ModelException
The method fires the WorkflowEvents WORKITEM_BEFORE_PROCESS and WORKITEM_AFTER_PROCESS.
The Method also catches PluginExceptions and adds the corresponding Faces Error Message into the FacesContext. In case of an exception the WorkflowEvent WORKITEM_AFTER_PROCESS will not be fired.
In case the processing was successful, the current conversation will be closed. In Case of an Exception (e.g PluginException) the conversation will not be closed, so that the current workitem data is still available.
org.imixs.workflow.exceptions.PluginExceptionorg.imixs.workflow.exceptions.ModelExceptionpublic String process(int id) throws org.imixs.workflow.exceptions.ModelException, org.imixs.workflow.exceptions.PluginException
id - - activityID to be processedorg.imixs.workflow.exceptions.PluginExceptionorg.imixs.workflow.exceptions.ModelExceptionprocess()public List<org.imixs.workflow.ItemCollection> getEvents()
public void load(String uniqueid)
load in class AbstractDataControlleruniqueid - Copyright © 2006–2019 Imixs Software Solutions GmbH. All rights reserved.