4 Replies Latest reply on Dec 9, 2008 5:08 PM by mgombocz.mgombocz.agilion.net

    Using beanshell script in jPDL pageflows

    mgombocz.mgombocz.agilion.net

      Hi,


      I would like to use beanshell script functionality in pageflows. Especially, to show the user the progress of his operation: Page 1 of 4, Page 2 of 4 and so forth.


      I already successfully realized it with Seam 1.1.6 last year, but now (2.0.2.SP1) I got following errors/warnings:


      The pageflow I used with Seam 1.1.6:


      <pageflow-definition name="createEmployee">


           <event type="process-start" >


                <script>


                     <expression>


                          int total = 3;


                          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="createEmployee" view-id="/editEmployee.xhtml">


      ...


           </start-page>


           <page name="createUser" view-id="/editUser.xhtml">


                <redirect />


                <transition name="cancel" to="cancelled" />


                <transition name="save" to="enterRoles">


                     <script>


                          <expression>current++;</expression>


                          <variable name="currentPage" mapped-name="current" access="read,write" />


                     </script>


                </transition>


           </page>


      ...


      </pageflow-definition>



      I accessed these variables in JSF like this:


      <s:div rendered="#{pageflow.inProcess}" styleClass="dialog">


      Page #{pageflow.processInstance.contextInstance.variables['currentPage']} of #{pageflow.processInstance.contextInstance.variables['totalPages']}


      </s:div>


      If I reuse the pageflow in Seam 2.0.2.SP1 I got following error:


      Caused by: org.jbpm.jpdl.JpdlException: [[ERROR] line 11: cvc-complex-type.2.4.a: Invalid content was found starting with element 'script'. One of '{"http://jboss.com/products/seam/pageflow":action}' is expected., [ERROR] line 31: cvc-complex-type.2.4.a: Invalid content was found starting with element 'script'. One of '{"http://jboss.com/products/seam/pageflow":condition, "http://jboss.com/products/seam/pageflow":action, "http://jboss.com/products/seam/pageflow":exception-handler}' is expected., [ERROR] line 48: cvc-complex-type.2.4.a: Invalid content was found starting with element 'script'. One of '{"http://jboss.com/products/seam/pageflow":action, "http://jboss.com/products/seam/pageflow":exception-handler}' is expected.]


      Then I changed the script blocks in the pageflow by surrounding them with <action> blocks:


           <event type="process-start">


                <action>


                     <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>


                </action>


           </event>


      In this case I receive the following warning:


      01:50:27,625 WARN  [JpdlXmlReader] process xml warning: action does not have class nor ref-name attribute <action xmlns="http://jboss.com/products/seam/pageflow" config-type="field" accept-propagated-events="true">


      With this warning the script variables are not accessible in my JSF.


      Do you know what I am doing wrong or what I have to change to make it work like with Seam 1.1.6?


      Many thanks in advance,
      Manuel