[ https://issues.apache.org/jira/browse/MYFACES-1760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540814 ]
David Brainard commented on MYFACES-1760: ----------------------------------------- this is wat the spec(jsf-1_2-spec) says about Selected values: name :selected Values Type : Object[] or array of primitives Description : The selected item values of this component. 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." according to this we have to just obtain the value from the value expression and return a primitive or an object[] So according to me the logic should be as follows: Obtain the value through value binding if the value is an array return the value casting it to Object[] if the value is a ArrayList convert the value to an array, return the array after casting it to Object[] if this is acceptable pls comment i'l add a patch for this tom. Regards, David Brainard Sounthiraraj > 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.