0 Replies Latest reply on Feb 13, 2007 8:04 PM by heitmanm

    Seam JBPM Variable Instance and taskInstanceListForType

    heitmanm

      Hi, I'm manipulated the DVD-Sample a lot and have the problem that when I return to the admin-area from a page that begins and finishes a task.
      The #{task.variables['creditId'] is now 0 and musst be 1 in the admin.xhtml....the firsttime before the first task is executed the variable is shon correctly. When the process is created the credit has business-scope and is also visible in the jbpm-database-table under jbpm_variableinstance.....

      ordermanagement3.jpdl.xml

      <?xml version="1.0"?>
      
      <process-definition name="OrderManagement">
      
       <start-state name="start">
       <transition to="docChecking"/>
       </start-state>
      
       <task-node name="docChecking" end-tasks="true">
       <task name="docChecking" description="Dokumente prüfen">
       <assignment pooled-actors="#{shipperAssignment.pooledActors}"/>
       </task>
       <transition name="cancel" to="cancelled"/>
       <transition name="approve" to="creditDecision"/>
       </task-node>
      
       <task-node name="creditDecision" end-tasks="true">
       <task name="creditDecision" description="Kreditentscheidung">
       <assignment pooled-actors="#{shipperAssignment.pooledActors}" />
       </task>
       <transition name="approvedCredit" to="shipping"/>
       <transition name="cancel" to="cancelled"/>
       </task-node>
      
       <task-node name="shipping" description="Vertrag versenden" end-tasks="true">
       <task name="shipping" description="Vertragsversand">
       <assignment actor-id="#{actor.id}" pooled-actors="#{shipperAssignment.pooledActors}" />
       </task>
       <transition name="cancel" to="cancelled"/>
       <transition name="shipped" to="timeLimitChecking"/>
       </task-node>
      
       <task-node name="timeLimitChecking" description="Frist pruefen" end-tasks="true">
       <task name="timeLimitChecking" description="Fristpruefung">
       <assignment actor-id="#{actor.id}" pooled-actors="#{shipperAssignment.pooledActors}" />
       </task>
       <transition name="cancel" to="cancelled"/>
       <transition name="approvedTimeLimit" to="account"/>
       </task-node>
      
       <task-node name="account" description="Gutschrift ausloesen" end-tasks="true">
       <task name="account" description="Ueberweisung">
       <assignment actor-id="#{actor.id}" pooled-actors="#{shipperAssignment.pooledActors}" />
       </task>
       <transition name="cancel" to="cancelled"/>
       <transition name="sendedMoney" to="complete"/>
       </task-node>
      
      
       <end-state name="complete"/>
       <end-state name="cancelled"/>
      
      
      </process-definition>
      
      


      docchecking.xhtml
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:s="http://jboss.com/products/seam/taglib">
      <body>
       <ui:composition template="/WEB-INF/template.xhtml">
       <ui:define name="topnav">
       <ui:include src="/WEB-INF/incl/admin_nav.xhtml" />
       </ui:define>
      
       <ui:define name="sidebar">
       <ui:include src="/WEB-INF/incl/login.xhtml" />
       </ui:define>
      
       <ui:define name="body">
       <h1>Dokumente prfen</h1>
      
       <p>Bitte überprüfen Sie Daten und fällen Sie eine Entscheidung</p>
       <p>Dokumente</p>
       <table width="410" height="60">
       <tr>
       <td>Dokument<br /></td><td>Vertrag.xls</td><td><input type="button" value="anzeigen" name="button3" /></td>
       </tr>
       <tr>
       <td>Dokument<br /></td><td>Präse.ppt</td><td><input type="button" value="anzeigen" name="button3" /></td>
       </tr>
       </table>
      
       <p>Kundendaten</p>
       <table bgcolor="#c0c0c0">
       <tr>
       <td>
       <h:outputText value="Kundennr: " /><h:outputText value="#{credit.customer.id}" />
       </td>
       <td>
       <h:outputText value="Name: " /><h:outputText value="#{credit.customer.lastname}" /> <h:outputText value="#{credit.customer.lastname}" />
       <br /></td>
       </tr>
      
      
       </table>
      
      
       <p>Kreditinformationen</p>
       <table bgcolor="#c0c0c0" border="0.5">
       <tr>
       <td>
       ¦<h:outputText value="CreditId: "></h:outputText>
       </td>
       <td>
       <h:outputText value="#{credit.id}"></h:outputText>
       </td>
       </tr>
       <tr>
       <td>
       <h:outputText value="Automodell: " />
       </td>
       <td>
       <h:outputText value="#{credit.car}" />
       </td>
       </tr>
       <tr>
       <td>
       <h:outputText value="Preis " />
       </td>
       <td>
       <h:outputText value="#{credit.price}" />
       </td>
       </tr>
       <tr>
       <td>
       <h:outputText value="Anzahlung: " />
       </td>
       <td>
       <h:outputText value="#{credit.downPayment}" />
       </td>
       </tr>
       <tr>
       <td>
       <h:outputText value="Laufzeit: " />
       </td>
       <td>
       <h:outputText value="#{credit.term}" />
       </td>
       </tr>
       <tr>
       <td>
       <h:outputText value="Rate monatlich: " />
       </td>
       <td>
       <h:outputText value="#{createCreditRequest.calculation}">
       <f:convertNumber maxFractionDigits="2"
       groupingUsed="true"
       currencySymbol="Euro"
       maxIntegerDigits="7"
       type="currency"/>
       </h:outputText>
       </td>
       </tr>
      
       </table>
      
      
       <p></p>
       <h:form>
      
       <h:commandLink action="#{accept.acceptDocuments}">
       <h:commandButton value="Antrag in Ordnung"/>
      
       </h:commandLink>
       <h:commandLink action="#{accept.reject}">
       <h:commandButton value="Antrag ablehnen"/>
       </h:commandLink>
       </h:form>
      
      
       </ui:define>
       </ui:composition>
      </body>
      </html>
      



      AcceptAction.java
      @Stateful
      @Name("accept")
      public class AcceptAction
       implements Accept,
       Serializable
      {
       @In(value="currentUser")
       Admin admin;
      
       @PersistenceContext(type=PersistenceContextType.EXTENDED)
       EntityManager em;
      
       @Out(scope=ScopeType.CONVERSATION)
       Credit credit;
      
       @In
       Long creditId;
      
      
       //------------------------------
      
       @BeginTask
       public String startDocChecking() {
       System.err.println("startDocChecking");
       credit = (Credit) em.createQuery("from Credit o where o.id = :creditId")
       .setParameter("creditId", creditId)
       .getSingleResult();
       return "docChecking";
       }
      
       @EndTask(transition="approve")
       public String acceptDocuments() {
       System.out.println("Answered");
       return "admin";
       }
      
       @EndTask(transition="cancel")
       public String reject() {
       System.out.println("rejected");
       return "admin";
       }
      
       //---------------------------------
      
       @BeginTask
       public String startCreditDecision() {
       System.err.println("startCreditDecision");
       credit = (Credit) em.createQuery("from Credit o where o.id = :creditId")
       .setParameter("creditId", creditId)
       .getSingleResult();
       return "creditDecision";
       }
      
       @EndTask(transition="approvedCredit")
       public String acceptCreditDecision() {
       System.out.println("approvedcredit");
       return "admin";
       }
      
       //----------------------------------
      
       @BeginTask
       public String startShipping() {
       System.err.println("startShipping");
       credit = (Credit) em.createQuery("from Credit o where o.id = :creditId")
       .setParameter("creditId", creditId)
       .getSingleResult();
       return "shipping";
       }
      
       @EndTask(transition="shipped")
       public String acceptShipping() {
       System.out.println("acceptShipping");
       return "admin";
       }
      
       //----------------------------------
      
       @BeginTask
       public String startTimeLimitChecking() {
       System.err.println("startTimeLimitChecking");
       credit = (Credit) em.createQuery("from Credit o where o.id = :creditId")
       .setParameter("creditId", creditId)
       .getSingleResult();
       return "timeLimitChecking";
       }
      
       @EndTask(transition="approvedTimeLimit")
       public String acceptTimeLimitChecking() {
       System.out.println("acceptShipping");
       return "admin";
       }
      
       //----------------------------------
      
       @BeginTask
       public String startAccount() {
       System.err.println("startAccount");
       credit = (Credit) em.createQuery("from Credit o where o.id = :creditId")
       .setParameter("creditId", creditId)
       .getSingleResult();
       return "account";
       }
      
       @EndTask(transition="sendedMoney")
       public String acceptAccount() {
       System.out.println("acceptShipping");
       return "admin";
       }
      
       @Destroy
       @Remove
       public void destroy() {}
      
      }
      


      admin.xhtml
      <<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:c="http://java.sun.com/jstl/core">
      <body>
       <ui:composition template="/WEB-INF/template.xhtml">
       <ui:define name="topnav">
       <ui:include src="/WEB-INF/incl/admin_nav.xhtml" />
       ui:define>
      
       <ui:define name="sidebar">
       <ui:include src="/WEB-INF/incl/login.xhtml" />
       </ui:define>
      
       <ui:define name="body">
       <f:subview rendered="#{!login.admin}">
       The admin screen is only administrative users. Please
       login to continue. If you are looking for the store,
       try <s:link view="/browse.xhtml" value="here" />.
       </f:subview>
      
       <f:subview rendered="#{login.admin}">
       <h1>Kredit Management</h1>
      
       <p>Hier läuft die Bearbeitung eines Kreditantrags ab. Diese Ansicht wird nur einem Benutzer mit entsprechenden Rechten angezeigt.<br /></p><h2>Aufgaben - unzugewiesen</h2>
       <div class="rvgActions">
       </div>
       <c:choose>
       <c:when test="#{empty pooledTaskInstanceList}">
       <p>Keine unzugewiesenen Aufgaben vorhanden<br /></p>
       </c:when>
       <c:otherwise>
       <h:dataTable value="#{pooledTaskInstanceList}"
       var="task"
       styleClass="table"
       headerClass="tablehead"
       rowClasses="tableodd,dvdtableeven"
       columnClasses="tablecol">
       <h:column>
      
       </h:column>
       <h:column>
       <f:facet name="header">Taskbeschreibung</f:facet>
       <h:outputText value="#{task.description}" />
       </h:column>
      
       <h:column>
       <s:link action="#{pooledTask.assignToCurrentActor}" taskInstance="#{task}"
       value="zuweisen"/>
       </h:column>
       </h:dataTable>
       </c:otherwise>
       </c:choose>
      
       <h2>Dokumenteprüfen</h2>
       <c:choose>
       <c:when test="#{empty taskInstanceListForType['docChecking']}">
       <p>Keine Dokumente zu prüfen.<br /></p>
       </c:when>
       <c:otherwise>
       <h:dataTable value="#{taskInstanceListForType['docChecking']}"
       var="task"
       styleClass="dvdtable"
       headerClass="dvdtablehead"
       rowClasses="dvdtableodd,dvdtableeven"
       columnClasses="dvdtablecol">
       <h:column>
       <f:facet name="header">Kreditnr</f:facet> #{task.variables['creditId']}
       </h:column>
       <h:column>
       <f:facet name="header">Taskbeschreibung</f:facet>
       #{task.description}
       </h:column>
      
       <h:column>
      
       <h:commandLink action="#{accept.startDocChecking}">
       <h:commandButton value="start"/>
       <f:param name="taskId" value="#{task.id}"/>
       </h:commandLink>
      
       </h:column>
      
       </h:dataTable>
       </c:otherwise>
       </c:choose>
      
       <h2>Kreditenscheidung</h2>
       <c:choose>
       <c:when test="#{empty taskInstanceListForType['creditDecision']}">
       <p>Keine Anträge zu prüfen.<br /></p>
       </c:when>
       <c:otherwise>
       <h:dataTable value="#{taskInstanceListForType['creditDecision']}"
       var="task"
       styleClass="dvdtable"
       headerClass="dvdtablehead"
       rowClasses="dvdtableodd,dvdtableeven"
       columnClasses="dvdtablecol">
       <h:column>
       <f:facet name="header">Kreditnr</f:facet> #{task.variables['creditId']}
       </h:column>
       <h:column>
       <f:facet name="header">Taskbeschreibung</f:facet>
       #{task.description}
       </h:column>
      
       <h:column>
      
       <h:commandLink action="#{accept.startCreditDecision}">
       <h:commandButton value="start"/>
       <f:param name="taskId" value="#{task.id}"/>
       </h:commandLink>
      
       </h:column>
      
       </h:dataTable>
       </c:otherwise>
       </c:choose>
      
       <h2>Versand</h2>
       <c:choose>
       <c:when test="#{empty taskInstanceListForType['shipping']}">
       <p>Keine Vertrge zu versenden.<br /></p>
       </c:when>
       <c:otherwise>
       <h:dataTable value="#{taskInstanceListForType['shipping']}"
       var="task"
       styleClass="dvdtable"
       headerClass="dvdtablehead"
       rowClasses="dvdtableodd,dvdtableeven"
       columnClasses="dvdtablecol">
       <h:column>
       <f:facet name="header">Kreditnr</f:facet> #{task.variables['creditId']}
       </h:column>
       <h:column>
       <f:facet name="header">Taskbeschreibung</f:facet>
       #{task.description}
       </h:column>
      
       <h:column>
      
       <h:commandLink action="#{accept.startShipping}">
       <h:commandButton value="start"/>
       <f:param name="taskId" value="#{task.id}"/>
       </h:commandLink>
      
       </h:column>
      
       </h:dataTable>
       </c:otherwise>
       </c:choose>
      
       <h2>Fristen</h2>
       <c:choose>
       <c:when test="#{empty taskInstanceListForType['timeLimitChecking']}">
       <p>Keine Vertrge zu eingegangen.<br /></p>
       </c:when>
       <c:otherwise>
       <h:dataTable value="#{taskInstanceListForType['timeLimitChecking']}"
       var="task"
       styleClass="dvdtable"
       headerClass="dvdtablehead"
       rowClasses="dvdtableodd,dvdtableeven"
       columnClasses="dvdtablecol">
       <h:column>
       <f:facet name="header">Kreditnr</f:facet> #{task.variables['creditId']}
       </h:column>
       <h:column>
       <f:facet name="header">Taskbeschreibung</f:facet>
       #{task.description}
       </h:column>
      
       <h:column>
      
       <h:commandLink action="#{accept.startTimeLimitChecking}">
       <h:commandButton value="start"/>
       <f:param name="taskId" value="#{task.id}"/>
       </h:commandLink>
      
       </h:column>
      
       </h:dataTable>
       </c:otherwise>
       </c:choose>
      
       <h2>Ueberweisungen</h2>
       <c:choose>
       <c:when test="#{empty taskInstanceListForType['account']}">
       <p>Keine Ueberweisungen.<br /></p>
       </c:when>
       <c:otherwise>
       <h:dataTable value="#{taskInstanceListForType['account']}"
       var="task"
       styleClass="dvdtable"
       headerClass="dvdtablehead"
       rowClasses="dvdtableodd,dvdtableeven"
       columnClasses="dvdtablecol">
       <h:column>
       <f:facet name="header">Kreditnr</f:facet> #{task.variables['creditId']}
       </h:column>
       <h:column>
       <f:facet name="header">Taskbeschreibung</f:facet>
       #{task.description}
       </h:column>
      
       <h:column>
      
       <h:commandLink action="#{accept.startAccount}">
       <h:commandButton value="start"/>
       <f:param name="taskId" value="#{task.id}"/>
       </h:commandLink>
      
       </h:column>
      
       </h:dataTable>
       </c:otherwise>
       </c:choose>
      
       </f:subview>
       </ui:define>
       </ui:composition>
      </body>
      </html>