[jboss-user] [JBoss Seam] - Stafull session bewn - set new reference

kooudy do-not-reply at jboss.com
Thu Jul 26 02:44:02 EDT 2007


I have a question:

I have statefull bean:

@Stateful
  | @Scope(ScopeType.SESSION)
  | @Name("hotelSearch")
  | public class HotelSearch implements HotelSearchLocalIF {
  |   @DataModelSelection
  |   private Hotel hotel;
  | 
  |   @DataModel
  |   private List<Hotel> hotelList;
  | 
  |   /**
  |    * Set new hotel.
  |    */
  |   public void setHotel(Hotel hotel) {
  |     this.hotel = hotel;
  |   }
  | 
  |   private void logHotel() {
  |     log.debug(this.hotel);
  |   }
  | 
  | }

I call hotel.setHotel(newHotel) from another stateless bean to set new detail.

Then I call logHotel() but there is original hotel logged 
(which was in variable hotel before setting new one).
It looks like method setHote(hotel) sets new detail only for setHotel() method duration. But after this method ends, original hotel is injected.

When I want to change hotel, I have to change attributes of hotel, but not whole instance (reference):

  public void setHotel(Hotel hotel) {
  | //    this.hotel = hotel;  //not works, after methodends, there is original hotel injected
  | 
  |     //ne approach to update hotel detail
  |     this.hotel.setId(hotel.getId);
  |     this.hotel.setName(hotel.getName);
  |     ...
  |   }

Can I force HotelSearch to set new hotel reference for HotelSearch?

I have met this several times and I don't now the right solution.

I have tried the same with @In and behaviour is similar.

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

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



More information about the jboss-user mailing list