Thank you very much!

Now that I know what to look out for, I think I must have been blind while searching for an answer.

But my first reference, this cwiki page, missed out on this:

http://cwiki.apache.org/WICKET/listview-with-checkboxes.html

I just updated it and added the necessary line!

Best Regards,

Alex

Am 21.03.2009 um 21:29 schrieb Martijn Dashorst:

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 <a...@humantouch.de> 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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





--
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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org


______________________________________________________________

"In software, we rarely have meaningful requirements.
Even if we do, the only measure of success that matters is
whether our solution solves the customer's shifting idea of what their problem is."
(Jeff Atwood)
.............................................................................................

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

Reply via email to