Class DocumentController

java.lang.Object
org.imixs.workflow.faces.data.AbstractDataController
org.imixs.workflow.faces.data.DocumentController
All Implemented Interfaces:
Serializable

@Named @ConversationScoped public class DocumentController extends AbstractDataController implements Serializable
The DocumentController is a @ConversationScoped CDI bean to control the life cycle of a ItemCollection in an JSF application without any workflow functionality. The bean can be used in single page applications, as well for complex page flows. The controller is easy to use and supports bookmarkable URLs.

The DocumentController fires CDI events from the type WorkflowEvent. A CDI bean can observe these events to participate in the processing life cycle.

To load a document the methods load(id) and onLoad() can be used. The method load expects the uniqueId of a document to be loaded. The onLoad() method extracts the uniqueid from the query parameter 'id'. This is the recommended way to support bookmarkable URLs. To load a document the onLoad method can be triggered by an jsf viewAction placed in the header of a JSF page:

 
    <f:metadata>
      <f:viewAction action="... documentController.onLoad()" />
    </f:metadata> 
 

A bookmarkable URL looks like this:

/myForm.xthml?id=[UNIQUEID]

In combination with the viewAction the DocumentController is automatically initialized.

After a document is loaded, a new conversation is started and the CDI event WorkflowEvent.DOCUMENT_CHANGED is fired.

After a document was saved, the conversation is automatically closed. Stale conversations will automatically timeout with the default session timeout.

After each call of the method save the Post-Redirect-Get is initialized with the default URL from the start of the conversation. This guarantees bookmakrable URLs.

Within a JSF form, the items of a document can be accessed by the getter method getDocument().

   #{documentController.document.item['$workflowstatus']}
 

The default type of a entity created with the DataController is 'workitem'. This property can be changed from a client.

Version:
0.0.1
Author:
rsoika
See Also:
  • Field Details

    • events

      @Inject protected jakarta.enterprise.event.Event<WorkflowEvent> events
  • Constructor Details

    • DocumentController

      public DocumentController()
  • Method Details

    • getDocument

      public ItemCollection getDocument()
      Returns the current workItem. If no workitem is defined the method Instantiates a empty ItemCollection.
      Returns:
      - current workItem or null if not set
    • setDocument

      public void setDocument(ItemCollection document)
      Set the current worktItem
      Parameters:
      workitem - - new reference or null to clear the current workItem.
    • create

      public void create()
      This method creates an empty workItem with the default type property and the property '$Creator' holding the current RemoteUser This method should be overwritten to add additional Business logic here.
    • save

      public void save() throws AccessDeniedException
      This method saves the current document.

      The method fires the WorkflowEvents WORKITEM_BEFORE_SAVE and WORKITEM_AFTER_SAVE.

      Throws:
      AccessDeniedException - - if user has insufficient access rights.
    • delete

      public void delete(String uniqueID) throws AccessDeniedException
      This action method deletes a workitem. The Method also deletes also all child workitems recursive
      Parameters:
      currentSelection - - workitem to be deleted
      Throws:
      AccessDeniedException
    • load

      public void load(String uniqueid)
      Loads a workitem by a given $uniqueid and starts a new conversaton. The conversaion will be ended after the workitem was processed or after the MaxInactiveInterval from the session.
      Overrides:
      load in class AbstractDataController
      Parameters:
      uniqueid -