2 Replies Latest reply on Feb 27, 2007 10:17 AM by gavin.king

    Request4Advice: Defining ProcessInstance Var's in Pageflow

    mgombocz

      Hi,
      maybe I am thinking to complicated, so I'd appreciate getting any tipps...

      I have defined a pageflow and I'd like to present a "step counter" on each page (e.g. "Step 1 of 4", "Step 2 of 4" etc.).

      I'd like to define them directly in the pageflow, e.g. "#{totalPages}" once at the beginning and "#{currentPage}" for each page node. These EL expressions will be in the pages for presentation as well.

      Maybe I don't see the wood for the trees, so thanks in advance for any hints.

      Manuel

        • 1. Re: Request4Advice: Defining ProcessInstance Var's in Pagefl
          mgombocz

          To whom it may concern.

          So, here's a solution (a few hours of sleep helped...):

          First of all here's my pageflow where I initialize and update two process variables named "totalPages" and "currentPage":

          <pageflow-definition name="createUser">
           <event type="process-start" >
           <script>
           <expression>
           int total = 2;
           int current = 1;
           </expression>
           <variable name="totalPages" mapped-name="total" access="write" />
           <variable name="currentPage" mapped-name="current" access="write" />
           </script>
           </event>
          
           <start-page name="createUser" view-id="/editUser.xhtml">
           <redirect />
          
           <transition name="cancel" to="cancelled" />
           <transition name="save" to="evaluate">
           </transition>
           </start-page>
          
           <decision name="evaluate"
           expression="#{userManager.usernameUnique}">
          
           <transition name="true" to="enterRoles">
           <action expression="#{userManager.save}" />
           <script>
           <expression>
           current++;
           </expression>
           <variable name="currentPage" mapped-name="current" access="read,write" />
           </script>
           </transition>
          
           <transition name="false" to="createUser" />
           </decision>
          
           <page name="enterRoles" view-id="/editUserRoles.xhtml">
           <redirect />
          
           <transition name="save" to="finished">
           <action expression="#{userManager.flush}" />
           </transition>
          
           <transition name="previous" to="createUser">
           <script>
           <expression>
           current--;
           </expression>
           <variable name="currentPage" mapped-name="current" access="read,write" />
           </script>
           </transition>
          
           <transition name="cancel" to="cancelled" />
           </page>
          
           <page name="finished" view-id="/showUser.xhtml">
           <redirect />
           <end-conversation />
           </page>
          
           <page name="cancelled" view-id="/searchUser.xhtml">
           <redirect />
           <end-conversation />
           </page>
          
          </pageflow-definition>


          These two variables can then be accessed in the views via:
          #{pageflow.processInstance.contextInstance.variables['currentPage']}
          #{pageflow.processInstance.contextInstance.variables['totalPages']}


          For whatever reason using context variable "processInstance" directly does not work, like
          #{processInstance.contextInstance.variables['currentPage']}
          


          Cheers.

          • 2. Re: Request4Advice: Defining ProcessInstance Var's in Pagefl
            gavin.king

            "processInstance" is the ProcessInstance associated with the current business process, not the one for the pageflow.