Hi,
I am encountering a strange problem when adding DropDownChoices to a
ListView. Displaying and retrieving values works fine, BUT the values
are lost during errorous form submission.
The following ListView is added to a form. When the form is submitted
successful all ModelObjects are updated fine.
But when submission fails ( e.g. because of some other fields which
are required and values are missing) the DropdownChoices loose their
selected values and return to the "original" ModelObject value.
Here is the code of the ListView:
public class TaskList extends ListView<ReminderTaskProxyModel> {
public TaskList (String id) {
super(id);
setRenderBodyOnly(true);
}
protected void populateItem (final
ListItem<ReminderTaskProxyModel> listItem) {
ReminderTaskProxyModel model = listItem.getModelObject();
WeekdayChoice dayChoice = new WeekdayChoice("day");
dayChoice.setModel(new PropertyModel<Integer>(model, "day"));
listItem.add(dayChoice);
HourChoice hourChoice = new HourChoice("hour");
hourChoice.setModel(new PropertyModel<Integer>(model, "hour"));
listItem.add(hourChoice);
listItem.setRenderBodyOnly(true);
}
}
WeekdayChoice and HourChoice basically extend DropDownChoice and set
the choices and a renderer:
public class HourChoice extends DropDownChoice<Integer> {
public HourChoice (String id) {
super(id);
setChoiceRenderer(new HourRenderer());
List<Integer> hours = new LinkedList<Integer>();
for(int i = 1; i <= 24; i++) {
hours.add(i);
}
setChoices(hours);
}
private class HourRenderer implements IChoiceRenderer<Integer> {
private NumberFormat format = new DecimalFormat("00.##");
public Object getDisplayValue (Integer hour) {
return format.format(hour) + ":00";
}
public String getIdValue (Integer hour, int index) {
return String.valueOf(hour);
}
}
}
Any ideas, or hints where I might go wrong are greatly appreciated.
Thank you in advance!
Regards,
Alex
______________________________________________________________
"A designer knows he has achieved perfection not when there is nothing
left to add,
but when there is nothing left to take away."
(Antoine de Saint Exupéry)
.............................................................................................
Alexander Lohse • Entwicklungsleitung & Projektmanagement
Tel +49 38374 752 11 • Fax +49 38374 752 23
http://www.humantouch.de
Human Touch Medienproduktion GmbH
Am See 1 • 17440 Klein Jasedow • Deutschland
Geschäftsführung:
Lara Mallien, Nele Hybsier, Alexander Lohse, Johannes Heimrath (Senior)
Handelsregister Stralsund • HRB 4192 • USt-IdNr. DE128367684
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org