[
https://issues.apache.org/jira/browse/MYFACES-1891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613183#action_12613183
]
Paul Rivera commented on MYFACES-1891:
--------------------------------------
I was able to replicate this bug. I've attached a patch that fixes this.
Christian is right, it is rooted in the handling of RendererUtils.NOTHING.
The patch I've provided adds the code below to the beginning of the
getConvertedStringValue() method of RendererUtils.
+ if (RendererUtils.NOTHING.equals(value)) {
+ return "";
+ }
+
if (converter == null) {
if (value == null) {
return "";
The idea of this fix is partly from the patch Christopher Pierce provided for
MYFACES-1567. Although, here, the check for NOTHING should be outside the
block where converter is checked for null.
The second fix provided in my patch is:
public static final String SELECT_ITEM_LIST_ATTR =
RendererUtils.class.getName() + ".LIST";
public static final String EMPTY_STRING = "";
- public static final Object NOTHING = new Serializable() {};
+ public static final Object NOTHING = new Serializable() {
+ public boolean equals(Object o)
+ {
+ if(o != null)
+ {
+ if(o.getClass().equals(this.getClass()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
The NOTHING object has to have a modified equals() method to return true as
long as the object is of the same class. Without this modification,
RendererUtils.NOTHING.equals(value) is never satisfied since 'value' is a field
of a Component that gets serialized/deserialized along with the UIViewRoot in
JspStateManagerImpl. If it gets serialized and deserialized, regardless of
server or client state saving method, 'value' will be a new instance and
RendererUtils.NOTHING.equals(value) will return false.
You can also observe this when using SelectOneListbox. Tracing through the
code, you can see that in HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet()
Line 365:
else
if(org.apache.myfaces.shared_impl.renderkit.RendererUtils.NOTHING.equals(lookup))
{
lookupSet = Collections.EMPTY_SET;
}
else
{
lookupSet = Collections.singleton(lookup);
}
the 'else if' condition will never be satisfied even if nothing is selected in
the selectOneListbox. This is because lookup is of another instance that came
from serialization/deserialization of the RendererUtils.NOTHING object.
Therefore, lookupSet will never be the EMPTY_SET. Instead, it will be a
collection containing the single element RendererUtils.NOTHING. Although this
makes the code only marginally slower, I think it's still best to fix it.
I've also tested SelectOneListbox and SelectManyCheckbox if they experienced
problems when nothing is selected. But I've encountered no bugs when testing
them.
> ClassCastException in converter when Hiding / Showing unselected
> selectOneRadio
> -------------------------------------------------------------------------------
>
> Key: MYFACES-1891
> URL: https://issues.apache.org/jira/browse/MYFACES-1891
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 1.2.3
> Environment: MyFaces 1.2.3, Spring WebFlow 2.0.2, RichFaces 3.2.1,
> Tomahawk 1.1.6, Facelets 1.1.15.B1, Tomcat 6.0.16
> Reporter: Patrick Schmidt
> Attachments: example.zip, RendererUtils.patch
>
>
> See the attached example.
> When the block with the selectOneRadio ist shown, then hidden and then shown
> again a ClassCastException occurs in the Converter. The selectOneRadio has as
> submittedValue org.apache.myfaces.shared_impl.renderkit.RendererUtils$1, for
> which the conversion is done.
> javax.faces.FacesException: Exception while calling encodeEnd on component :
> {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId:
> /WEB-INF/pages/schnellerfassung/dea/dea.xhtml][Class:
> javax.faces.component.html.HtmlForm,Id: form][Class:
> org.apache.myfaces.custom.div.Div,Id: hideableBlock][Class:
> javax.faces.component.html.HtmlSelectOneRadio,Id: selectOneRadio]}
> at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:610)
> at
> org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:286)
> at
> org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
> at
> org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284)
> at
> org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
> at
> org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284)
> at
> org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:125)
> at
> org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
> at
> org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
> at
> org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
> at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:673)
> at
> org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:544)
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:239)
> at
> com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
> at
> org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
> at
> org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
> at org.springframework.faces.webflow.JsfView.render(JsfView.java:92)
> at
> org.springframework.webflow.engine.ViewState.render(ViewState.java:240)
> at
> org.springframework.webflow.engine.ViewState.resume(ViewState.java:199)
> at org.springframework.webflow.engine.Flow.resume(Flow.java:535)
> at
> org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:261)
> at
> org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:153)
> at
> org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:173)
> at
> org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:172)
> at
> org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
> at
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
> at
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
> at
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
> at
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> com.metzler.ec.web.filter.RendererFilter.doFilter(RendererFilter.java:183)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
> at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
> at
> org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
> at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:359)
> at
> org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
> at
> org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:268)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:268)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:87)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:61)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:229)
> at
> org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
> at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
> at
> org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:174)
> at
> org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
> at
> org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
> at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:595)
> Caused by: javax.faces.convert.ConverterException:
> java.lang.ClassCastException:
> org.apache.myfaces.shared_impl.renderkit.RendererUtils$1
> at
> javax.faces.convert.IntegerConverter.getAsString(IntegerConverter.java:85)
> at
> org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:628)
> at
> org.apache.myfaces.shared_impl.renderkit.html.HtmlRadioRendererBase.encodeEnd(HtmlRadioRendererBase.java:91)
> at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:607)
> ... 87 more
> Caused by: java.lang.ClassCastException:
> org.apache.myfaces.shared_impl.renderkit.RendererUtils$1
> at
> javax.faces.convert.IntegerConverter.getAsString(IntegerConverter.java:81)
> ... 90 more
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.