Is there a way to store some bean inside the conversation context? I.e for each new conversation, a new separate bean is created belonging to it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way to do what you want is to declare a ConversationScoped managed bean or EJB where JSF2 manages the scope.
There are some good explanations here:
… any of which will do a better job than I will. The very short version is that you annotate a bean – which can be a plain POJO that follows the bean conventions – with the
@ConversationScopedannotation. You then@InjectaConversationobject, which you can use tobegin()andend()conversations. Inject this@ConversationScopedbean into other things. TheConversation.beginandConversation.endmethods control its lifecycle.There’s a bit much code to just post here, but the above links should help.
An alternative to
@ConversationScopedPOJO managed beans can be@Stateful @ConversationScopedEJBs. They can be really handy when you need EJB services in a conversation.For some of the conceptual background and detail read the CDI/Weld reference on scopes – and the rest of the CDI/Weld manual. It’s really well written and really good.