@ViewConversationScoped context


The standard context for the @ConversationScoped annotation in JSR-299 has the same lifespan like the @RequestScoped - it's a 'transient conversation'. This is until you start the conversation with conversation.begin(); or conversation.begin("yourowncid");. In this case the conversation will become longrunning and last until you either end() it or a few other criterias defined in the JSR-299 spec are met.

This means that a longrunning conversation can only be started after an action got invoked. But all page request to the view which happen before the action invocation will lead to creating the bean for each and every request over and over again. Imagine a failed validation on the page before the create() action on your backing bean can get invoked.

Lifespan of a @ViewConversationScoped bean

Contrary to the the standard @ConversationScoped bean, the @ViewConversationScoped bean will have the @ViewScoped as base. This means the contextual instance will get created on the very first view impression and will be available on subsequent view invocations according to the rules of the standard @ViewScoped. The action has the possibility to get a ViewConversation object injected and start the conversation with begin() as known from the standard JSF-299 Conversation handling.

The contextual instance will get destroyed at the end of the request in which the conversation ends. Please note that this is different to the JSF @ViewScoped context which ends at the time you redirect/forward to another view, which is usually in the middle of a request!

Extensions/CDI/DevDoc/Drafts/ViewConversationScoped (last edited 2010-02-01 09:27:12 by 128)