I have studied the Javadocs related to JBPM, and I really can't find anything in the ProcessInstance or anything else that helps me know where we are in the flow. I suppose I could keep track of that in my component, but I have the nagging feeling that this information has to be present somewhere.
Any insight is appreciated.
The way I understand it, the injected taskInstance defines exactly at which node you are at in the current processInstance.
You will not be able to
allow the user to jump around the flow if necessaryas the whole idea is to follow the well define business process. The only way to navigate the process is to bump tokens from node to node.
Look into ProcessInstance.getRootToken(), ProcessInstance.findToken(String) and ProcessInstance.findAllTokens()
To jump around in the process, look into Token.setNode()
Good point. Maybe
jump aroundwas a poor choice of words. And incidentally, also a very poor rap song by House of Pain, but I digress.
Basically, I want to do two things:
- To provide a
guideto the user as to where they are in the process. This could merely be informational and not interactive (e.g. a link).
- To allow the user to go back to another node to change something. For example, you will often see on an E-commerce site the ability to edit the billing address on the confirmation page. If you choose to do that though, then you need to proceed down the flow again.
For the first one, how does the injected taskInstance tell me where I am?
Also, are these objectives compatible with the JBPM
philosophy? For both could I simply provide decision nodes representing the decision to either move to the next step or go to back to any of the previous steps?
- To provide a
With regards to showing the user where you are I implemented a svg picture of the process definition and color in the nodes runtime depending on the node's status. The jbpm web console does a simlar thing by using css to draw colored divs around the nodes in the processdefinition.jpg.
If you are interested I can send you the code for the svg picture. It redraws the eclipse picture from the information in the processdefinition.xml and the gpd.xml.
The picture looks better tho than the code that draws it.
With regards to jumping round, I modeled things more square. If you want the user to edit the billing address on the confirmation page then you model a transformation from the confirm node to the edit billing address node and back again. Not sure if this is a 'good' way but is how I have done it.
The injected taskInstance contains the current token of the process. Not sure there is anything more to know about where you are as it is where you are. It defines the task that the process is waiting for to be done.
Decision nodes are more for when the computer makes the decision, i.e. not a human actor.