[jboss-user] [JBoss Seam] - @In(create = true) @Out works fine in 1.1.5.GA and not in 1.

msystems do-not-reply at jboss.com
Fri Mar 2 10:51:43 EST 2007


  | @Stateful
  | @Name("accountBean")
  | public class AccountBean implements AccountLocal {
  |     @PersistenceContext
  |     private EntityManager em;
  | 
  |     @In(create = true) @Out
  |     private User userDomain;
  | 
  |     @In(required = false)
  |     private Locale localeDomain;
  | 
  |     @Out(required = false)
  |     private Account accountDomain;
  | 
  |     @Begin
  |     public String begin() {
  |         return "accountCreateAgreement";
  |     }
  |     
  |     public String acceptDisclaimer() {
  |         userDomain.setDisclaimerAcceptDate(new Date());
  | 
  |         return "accountCreateForm";
  |     }
  | 
  |     public String validatePageRequest() {
  |         if ((userDomain != null) && (userDomain.isDisclaimerAccepted())) {
  |             return null;
  |         } else {
  |             return cancel();
  |         }
  |     }
  |     
  |     @End
  |     public String create() {
  |         if (!userDomain.isDisclaimerAccepted()) {
  |             return cancel();
  |         }
  |         
  |         try {
  |             em.createNamedQuery("user.findByUsername")
  |                     .setParameter("username", userDomain.getUsername())
  |                     .getSingleResult();
  | 
  |             // User exists
  |             FacesMessages.instance().addFromResourceBundle("username", FacesMessage.SEVERITY_ERROR, "usernameExists");
  |             return null;
  |         } catch (NoResultException e) { // Ignore
  |         } catch (NonUniqueResultException e) { } // Ignore - can never occur
  | 
  |         User user = UserType.MEMBER.getUserWithDependencies(this.userDomain);
  |         user.getUserSettings().setLocale(localeDomain);
  | 
  |         GregorianCalendar validToDate = new GregorianCalendar(localeDomain.getJavaLocale());
  |         validToDate.setTimeZone(TimeZone.getTimeZone(localeDomain.getTimeZone()));
  |         validToDate.set(GregorianCalendar.AM_PM, GregorianCalendar.AM);
  |         validToDate.set(GregorianCalendar.HOUR, 0);
  |         validToDate.set(GregorianCalendar.HOUR_OF_DAY, 0);
  |         validToDate.set(GregorianCalendar.MINUTE, 0);
  |         validToDate.set(GregorianCalendar.SECOND, 0);
  |         validToDate.set(GregorianCalendar.MILLISECOND, 0);
  |         validToDate.add(GregorianCalendar.DAY_OF_MONTH, 31);
  | 
  |         accountDomain = user.getAccount();
  |         accountDomain.setValidTo(validToDate.getTime());
  | 
  |         em.persist(user);
  | 
  |         // Encode password
  |         Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
  |         user.setPassword(passwordEncoder.encodePassword(user.getPassword(), user.getId()));
  | 
  |         return "accountCreateWelcome";
  |     }
  | 
  |     @End
  |     public String cancel() {
  |         return "accountCreateCancel";
  |     }
  | 
  |     @Remove @Destroy
  |     public void destroy() {
  |     }
  | }
  | 

1.1.5.GA
Seam creates one instance of userDomain and for each method call
Seam injects the same instance of userDomain.

1.2.0.PATCH1
For each method call Seam creates a new instance of userDomain.

Can anybody here tell me what's going on?

Thanks,
/Kenneth


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

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



More information about the jboss-user mailing list