3 Replies Latest reply on Sep 19, 2010 2:22 PM by lvdberg

    Mantaining the string value from task to task

    vanz

      I've got a process with three tasks and I'm not able to associate to it an ID string.
      Inside the file todoDoc.java I defined it in the field description but its value is not mantained and disappears when I switch from the first task to the following one.


      I want that the value, that I input at the beginning of the process, will be mantained till the end of it.
      Since I have different processes I want the value of the ID string to be different for every process.


      Right now when I switch from the first task to the second one when I display the string the result is alwasy #{todoDoc.description}.
      Where am I mistaking?


      documentoList.xhtml


      <ui:define name="body">
              <rich:panel>
                  <f:facet name="header">Crea nuovo task</f:facet>
                  <h:form id="description">
                      <div>Description:<h:inputText id="description" value="#{todoDoc.description}"
                          style="width: 400" /> 
                          
                          <h:commandButton value="Ciclo 3 step (RVA)" action="#{todoDoc.createTodo}" />
                          <h:commandButton value="Ciclo 2 step (RA)" action="#{todoDoc2.createTodo2}" />
                      </div>
                  </h:form>
      
              </rich:panel>
      
              <br />
              <br />
      
              <rich:panel>
                  <f:facet name="header">Lista dei task propri</f:facet>
                  <div id="list"><h:form id="list">
                      <div><h:outputText value="Nessun task presente."
                          rendered="#{empty taskInstancePriorityList}" /> <h:dataTable
                          value="#{taskInstancePriorityList}" var="task"
                          rendered="#{not empty taskInstancePriorityList}">
                          
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Description task" />
                              </f:facet>
                              
                              <h:inputText value="#{task.description}" style="width: 400" />
                          </h:column>
      
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Fase" />
                              </f:facet>
                              <h:inputText value="#{task.name}" style="width: 400" />
                          </h:column>
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Created" />
                              </f:facet>
                              <h:outputText
                                  value="#{task.taskMgmtInstance.processInstance.start}">
                                  <s:convertDateTime type="date" />
                              </h:outputText>
                          </h:column>
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Priority" />
                              </f:facet>
                              <h:inputText value="#{task.priority}" style=" width : 99px;" />
                          </h:column>
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Due Date" />
                              </f:facet>
                              <h:inputText value="#{task.dueDate}" style="width: 100">
                                  <s:convertDateTime type="date" dateStyle="short" />
                              </h:inputText>
                          </h:column>
      
      
      
                          <h:column>
                              <s:button action="#{todoDoc.conferma}" taskInstance="#{task}"
                                  value="Documento Accettato" />
                          </h:column>
                          <h:column>
                              <s:button action="#{todoDoc.rifiuta}" taskInstance="#{task}"
                                  value="Documento Rifiutato" />
                          </h:column>
                      </h:dataTable></div>
      
                      <div><h:commandButton value="Update Items"
                          rendered="#{not empty taskInstanceList}" /></div>
                  </h:form></div>
              </rich:panel>
      
              <br />
              <br />
      
              <rich:panel>
                  <f:facet name="header">Lista dei task divisi per gruppo</f:facet>
                  <div id="list"><h:form id="list2">
                      <div><h:outputText value="Nessun task presente."
                          rendered="#{empty pooledTaskInstanceList}" /> 
                          
                          <h:dataTable
                              value="#{pooledTaskInstanceList}" var="task"
                              rendered="#{not empty pooledTaskInstanceList}">
                              
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Description task" />
                              </f:facet>
                              
                              <h:inputText value="#{task.description}" style="width: 400" />
                          </h:column>
      
                          
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Fase" />
                              </f:facet>
                              <h:inputText value="#{task.name}" style="width: 400" />
                          </h:column>
                          <h:column>
                              <s:button action="#{pooledTask.assignToCurrentActor}" value="Assegna" taskInstance="#{task}" />
                          </h:column>
                      </h:dataTable></div>
                  </h:form></div>
              </rich:panel>
      
      
          </ui:define>
      
      </ui:composition>



      todoDoc.java




      package org.domain.docmanager.session;
      
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.bpm.CreateProcess;
      import org.jboss.seam.annotations.bpm.EndTask;
      import org.jboss.seam.annotations.bpm.StartTask;
      
      @Name("todoDoc")
      public class TodoDoc {
          
          private String description;
      
          public String getDescription()
          {
              return description;
          }
      
          public void setDescription(String description) {
              this.description = description;
          }
      
          @CreateProcess(definition="todo")
          public void createTodo() {
          }
          
          @StartTask @EndTask
          public void conferma() {}
          
          @StartTask @EndTask(transition="rifiuta")
          public void rifiuta() {
          }
      }
      


      todo.jpdl.xml




      <process-definition name="todo" xmlns="urn:jbpm.org:jpdl-3.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd">
      
          <start-state name="start">
              <transition to="Redazione">    
              </transition>
          </start-state>
      
          <task-node name="Redazione">
              <task name="redazione" description="#{todoDoc.description}">
                  <assignment actor-id="#{actor.id}" />
              </task>
              <transition to="Verifica"></transition>
          </task-node>
      
          <task-node name="Verifica">
              <task name="verifica" description="#{todoDoc.description}">
                  <assignment pooled-actors="verificatore"/>
              </task>
              <transition to="Approvazione"></transition>
              <transition to="Redazione" name="rifiuta"></transition>
          </task-node>
      
          <task-node name="Approvazione">
              <task name="approvazione" description="#{todoDoc.description}">
                  <assignment pooled-actors="approvatore"/>
              </task>
              <transition to="done"></transition>
              <transition to="Redazione" name="rifiuta"></transition>
          </task-node>
      
          <end-state name="done" />
      
      </process-definition>
      




        • 1. Re: Mantaining the string value from task to task
          lvdberg

          Hi,


          I see what you're trying to do, but I think you should reconsider your design a bit.
          The ToDo doc is the entity which must be passed from task to task. Seam uses the concept of the Business process scope to save these kind of vars. The system has this Super scope because a business process can be accessed by various users and it must survive system shut-downs. So every important business object must be stored somewhere (normally in the DB). The description of a task is NOT the right place to store business vars, the description attribute on the task element is used to define a textual detail description what the task is used for.


          What you must do is outject the TodDo doc into the BusinessProcess you do this as follows:



          @Out(scope=ScopeType.BUSINESS_PROCESS)
          String description
          


          Seam will take care of storing the description as a var into the jBPM-storage. When you need this var, you can simply do the opposite and use the @In. 


          IMPORTANT: Depending on the things you're going to do, you must set required false/true on In and OUT otherwise  you can get NPE errors.


          Leo


          P.S. download the free Seam in action chapter from manning.com. It explains very good how to use jBPM in combination with Seam.







          • 2. Re: Mantaining the string value from task to task
            vanz

            Hi,
            I think I understood what you told me to do and I tried doing it.
            Using @Out I saved the value of the var and with @in I recall it.
            I tried putting @out and @in in the todoDoc but doing it nothing changes and I still have the problem. I'm not able to understand how to recall the value in the right way.


            Can you give me an example on how to do it (in particular regarding @in and @out in the java class and how to display the value in the xhtml page). I don't need all the code but just a couple of lines to understand how to make it work.


            Thank you.


            • 3. Re: Mantaining the string value from task to task
              lvdberg

              Hi,


              I insist that you use the Seam in Action free download as a guide for further development, because you really needs some basic understanding of how jBPM works (in combination with Seam).


              I've put my previous example in the bean, but the way you're handling the the task is incorrect. Your tasknodes should call the defined actions and you're not doing that in your page.




              import org.jboss.seam.annotations.Name;
              import org.jboss.seam.annotations.bpm.CreateProcess;
              import org.jboss.seam.annotations.bpm.EndTask;
              import org.jboss.seam.annotations.bpm.StartTask;
              
              @Name("todoDoc")
              public class TodoDoc {
                  
                  @Out(scope=ScopeType.BUSINESS_PROCESS, required=false)
                  @In (required=false)
                  String docDescription
              
              
                  private String description
              
                  public String getDescription()
                  {
                      return description;
                  }
              
                  public void setDescription(String description) {
                      this.description = description;
                  }
              
                  @CreateProcess(definition="todo")
                  public void createTodo() {
                    /// Here you're saving it in the BusinessContext --> DB
                    docDescription = description; 
                  }
                  
                  @StartTask @EndTask
                  public void conferma() {
                  if (docDescription != null) {
                    // Now do something with the description
                   }
              }
              
              
                  
                  @StartTask @EndTask(transition="rifiuta")
                  public void rifiuta() {
                  }