5 Replies Latest reply on Apr 11, 2008 10:25 PM by pieter.martin

    JBPM: Knowing Which Task You Are Currently In

    darthmaul

      I am using JBPM to define a fairly straightforward process flow, and I want to create a breadcrumb-like structure at the top of each page so users can know where they are in the flow.  Basically, I want something similar to this from the Seam documentation.


      However, since I want to use hyperlinks to allow the user to jump around the flow if necessary, I need to know which task is currently being executed within the flow so that the description of it isn't a link.


      For example,


      Start Order / Shipping Options / Payment Options / Confirm Order


      where I am currently on the page related to executing the Shipping Options task.


      How can I use taskInstance (or some other object) to figure out where I am in the flow dynamically?


      Thanks.

        • 1. Re: JBPM: Knowing Which Task You Are Currently In
          darthmaul

          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.


          Thanks.

          • 2. Re: JBPM: Knowing Which Task You Are Currently In
            pieter.martin

            Hi,


            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 necessary as 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.


            Cheers
            Pieter

            • 3. Re: JBPM: Knowing Which Task You Are Currently In
              neville.sequeira

              Look into ProcessInstance.getRootToken(), ProcessInstance.findToken(String) and ProcessInstance.findAllTokens()


              To jump around in the process, look into Token.setNode()

              • 4. Re: JBPM: Knowing Which Task You Are Currently In
                darthmaul

                Good point.  Maybe jump around was 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 guide to 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?


                Thanks.

                • 5. Re: JBPM: Knowing Which Task You Are Currently In
                  pieter.martin

                  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.


                  Cheers