[jboss-user] [JBoss Seam] - Instances get lost - strange behavior in conversational comp

maku01 do-not-reply at jboss.com
Thu Aug 30 01:41:00 EDT 2007


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079421#4079421

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079421



More information about the jboss-user mailing list