ListView documentation states that you should "setReuseItems(true)"
when working in a form or with form components.

Martijn

On Sat, Mar 21, 2009 at 9:26 PM, Alexander Lohse <[email protected]> wrote:
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to