4 Replies Latest reply on Mar 21, 2007 3:19 PM by mdarr

    Problem Ending a Task

    mdarr

      Ok so i have followed along with the dvd-seam example.

      However I am apparently doing something wrong here.

      I start the task ... i can see it in the debug.seam page.

      But when i go to end it. Nothing happens.

      Task as defined in the xml ->

      <task-node name="working" end-tasks="true">
       <task name="taskWorking" description="Tasks being worked on">
       <assignment pooled-actors="ticket-worker"/>
       </task>
      
       <transition name="next" to="finished"/>
       </task-node>
      



      The code on the task list where you start the task ->
       <s:button action="#{ticketWorking.viewTask}" taskInstance="#{task}"
       value="Set Task to Working"/>
      


      The Class ->
      @Stateful
      @Name("ticketWorking")
      public class TicketWorkingAction implements TicketWorking {
      
       @Logger
       Log log;
      
       @PersistenceContext(type=PersistenceContextType.EXTENDED)
       EntityManager em;
      
       @Out(required=false, scope=ScopeType.CONVERSATION)
       Ticket ticket;
      
       @In(required=false)
       Long ticketId;
      
       @In(required = false)
       String name;
      
       @In(required = false)
       String description;
      
       @In
       User authUser;
      
       @StartTask
       //@BeginTask -- i tried either or
       public String viewTask() {
       log.info("ticket working - view task - #{ticketId}");
       ticket = (Ticket) em.find(Ticket.class, ticketId);
       log.info("ticket found - #{ticket}");
       return "/ticket_work.xhtml";
       }
      
       @EndTask(transition="next")
       public String save() {
       log.info("ticket working - save");
       saveChange();
      
       return "/ticket_list.xhtml";
       }
      
       @EndTask//(transition="next")
       public String finished() {
       log.info("ticket working - finished");
       saveChange();
      
       return "/ticket_list.xhtml";
       }
      
       private void saveChange() {
       // TODO change the owner?
      
       TicketChange tChange = new TicketChange();
       tChange.setDescription(description);
       tChange.setUser(authUser);
       em.persist(tChange);
       }
      
       @Remove
       @Destroy
       public void destroy() {
      
       }
      }
      


      The JSF page ->
      <f:view>
       <h:form>
       Description - <h:inputText value="#{description}"/><br/>
      
       <h:commandButton value="Save" action="#{ticketWorking.save}"/><br/>
       <h:commandButton value="Save and Send to Approval" action="#{ticketWorking.finished}"/><br/>
      
       <p>
       <s:link value="View Tickets" action="/ticket_list.xhtml"/><br/>
       </p>
       </h:form>
      </f:view>
      



      .... i am hoping its just something stupid. But any ideas could help

      Btw i have the two methods because I was trying both ways.

      FWIW Ticket is an Entity Bean.



        • 1. Re: Problem Ending a Task
          pmuir

           

          @EndTask(transition="next")
           public String save() {
           log.info("ticket working - save");
           saveChange();
          
           return "/ticket_list.xhtml";
           }


          This is right. Have you checked that the method is being called, and completing without exception?

          • 2. Re: Problem Ending a Task
            mdarr


            I should have been more specific that's the problem its NOT calling it for some reason.

            IF i comment out the the @EndTask ... it will call the method just fine. Of course then it will not end the task if i do. So i know it is not a problem of finding hte bean. But for some reason put that @EndTask in front .... and it doesnt work.

            • 3. Re: Problem Ending a Task
              mgombocz

              Just guessing:

              Could it be because of attribute "end-task" in

              <task-node name="working" end-tasks="true">

              ?

              According to jBPM docs this is ending tasks automatically. Just try to omit "end-tasks" attribute.

              • 4. Re: Problem Ending a Task
                mdarr


                I tried omiting end-tasks and changing end-tasks to false and it still did not work.

                I did some more debugging and have an idea on the problem.

                Basically there is no task available and thats why it never executes the method.

                So i am assuming the long running conversation is no more. But i am not sure why that would be.