Hi Martin, call get or set defaultModel is not the solution, consider this another test case:
The new link implementation: AjaxLink link = new AjaxLink("reload") { @Override public void onClick(AjaxRequestTarget target) { textField.setDefaultModelObject(new Integer(30)); target.addComponent(textField); } }; new test script: 1- click on the reload link, then you has as expected the text field markup presenting the new value on model 2 - type something wrong on the text field, like some non numeric characters 3 - submit the form. At this moment, you has your forms components on the server with the raw input 3 - press reload link, to update the markup of the component 4 - you has now an text field markup presenting the wrong user typed value, and the original one on the component model For this case modelChanged or clearInput method solves the problem of render the form component with his actual model value. It brings me an question, does store the raw input on server worth? pro: user can go back to his form, and has all his input back cons: he already get his input back on the render parse, and the browser can remember just using html meta tags that require cache On Tue, Feb 23, 2010 at 9:06 AM, Martin Makundi < martin.maku...@koodaripalvelut.com> wrote: > 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 > > > -- Pedro Henrique Oliveira dos Santos