dev@javaserverfaces.java.net

Re: Facelets VDL.buildView drops programmatic component change

From: Martin Kočí <Martin.Koci_at_aura.cz>
Date: Mon, 16 Nov 2009 22:39:14 +0100

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1414

Ryan Lubke píše v Po 16. 11. 2009 v 12:45 -0800:
> On 11/16/09 1:12 PM, Martin Kočí wrote:
> > Hi,
> >
> > problem has nothing to do with navigation and surely relates to Facelets
> > state saving. Simple tests (code pasted below) outputs following
> > results:
> >
> > 1) JSP: switchs colums at every click with no problem
> >
> > 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual
> > switch as described in original mail
> >
> > 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true - switchs with
> > first click but next restore state ends withs
> > java.lang.ClassCastException:
> > com.sun.faces.application.view.StateHolderSaver cannot be cast to
> > [Ljava.lang.Object;
> >
> >
> > Common code from test.jspx and test.xhtml
> > ... jsp: or facelets stuff here ...
> > <h:form id="form">
> >
> > <h:commandButton value="Switch columns">
> > <f:actionListener binding="#{testBean}" />
> > </h:commandButton>
> >
> > <h:dataTable id="table">
> > <h:column>
> > <f:facet name="header">
> > <h:outputText value="firstName" />
> > </f:facet>
> > </h:column>
> > <h:column>
> > <f:facet name="header">
> > <h:outputText value="surname" />
> > </f:facet>
> > </h:column>
> > </h:dataTable>
> >
> > </h:form>
> >
> >
> > @ManagedBean
> > @RequestScoped
> > public class TestBean implements ActionListener {
> > public void processAction(ActionEvent event) throws
> > AbortProcessingException {
> > FacesContext context = FacesContext.getCurrentInstance();
> > UIComponent table = context.getViewRoot().findComponent("form:table");
> > UIComponent column1 = table.getChildren().get(0);
> > UIComponent column2 = table.getChildren().get(1);
> > table.getChildren().clear();
> > table.getChildren().add(column2);
> > table.getChildren().add(column1);
> > }
> >
> > }
> >
> I see. Please log an issue.
> > Ryan Lubke píše v Po 16. 11. 2009 v 08:24 -0800:
> >
> >> On 11/16/09 6:43 AM, Martin Kočí wrote:
> >>
> >>> Hi,
> >>>
> >>> i have a problem with Facelets2 (mojarra trunk) and component tree
> >>> manipulation:
> >>> in invoke application phase I switch two UIColumn in UIData (first
> >>> columns goes last atd.) and I expect that this change will survive save
> >>> state/restore state but it is not true. With some help of debugger it
> >>> seems that
> >>> com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FacesContext, UIViewRoot) reverts my component change back.
> >>>
> >>> The process is: first request -> RenderResponse calls VDL.buildView (ok)
> >>> -> postback request> Restore View -> Invoke Application (listener
> >>> performs component tree manipulation) -> RenderResponse calls
> >>> VDL.buildView -> FaceletViewHandlingStrategy.buildView(FacesContext,
> >>> UIViewRoot) rebuilds UIData from .xhtml and drops UIColumn's order
> >>> change.
> >>>
> >>> FaceletViewHandlingStrategy.buildView contain a intresting if as first
> >>> statement:
> >>>
> >>> if (Util.isViewPopulated(ctx, view)) {
> >>> return;
> >>> }
> >>>
> >>> Isn't for this case view already populated from Restore State phase?
> >>> Probably it is and if I add Util.setViewPopulated in
> >>> ViewHandlingStrategy.restoreView it fixes my problem.
> >>>
> >>>
> >> Is there a navigation rule involved here?
> >>
> >>> This problem is not present with JSP; with facelets only with partial
> >>> state saving=false.
> >>>
> >>>
> >>> Is it a bug?
> >>>
> >>>
> >>> Regards,
> >>>
> >>> Martin Kočí
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> >>> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
> >>>
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> >> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> > For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>
>