myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Myfaces Wiki] Update of "ViewConversationScoped" by MarkStruberg
Date Mon, 01 Feb 2010 08:51:45 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The "ViewConversationScoped" page has been changed by MarkStruberg.


New page:
= @ViewConversationScoped context =

=== Introduction ===

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!

View raw message