This content has been marked as final.
Show 3 replies
-
1. Re: RequestParameter question
gavin.king Feb 16, 2006 8:44 AM (in response to jameswoodward)The problem is that you are using an @Create method of a SESSION scope component - which is called only the first time the component is needed.
Instead, use getCompany() and getUser() methods, or use an @Create method of an EVENT scoped component. -
2. Re: RequestParameter question
liudan2005 Feb 16, 2006 8:44 AM (in response to jameswoodward)Use @Factory for your method
-
3. Re: RequestParameter question
jameswoodward Feb 23, 2006 9:27 AM (in response to jameswoodward)Thanks for that, here is my working version!
@Stateful @Name("mySession") @Scope(ScopeType.SESSION) @Interceptors(SeamInterceptor.class) @Cache(NoPassivationCache.class) public class MySessionBean implements Serializable, MySession { @PersistenceContext private EntityManager entityManager; @RequestParameter("CompanyID") private String paramCompanyId; @RequestParameter("UserID") private String paramUserId; private Company company; private User user; @Out @Factory("company") public Company getCompany() { if (paramCompanyId != null) { company = entityManager.find(Company.class, new Integer(paramCompanyId)); } return company; } @Out @Factory("user") public User getUser() { if (paramUserId != null) { user = entityManager.find(User.class, new Integer(paramUserId)); } return user; } @Create public void init() { System.out.println("MySessionBean.init()"); } @Destroy @Remove public void destroy() { System.out.println("MySessionBean.destroy()"); } }
Which I can access from the view using:<af:outputText value="#{company.name}"/>