dev@javaserverfaces.java.net

Re: issue 1826

From: Ed Burns <ed.burns_at_sun.com>
Date: Mon, 11 Oct 2010 08:09:23 -0700

Forwarding to dev_at_javaserverfaces.

>>>>> On Sat, 9 Oct 2010 23:37:07 -0700, Sheetal Vartak <sheetal.vartak_at_oracle.com> said:

SV> Hi Ed/Roger, 1826 is regarding the Acid test (4 tests) that Richard
SV> Kennard wrote. Our RI passes 3. The one that's failing produces a
SV> stack trace as follows :

SV> [#|2010-10-07T14:26:11.910-0700|WARNING|glassfish3.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=81;_ThreadName=http-thread-pool-8080(1);|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
SV> java.lang.ClassCastException: com.sun.faces.application.view.StateHolderSaver cannot be cast to [Ljava.lang.Object;
SV> at javax.faces.component.UIOutput.restoreState(UIOutput.java:255)
SV> at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:253)
SV> at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
SV> at javax.faces.component.UIComponent.visitTree(UIComponent.java:1575)
SV> at javax.faces.component.UIComponent.visitTree(UIComponent.java:1586)
SV> at javax.faces.component.UIComponent.visitTree(UIComponent.java:1586)
SV> at javax.faces.component.UIForm.visitTree(UIForm.java:344)
SV> at javax.faces.component.UIComponent.visitTree(UIComponent.java:1586)
SV> at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:245)
SV> at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:181)
SV> at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
SV> at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:454)
SV> at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:160)
SV> at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:197)
SV> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
SV> at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:115)
SV> at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
SV> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:338)

SV> Now in the case where a component is dynamically added (subscribed
SV> to PreRenderViewEvent), things work just fine. Ed, your devtest that
SV> you added for 1757 does a dynamic add. Hence you have'nt seen this
SV> exception. It can be reproduced with Richard's acid test. He is
SV> removing a component from getChildren() and adding it
SV> back. Basically trying to toggle the order of the children in a
SV> form:

SV> UIComponent component = getChildren().remove( 0 );
SV> getChildren().add( component );

SV> What's happening is that the stateObj in this case for the UIOutput
SV> component is an instance of
SV> com.sun.faces.application.view.StateHolderSaver and there is no code
SV> to handle this situation during restoreState(). There is a check to
SV> see if the stateObj is an instance of
SV> javax.faces.component.StateHolderSaver, but there is no relation
SV> between the 2 except for the fact that the classes have identical
SV> code in them. Why is javax.faces.component.StateHolderSaver not a
SV> public class and why do we have another class
SV> (com.sun.faces.application.view.StateHolderSaver) doing the same
SV> thing ?

SV> I see that code was introduced in
SV> StateManagementStrategyImpl.saveComponentState() as follows :

SV> if (stateContext.componentAddedDynamically(c)) {
SV> stateObj = new StateHolderSaver(ctx, c); //This is com.sun.faces.application.view.StateHolderSaver
SV> // ensure it's in the addList.
SV> Map<String, ComponentStruct> dynamicAdds = stateContext.getDynamicAdds();
SV> assert(null != dynamicAdds);
SV> String clientId = c.getClientId(ctx);
SV> if (!dynamicAdds.containsKey(clientId)) {
SV> ComponentStruct toAdd = new ComponentStruct();
SV> toAdd.absorbComponent(ctx, c);
SV> dynamicAdds.put(clientId, toAdd);
SV> }
SV> } else {... }

SV> But there is no code to restore state if the stateObj is of type
SV> com.sun.faces.application.view.StateHolderSaver.

SV> Any clues/comments?

-- 
| ed.burns_at_sun.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/