Yes.. don't use referenceToModel. Instead call

textField.getDefaultModelObject();

**
Martin

2010/2/23 Pedro Santos <pedros...@gmail.com>:
> Hi Martin, consider this form:
>
> java code:
>        Form form = new Form("form");
>        add(form);
>        final TextField<Integer> textField = new TextField("tf", new
> Model());
>        textField.setType(Integer.class);
>        textField.setOutputMarkupId(true);
>        form.add(textField);
>        AjaxLink link = new AjaxLink("reload") {
>            public void onClick(AjaxRequestTarget target) {
>                IModel referenceToModel = textField.getDefaultModel();
>                referenceToModel.setObject(new Integer(30));
>                target.addComponent(textField);
>            }};
>        form.add(link);
>        form.add(new FeedbackPanel("fp"));
>
> markup code:
>
> <form wicket:id="form" >
> <input wicket:id="tf" type="text" />
> <a wicket:id="reload">reload</a>
> <input type="submit" />
> <div wicket:id="fp" ></div>
> </form>
>
> In the browser:
> 1 - you type something wrong on the text field, like some non numeric
> characters
> 2 - submit the form. At this moment, you has your forms components on the
> server with the raw input
> 3 - press reload link, to change the value on the text field model
> 4 - you has now an text field presenting the wrong user typed value, and the
> new one on the component model on server.
>
>
> On Mon, Feb 22, 2010 at 5:55 PM, Martin Makundi <
> martin.maku...@koodaripalvelut.com> wrote:
>
>> Hi!
>>
>> What's the difference whether it's thrown away or not if the next step
>> is re-submit with new values?
>>
>> **
>> Martin
>>
>> 2010/2/22 Pedro Santos <pedros...@gmail.com>:
>> > IMO the form processing can be:
>> >
>> >>
>> >> 1. validate
>> >> 2. detect error
>> >> 3. keep rawinput
>> >> 4. re-render error components with red border AND rawinput
>> >>
>> >
>> > 4.1. throw away the raw input in some detach method
>> >
>> > 5. user retry form submit
>> >>
>> >
>> > 6. all form components get they raw input again since they get rendered
>> > before some detach method clear they raw input, no need to maintain those
>> > values on the server
>> >
>> >
>> >
>> >
>> > --
>> > Pedro Henrique Oliveira dos Santos
>> >
>>
>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>

Reply via email to