[ https://issues.apache.org/jira/browse/MYFACES-1760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540546 ]
David Brainard commented on MYFACES-1760: ----------------------------------------- When we change the value binding from a list to an array this problem does not occur.ie in this value-expression "#{test_scope.targetPagePhysicals}" if targetPagePhysicals is an array this problem wont occur. I checked the impl. The problem is that when the selected values are converted, the type of value binding is checked valueType = vb.getType(facesContext); and if it is an array the selected values are set in a array and if it is a list it is set to an arraylist. so when getSelectedValues() method is called it just resolves the value and casts it to Object[] and we get the prob. I have checked with the Sun RI. the prob is present there also. I have checked the specs.this is wat it is stated in the specs. "This property is a typesafe alias for the value property,so that the actual state to be used can be acquired via a value expression." I think we have to check the type of the value returned by value binding before casting to Object[](Unless it has been implemented like that intentionally for some reason). pls comment if there is any prob. > Using "getSelectedValues" of "UISelectMany" seems to be causing > "ClassCastException" > ------------------------------------------------------------------------------------ > > Key: MYFACES-1760 > URL: https://issues.apache.org/jira/browse/MYFACES-1760 > Project: MyFaces Core > Issue Type: Bug > Affects Versions: 1.1.5 > Reporter: Guy Bashan > > It seems like calling getSelectedValues method of selectBooleanCheckbox > causes exception. > This is an example for a fregment of code: > --------------------------------------------------------- > <t:selectManyCheckbox > value="#{test_scope.targetPagePhysicals}" layout="pageDirection" > converter="PagePhysicalConverter" binding="#{test_scope.htmlSelect}"> > <f:selectItems > value="#{test_scope.pagePhysicals}" /> > </t:selectManyCheckbox> > <t:commandButton value="submitTargetPages" > style="width:100px" immediate="true" onclick="submit()" forceId="true" > actionListener="#{test_scope.targetPagesSelectedAction}" /> > In the bean: > ---------------- > public void targetPagesSelectedAction(ActionEvent event) > { > Object[] xx = htmlSelect.getSelectedValues(); > FacesContext.getCurrentInstance().renderResponse(); > } > Causes the following exception: > ------------------------------------------- > javax.servlet.ServletException: Exception while invoking expression > #{test_scope.targetPagesSelectedAction} > at javax.faces.webapp.FacesServlet.service(FacesServlet.java:154) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at org.ajaxanywhere.AAFilter.doFilter(AAFilter.java:46) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilter.java:285) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > com.amadesa.admin.model.persistence.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:149) > at > com.amadesa.admin.model.persistence.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:56) > 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:228) > 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:104) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) > at > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) > at java.lang.Thread.run(Thread.java:619) > Caused by: javax.faces.el.EvaluationException: Exception while invoking > expression #{test_scope.targetPagesSelectedAction} > at > org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:156) > at javax.faces.component.UICommand.broadcast(UICommand.java:89) > at > javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97) > at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:139) > at > org.apache.myfaces.lifecycle.ApplyRequestValuesExecutor.execute(ApplyRequestValuesExecutor.java:32) > at > org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95) > at > org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70) > at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139) > ... 25 more > Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast > to [Ljava.lang.Object; > at > javax.faces.component.UISelectMany.getSelectedValues(UISelectMany.java:48) > at > com.amadesa.admin.view.bean.test.TestScopeBean.targetPagesSelectedAction(TestScopeBean.java:166) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132) > ... 32 more -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.