ClassCastException in ListMultipleChoice when using setType()
--------------------------------------------------------------
Key: WICKET-2752
URL: https://issues.apache.org/jira/browse/WICKET-2752
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.4.1
Environment: Windows XP, java 1.6.0_18, Tomcat 6.0.24
Reporter: Denis Bogdanas
Priority: Minor
If we call setType() on a ListMultipleChoice, it will lead to the following
exception on form submit:
java.lang.ClassCastException: java.lang.String cannot be cast to
java.util.Collection
at
org.apache.wicket.markup.html.form.ListMultipleChoice.updateModel(ListMultipleChoice.java:327)
etc.
Example code:
ListMultipleChoice<AT> listBox = new ListMultipleChoice<AT>(...);
listBox.setRequired(true);
listBox.setType(String.class);
I found the cause using debug. The method FormComponent.convertInput() contains
the following code:
protected void convertInput()
{
if (typeName == null)
{
try
{
convertedInput =
convertValue(getInputAsArray());
}
...
}
else
{
...
try
{
convertedInput =
(T)converter.convertToObject(getInput(), getLocale());
}
...
}
}
The input is processed as a single element instead of array when typeName ==
null. I suppose the call setType() should be prohibited when the component
doesn't use it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.