3 Replies Latest reply on Jan 9, 2008 9:05 PM by rainhust

    @EndTask do not work in method calls!!

    rainhust

      in a backing method call another method which annotated with @EndTask and the task do not end .

      if call the annotated method from backing method , it's work.

      for example:
      there is a seam component

      @Stateful
      @Name("chiefExamine")
      public class ChiefExamineAction implements ChiefExamine , Serializable {
      @EndTask(transition="need modify form")
       public String reject() {
       log.info("endTask: reject");
       // modify form
       return "admin";
       }
       @BeginTask
       public String viewTask() {
       loadBaoxiaoInfo();
       return "examine";
       }
       @EndTask(transition="to result")
       public String accept() {
       log.info("endTask: accept");
       return "admin";
       }
      
       @Transactional
       public String saveApprove() {
       this.approve.setBaoxiao(getBaoxiao());
       this.approve.setDate(new Date());
       this.approve.setUser(user);
      
       em.persist(this.approve);
       em.flush();
       // call the @EndTask method.
       if(approve.getResult().equals("agree")) {
       return this.accept();
       }else if(approve.getResult().equals("more info")) {
       return this.reject();
       } else return "admin";
       }
      


      in jsp pages:
      <h:commandButton action="#{chiefExamine.saveApprove}" value="Submit" />
      
       <h:commandButton action="#{chiefExamine.accept}" value="Accept Request" />
      


      if using #{chiefExamine.saveApprove}, then the task do not end.

      if using #{chiefExamine.accept}, then the task can end .

      but if i put the saveApprove method in accept method, like this:
      @EndTask(transition="to result")
       public String accept() {
       log.info("endTask: accept");
       saveApprove(); // call the save method from there will cause exception
       return "admin";
       }
      


      this will cause one exception. see there:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=127226

      so i want to know why the @EndTask do not work when call the annotated method from other backing method. or something i do wrong.