I’m not sure how i should put this question cos’ there are couple of files (.java, .xhtml, etc) involved. Anyway this programs involves couple of checkboxes (selectmanycheckbox) and others. There is a onchange=submit() on this selectmanycheckboxes.
Here’s what i noticed:
- The generated html for each of those checkboxes there is a onchange=submit(). Kind of funny that by checking a checkboxes, it is submitting the form everytime.
The real issue is when i check one of the checkboxes, there is an error exactly as printed.
======================================================================
java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
Caused by:
java.lang.ClassCastException – [I cannot be cast to [Ljava.lang.Object;
I don’t understand the [I here. Any idea?
What i did after that was to remove all the checkboxes and submit the form. Still getting the same error.
Any idea?
The source code is available on their site. Your particular code is provided in
javaee/ch04/selectfolder.It’s been set by the
<h:selectManyCheckbox onchange="submit()" />in the code example. Theonchangeattribute is indeed totally unnecessary. It’s likely an oversight of the author.The
[Iis the signature of anint[]type. The exception is telling that an instance ofint[]type cannot be cast to an instance ofObject[]. This makes in turn no sense, it should work fine. This particular problem is caused by something else.The
<h:selectManyMenu>in the code example is also bound to anint[]property.However removing them is not the right solution. It should work fine. Your problem is caused by something else deeper under the hoods. It’s likely a bug in the EL implementation used. What servletcontainer make/version are you using? What servlet API version is your
web.xmldeclared to? Did you try upgrading the servletcontainer?