[webbeans-issues] [JBoss JIRA] Commented: (WBRI-258) The conversation needs to be restored in the restore view phase in JSF 2

Dan Allen (JIRA) jira-events at lists.jboss.org
Fri May 8 02:10:46 EDT 2009


    [ https://jira.jboss.org/jira/browse/WBRI-258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12466437#action_12466437 ] 

Dan Allen commented on WBRI-258:
--------------------------------

In JSF 2, UIData components are unfolded when the view is restored. This requires evaluating the value of the UIData component and stepping through each row. If the value resolves to a conversation-scoped component, since the conversation is not yet restored, Web Beans is going to throw an exception. Therefore, we need to restore the conversation before the view is restored (before the Restore View phase).

But how can we do that if the conversation token is stored in a UIViewRoot attribute? I have decided that using a UIViewRoot attribute is a fragile approach to propagating the conversation id across requests. A far more stable and portable approach is to add it as a request parameter to the query string of any URL that JSF uses. That opens the possibility for any mechanism (filter, phase listener, etc) to read this value on the next request and restore the conversation. It is no longer tied to JSF.

So how is this done? Fortunately, any URL that JSF builds is created using the getActionURL() method on ViewHandler. So it's simply a matter of providing a forwarding ViewHandler that overrides this one method and weaves in the conversation id. This covers all cases: form actions, link hrefs, Ajax calls, and redirect URLs.

There is really no reason why we have to wait until the view is restored to setup the conversation and obviously that is problematic in JSF 2. This new approach opens the door to the possibility that the conversation is setup, and thus available, in a filter. It also makes it easy to integration w/ other view technologies, such as wicket since the propagation mechanism is universal.

> The conversation needs to be restored in the restore view phase in JSF 2
> ------------------------------------------------------------------------
>
>                 Key: WBRI-258
>                 URL: https://jira.jboss.org/jira/browse/WBRI-258
>             Project: Web Beans
>          Issue Type: Bug
>    Affects Versions: 1.0.0.PREVIEW1
>            Reporter: Dan Allen
>             Fix For: 1.0.0.PREVIEW2
>
>
> JSF 2 walks the tree in the RestoreView phase, whereas JSF 1 does not. The timing causes a problem if you have a value expression bound to a conversation-scoped bean. The solution is to use a ComponentEventListener to restore the conversation rather than a phase listener. The listener should observe the PostRestoreStateEvent on UIViewRoot. Component listeners can be registered programmatically. WebBeans should detect which version of JSF is in use and act accordingly.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the weld-issues mailing list