[
https://issues.jboss.org/browse/JBSEAM-4898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12667247#comment-12667247
]
John Gilbert commented on JBSEAM-4898:
--------------------------------------
We have figured out a potential solution. This is all related to how Jsf2
changed RestoreView. First it rebuilds the tree from scratch and then visits
the tree to restore the state. Since the state isn't restored it can't rebuild
the tree. Previously it just restored the tree from the state.
There are two pieces to the fix.
First we moved the restore of the conversation to beforeRestore. This is
similar to the logic in Weld.
* SeamPhaseListener
{code}
/**
* Set up the Seam contexts, except for the conversation
* context
*/
protected void beforeRestoreView(FacesContext facesContext)
{
FacesLifecycle.beginRequest( facesContext.getExternalContext() );
// this is the same place that WELD restores the conversation
Map parameters =
facesContext.getExternalContext().getRequestParameterMap();
ConversationPropagation.instance().restoreConversationId(parameters);
boolean conversationFound = Manager.instance().restoreConversation();
FacesLifecycle.resumeConversation( facesContext.getExternalContext() );
}
/**
* Restore the page and conversation contexts during a JSF request
*/
protected void afterRestoreView(FacesContext facesContext)
{
FacesLifecycle.resumePage();
Map parameters =
facesContext.getExternalContext().getRequestParameterMap();
// ConversationPropagation.instance().restoreConversationId(parameters);
boolean conversationFound = Manager.instance().restoreConversation();
// FacesLifecycle.resumeConversation( facesContext.getExternalContext() );
postRestorePage(facesContext, parameters, conversationFound);
}
{code}
Second, we made the PageContent lazily initialize. this is similar to how Seam
3 does the ViewScopedContext.
* Contexts
{code}
public static boolean isPageContextActive()
{
if (pageContext.get() == null) {
// lazy initialize the page context during restore view
// this is similar to the ViewScopedContext.isActive() in
Seam 3
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
UIViewRoot viewRoot = facesContext.getViewRoot();
if (viewRoot != null) {
pageContext.set( new PageContext() );
}
}
}
return pageContext.get() != null;
}
{code}
I will submit a patch next we after we wrap up our sprint to ensure there
aren't any additional changes.
> JSF2 Page Scope components are not active on postback
> -----------------------------------------------------
>
> Key: JBSEAM-4898
> URL: https://issues.jboss.org/browse/JBSEAM-4898
> Project: Seam 2
> Issue Type: Bug
> Affects Versions: 2.3.0.ALPHA
> Reporter: John Gilbert
> Attachments: seam-scope-test-master.zip
>
>
> Page scoped components are not active on postback during the restore view
> phase. We have been doing things like this in JSF 1.2 for years with no
> trouble.
> {code}
> <ui:include src="#{pageScopedComponent.viewId}" />
> {code}
> In JSF 2 the page will render, because the facelet isn't actually complied
> until the render phase on a GET. Then on postback the component is not found
> in the stateful page scope and then isn't created because the page scope is
> not active yet.
> I have made many attempts to debug this but I have run out of ideas. I'm
> thinking this is a bug so I am posting it here. But if someone can give me
> some fresh ideas on where to look, I will keep digging.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues