6 Replies Latest reply on Apr 19, 2006 10:54 AM by Gavin King

    Long running conversations and entity managers, a bit confus

    Andrew Apprentice

      Okay, I am a bit confused how the EJB3 session beans + Seam + Seam managed entity managers work. I have looked at the examples, and none seem to do this.

      What I am doing:
      I am creating a registration site for a conference. The registration process is a wizard invovling 3-x number of steps. On the first step, I am creating a Registration object and adding it to my Conference object (collections mapped via one-to-many). The registration has several children objects called BreakoutSessionRegistration, and the Conference has several children of type BreakoutSession.

      On the beginRegistration:

      @Begin(join=true)
       @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
       public String beginRegistration()
       {
       this.registration = new Registration();
       this.registration.setConference(conference);
       this.conference.getRegistrations().add(registration);
       for (BreakoutSession bs : this.conference.getBreakoutSessions())
       {
       BreakoutSessionRegistration bsr = new BreakoutSessionRegistration();
       bsr.setRegistration(registration);
       bsr.setSession(bs);
       bsr.setNumberOfAttendees((short)0);
       bsr.getRegistration().getBreakoutRegistrations().add(bsr);
       bsr.getSession().getRegistrations().add(bsr);
       }
      
       return "beginRegistration";
       }
      


      So now, I want the user to continue to edit this registration object and breakout sessions over several pages of a wizard.

      I also want to have a cancel button:
       @End
       public String cancel()
       {
       // what to do here?
       return "canceled";
       }
      

      I don't want anything committed to the database until my save() method is called. I also want the cancel button to undo its changes. In this same "action" class, I have a list of all the registrations for the current user and a list of all the conferences. I get this list before I ever being a conversation.

      My beginRegistration method starts the conversation. The problem is that the conversation is dirty and therefore so is the list of my conversations. When the user cancels, I want to restore the "virgin" state of the conferences and registrations.

      Is this possible? I tried entityManager.refresh(Object) on the conference, but it did not like the fact that the registration was not in the database (null identifier error).

      I'm really having a hard time with getting a good grasp of how to use the extended persistence manager, long running conversations and the ability to cancel or save.

      Thanks in advance, I'm really at a loss.
      Andrew