Class WorkflowController
- All Implemented Interfaces:
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']}
- Version:
- 2.0.0
- Author:
- rsoika
- See Also:
-
Field Summary
Fields inherited from class org.imixs.workflow.faces.data.AbstractDataController
data
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
This action method is used to initialize a new workitem with the initial values of the assigned workflow task.void
This method creates a new empty workitem.This method returns a List of workflow events assigned to the corresponding '$taskId' and '$modelVersion' of the current WorkItem.Returns the current workItem.void
Loads a workitem by a given $uniqueID and starts a new conversation.process()
This method processes the current workItem and returns a new action result.process
(int id) This method processes the current workItem with the provided eventID.void
setWorkitem
(ItemCollection workitem) Set the current worktItemMethods inherited from class org.imixs.workflow.faces.data.AbstractDataController
close, getDefaultType, getDocumentService, isNewWorkitem, onLoad, reset, setDefaultType, startConversation
-
Field Details
-
DEFAULT_TYPE
- See Also:
-
-
Constructor Details
-
WorkflowController
public WorkflowController()
-
-
Method Details
-
getWorkitem
Returns the current workItem. If no workitem is defined the method Instantiates a empty ItemCollection.- Returns:
- - current workItem or an emtpy workitem if not set
-
setWorkitem
Set the current worktItem- Parameters:
workitem
- - new reference or null to clear the current workItem.
-
create
This action method is used to initialize a new workitem with the initial values of the assigned workflow task. The method updates the Workflow attributes '$WriteAccess','$workflowgroup', '$workflowStatus', 'txtWorkflowImageURL' and 'txtWorkflowEditorid'.- Parameters:
action
- - the action returned by this method- Throws:
ModelException
- is thrown in case not valid workflow task if defined by the current model.
-
create
This method creates a new empty workitem. An existing workitem and optional conversation context will be reset. The method assigns the initial values '$ModelVersion', '$ProcessID' and '$UniqueIDRef' to the new workitem. The method creates the empty field '$workitemID' and the item '$owner' which is assigned to the current user. This data can be used in case that a workitem is not processed but saved (e.g. by the dmsController). The method starts a new conversation context. Finally the method fires the WorkfowEvent WORKITEM_CREATED.- Parameters:
modelVersion
- - model versionprocessID
- - processIDprocessRef
- - uniqueid ref- Throws:
ModelException
-
process
This method processes the current workItem and returns a new action result. The action result redirects the user to the default action result or to a new result provided by the workflow model. The 'action' property is typically evaluated from the ResultPlugin. Alternatively the property can be provided by an application. If no 'action' property is provided the method returns null.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.
- Returns:
- the action result provided in the 'action' property or evaluated from the default property 'txtworkflowResultmessage' from the ActivityEntity
- Throws:
PluginException
ModelException
-
process
This method processes the current workItem with the provided eventID. The method can be used as an action or actionListener.- Parameters:
id
- - activityID to be processed- Throws:
PluginException
ModelException
- See Also:
-
getEvents
This method returns a List of workflow events assigned to the corresponding '$taskId' and '$modelVersion' of the current WorkItem.The method uses a caching mechanism to load the event list only once
- Returns:
- Throws:
ModelException
-
load
Loads a workitem by a given $uniqueID and starts a new conversation. The conversation will be ended after the workitem was processed or after the MaxInactiveInterval from the session.- Overrides:
load
in classAbstractDataController
- Parameters:
uniqueID
-
-