chkal/pf-issue-test — Issue #10: Missing parameters + rendering errors
Author: chkal
Created: 2012-03-06 07:14:56+00:00
State: open

Originally filed by **David.Ab...@gmail.com** on 2009-04-22T05:48:16

Google Code issue: http://code.google.com/p/prettyfaces/issues/detail?id=7

Problem:

We do have in the JSF page:

They are identical, the first one is Link, the second one is Button.

We are using the latest pretty faces version, but it has no url-mapping for
now.

CommandLink version of code works just fine, but CommandButton is a
different story. First of all I checked parameters numbers and all
additional parameters mentioned inside commandButton are missing and
reported as NULL. By the way, bean was initialized and gone to rendering
stage. And we got in log:

[#|2009-04-22T08:34:57.758+0300|WARNING|sun-appserver9.1|org.apache.coyote.tomcat5.CoyoteRequest|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-0;_RequestID=600a4372-8d90-4491-80a5-d8a3ecd19998;|PWC4011:
Unable to set request character encoding to UTF-8 from context /eshop-war,
because request parameters have already been read, or
ServletRequest.getReader() has already been called|#]

And:

[#|2009-04-22T08:34:57.758+0300|WARNING|sun-appserver9.1|javax.enterprise.resource.webcontainer.jsf.lifecycle|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-0;_RequestID=600a4372-8d90-4491-80a5-d8a3ecd19998;|executePhase(RESTORE_VIEW
1,com.sun.faces.context.FacesContextImpl@1d2681e) threw exception
java.lang.ClassCastException: javax.faces.component.UIViewRoot cannot be
cast to com.sun.faces.application.StateManagerImpl$TreeNode
at
com.sun.faces.application.StateManagerImpl.restoreTree(StateManagerImpl.java:602)
at
com.sun.faces.application.StateManagerImpl.restoreTree(StateManagerImpl.java:551)
at
com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:87)
at
com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:290)
at
com.ocpsoft.pretty.application.PrettyViewHandler.restoreView(PrettyViewHandler.java:93)
at
com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:141)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)

.......

[#|2009-04-22T08:34:57.758+0300|WARNING|sun-appserver9.1|javax.enterprise.resource.webcontainer.jsf.lifecycle|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-0;_RequestID=600a4372-8d90-4491-80a5-d8a3ecd19998;|executePhase(RENDER_RESPONSE
6,com.sun.faces.context.FacesContextImpl@b1c600) threw exception
javax.faces.FacesException: javax.servlet.ServletException:
javax.faces.component.UIViewRoot cannot be cast to
com.sun.faces.application.StateManagerImpl$TreeNode
at
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:413)
at
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:442)
at
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
at
com.ocpsoft.pretty.application.PrettyViewHandler.renderView(PrettyViewHandler.java:87)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:547)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)

.........

In browser you see:

root cause

java.lang.ClassCastException: javax.faces.component.UIViewRoot cannot be
cast to com.sun.faces.application.StateManagerImpl$TreeNode

What version of the product are you using? On what operating system?
Windows XP Professional (2002 edition) with SP3, latest NetBeans with
glashfish v2 and latest prettyfaces + facelets.

Please provide any additional information below.
It's very interesting where parameters are messed up and why it affects
only commandLink. Your lib should be working with parameters so I assume it
might not be working correctly or there some incompatibility somewhere.
Code worked just fine without facelets and pretty faces. It would be nice
to test by removing pretty faces package, but I was not able to remove it.