Hello,
I have a ListMultipleChoice component in my form and I get the following
exception when I select an option and submit the form:
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
to java.util.Collection
at
org.apache.wicket.markup.html.form.ListMultipleChoice.updateModel(ListMu
ltipleChoice.java:325)
at
org.apache.wicket.markup.html.form.Form$20.validate(Form.java:1837)
at
org.apache.wicket.markup.html.form.Form$ValidationVisitor.formComponent(
Form.java:165)
at
org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPost
OrderHelper(FormComponent.java:421)
at
org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPost
OrderHelper(FormComponent.java:408)
at
org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPost
Order(FormComponent.java:385)
at
org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(For
m.java:1060)
at
org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModel
s(Form.java:1829)
at
org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.j
ava:1796)
at org.apache.wicket.markup.html.form.Form.process(Form.java:865)
at
org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:807)
... 53 more
Could someone please point out if I'm missing something? Here's the
relevant pieces of my code:
------
ListMultipleChoice searchPymntApplCd = new
ListMultipleChoice(
"searchPymntApplCd",
new AbstractReadOnlyModel() {
public Object getObject() {
return getPaymentApplOptions(paymentAppls);
//This returns ArrayList<PaymentApplOption>
}},
new IChoiceRenderer() {
public Object getDisplayValue(Object object) {
PaymentApplOption option =
(PaymentApplOption) object;
return option.getPymntApplDesc();
}
public String getIdValue(Object object, int
index) {
if
(PaymentApplOption.class.isInstance(object)) {
PaymentApplOption option =
(PaymentApplOption) object;
return option.getPymntApplCd();
}
return null;
}
}).setMaxRows(5);
searchPymntApplCd.setRequired(false);
searchPymntApplCd.setType(Collection.class);
add(searchPymntApplCd);
-------
public class PaymentApplOption implements Serializable {
private String pymntApplCd;
private String pymntApplDesc;
...
}
Thanks.