Hi.
I have a code that was working in 1.4 but it shows an error message in
wicket 1.5.
I have a TextField, an AjaxSubmitLink and a ListMultipleChoice. When I click
the submit link I want to add the value from text field to the list.
ArrayList<Serializable> list = new ArrayList<Serializable>();
list.add("1");
list.add("2");
list.add("3");
listModel = new Model<ArrayList<Serializable>>(list);
Form form = new Form("form");
final FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
feedbackPanel.setOutputMarkupId(true);
form.add(feedbackPanel);
final TextField<String> textField = new TextField<String>("txtValue", new
PropertyModel<String>(this, "objectModel"));
final Model<ArrayList<Serializable>> choiceModel = new
Model<ArrayList<Serializable>>();
final ListMultipleChoice listChoice = new ListMultipleChoice("listChoice",
choiceModel, listModel);
listChoice.setMaxRows(100);
listChoice.setOutputMarkupId(true);
AjaxSubmitLink addLink = new AjaxSubmitLink("addElement", form) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
if (objectModel == null) {
return;
}
ArrayList<Serializable> model = listModel.getObject();
if (objectModel instanceof String) {
try {
if (!model.contains(objectModel)) {
model.add(objectModel);
}
} catch (NumberFormatException ex) {
error("Invalid value type.");
}
}
if (target != null) {
target.add(listChoice);
}
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(form);
}
};
form.add(textField);
form.add(listChoice);
form.add(addLink);
add(form);
In Wicket 1.5 I get : "'4' is not a valid Serializable."
I have to use Serializable because I have more components text field, date
field to take the value.
I I use String instead of Serializable, it works.
What is wrong in wicket 1,5?
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-ListMultipleChoice-add-Serializable-values-tp4585991p4585991.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]