JSF – RequestScoped CDI Beans and Imixs-Workflow

You can use Imixs-Workflow with a RequestScoped CDI Bean in JSF easily. The thing which is important is that you add two hidden fields into your form containing the $uniqueid and $version.

<!-- Workflow Events -->
 <ui:repeat var="event" value="#{workflowController.events}">
 <h:commandButton action="#{workflowController.process}"
 value="#{event.item['txtname']}">

 <f:setPropertyActionListener
 target="#{workflowController.workitem.item['$ActivityID']}"
 value="#{event.item['numactivityid']}" />

 </h:commandButton>
 </ui:repeat>
 <h:inputHidden value="#{workflowController.workitem.item['$uniqueid']}" />
 <h:inputHidden value="#{workflowController.workitem.item['$version']}" />

This mechanism ensures that the form can not be posted back to the server if the workitem was processed in the meantime. This situation can occur if the user opens the same workitem in multible browser tabs and tries to submit the same workitem form different tabs without refreshing the content. It also secures the situation when the user opens different worktiems in different tabs and tries to submit.

The Imixs-JSF project still uses ConversationScoped CDI Beans. The reason is an issue with the fileUploadController. But I think we will got back to RequestScoped also for the workflowController CID Bean in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.