3 Replies Latest reply on Jan 2, 2008 12:57 PM by marcelkolsteren

    Instances get lost - strange behavior in conversational comp

    maku01

      hi,

      I've a really strange problem with a Seam Component which scope is "CONVERSATION"

      I read a Entity List (roomList) with JPA in the case the member variable is null --> getRoomList().

      Then I want to hold the instance as long the component exists.

      When I operate on this component from the referencing view everything is o.k.

      But when I change to an other view strange things happen.

      When I return to the former view the Entity List (roomList) is not null but it is not the same as on creation.

      This List has than null entries (as much as the "original" list).
      The component instance is the same.

      @Name("roomMaint")
      @Scope(CONVERSATION)
      public class RoomMaint implements Serializable {
      
       private static final long serialVersionUID = 1L;
      
       private List<RoomEntity> roomList;
      
       private RoomEntity roomEntity;
      
       @In(at.hcare.service.base.ServiceNames.ROOM_SERVICE)
       private IRoomService roomService;
      
      
       @Logger
       protected Log log;
      
       @Create
       public void create() {
       log.debug("Create " + getClass().getName());
       }
      
       @Destroy
       @Remove
       public void destroy() {
       log.debug("destroy " + getClass().getName());
       }
      
       @Begin(join = true)
       public void start() {
       log.debug("start");
       }
      
       @Factory(scope = ScopeType.STATELESS)
       public List<RoomEntity> getRoomList() {
       if (roomList == null) {
       roomList = roomService.findAll();
       }
       return roomList;
       }
      
       @Factory(scope = ScopeType.STATELESS)
       public RoomEntity getCurrRoomEntity() {
       if (roomEntity == null) {
       creation();
       }
       return roomEntity;
       }
      
       public String save() {
       if (getCurrRoomEntity().isPersisted()) {
       roomService.update(getCurrRoomEntity());
       } else {
       roomService.persist(getCurrRoomEntity());
       }
       GenericFacesHelper.addSavedMessage("room");
       return NavigationOutcome.STAY_ON_SAME_PAGE;
       }
      
       public String remove() {
       return remove(getCurrRoomEntity());
       }
      
       public String remove(RoomEntity roomEntity) {
       if (roomEntity != null && roomEntity.isPersisted()) {
       roomService.remove(roomEntity);
       }
       return NavigationOutcome.STAY_ON_SAME_PAGE;
       }
      
       public void select(RoomEntity roomEntity) {
       this.roomEntity = roomEntity;
       }
      
       public String getDetailState() {
       return ExtendedResourceLoader.getText(isCurrNew() ? "new" : "edit");
       }
      
       public boolean isCurrNew() {
       return !getCurrRoomEntity().isPersisted();
       }
      
       public String creation() {
       roomEntity = roomService.createDefaultEntity();
       return NavigationOutcome.STAY_ON_SAME_PAGE;
       }
      }


      When I change the context to "SESSION" it works as expected.

      Could anybody give me a hint what is wrong?

      TIA
      Martin

        • 1. Re: Instances get lost - strange behavior in conversational
          thejavafreak

          1. Perhaps because the conversation has ended, or it has reached the maximum time-out
          2. Perhaps it's on a different conversation, make sure it has the same conversation id

          • 2. Re: Instances get lost - strange behavior in conversational
            maku01

             

            "thejavafreak" wrote:
            1. Perhaps because the conversation has ended, or it has reached the maximum time-out
            2. Perhaps it's on a different conversation, make sure it has the same conversation id

            Sorry, I don't understand this.
            The component instance is the same when I return to the view. Only the instance of the Entity List has changed.
            In my opinion, when the conversation has ended I would get a new instance of the component class (RoomMaint )

            The method when I come back is the start method
            @Begin(join = true)
            public void start() {
             log.debug("start");
            }
            

            BTW, I use Seam 2 Beta (Latest CVS Build)

            • 3. Re: Instances get lost - strange behavior in conversational
              marcelkolsteren

              I encountered the same problem in my J2EE application, which uses Seam 2.0.0.GA. It is caused by a bug in JBoss/Seam. See the JIRA issues JBSEAM-2214 and JBSEAM-2224. I got rid of the problem by installing the fix (EntityBeanList.java version 1.6).