That solved the problem. Thank you very much!

-----Original Message-----
From: Jeremy Thomerson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 03, 2008 12:26 PM
To: [email protected]
Subject: Re: Maintain radio values on submit validation

Have you tried ListView.setReuseItems(true) - I didn't look at your code
in
depth, but at a glance I think the problem is that your radios are
getting
recreated.

-- 
Jeremy Thomerson
http://www.wickettraining.com

On Wed, Dec 3, 2008 at 12:50 PM, Dane Laverty
<[EMAIL PROTECTED]>wrote:

> I have a form with a list of RadioGroups, which are all required. If
the
> user submits the form with one or more of the RadioGroups left blank,
> the validator correctly returns to form. However, when that happens,
any
> RadioGroups the user filled also become blank. Is there a way to
> maintain the values in the correctly filled RadioGroups when the form
is
> submitted? The relevant code is below.
>
>
>
> add(new ListView("questions", new PropertyModel(user,
"test.questions"))
> {
>
>
>
>  protected void populateItem(ListItem item) {
>
>    final Question question = (Question) item.getModelObject();
>
>
>
>    // answersRadioGroup will be a group of radio buttons -- one for
> each possible answer (4, currently)
>
>    RadioGroup answersRadioGroup = new RadioGroup("answers", new
> PropertyModel(question, "markedAnswerLetter"));
>
>
>
>    // This loop will generate a radio button for letters A, B, C, and
D
>
>
>    for (char letter = 'A'; letter <= 'D'; letter++) {
>
>      final String letterAsString = letter + "";
>
>      Radio radio = new Radio(letterAsString, new
> Model(letterAsString));
>
>      radio.setLabel(new
> Model(question.getAnswers().get(letterAsString).toString()));
>
>
>
>      answersRadioGroup.add(radio);
>
>    }
>
>
>
>    // Ensure that each question must be answered.
>
>    answersRadioGroup.setRequired(true);
>
>
>
>    // Put the whole shebang (radio buttons + answer texts) into the
> test.
>
>    item.add(answersRadioGroup);
>
>  }
>
> }
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to