[
https://issues.apache.org/jira/browse/MYFACES-1760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540407
]
Simon Kitching commented on MYFACES-1760:
-----------------------------------------
The getSelectedValues method certainly assumes the value is an array:
public Object[] getSelectedValues()
{
return (Object[]) getValue();
}
Note that the spec for UISelectMany says: "Optionally, the component can be
preconfigured with zero or more currently selected items, by storing them as an
array in the value property of the component.". And the setSelectedValues
method takes only an array as a parameter. This suggests that the value should
always be an array (ie it would be an error to bind the value to an expression
returning a list).
However currently methods compareValues and _createItemValuesIterator both try
to handle values that are list types.
Guy, I presume that your value-expression "#{test_scope.targetPagePhysicals}"
returns a List?
> 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.