Well that's the thing, a reset back to defaults makes sense since that's how most apps behave. Wiping out the defaults and emptying out the form fields is a bit strange to call via a "Reset" button, maybe "New" button? As Martin described it makes sense but might be confusing to the user unless you're explicit in the UI.
The last time I had to touch on the form field's input VS its model was to audit the user input as Hibernate's Envers didn't fit our services (which touched on too many entities at once and was harder to present in the UI to the system admin). ~ Thank you, Paul Bors -----Original Message----- From: Richard W. Adams [mailto:rwada...@up.com] Sent: Monday, September 30, 2013 10:52 AM To: users@wicket.apache.org Subject: RE: Form Reset Problems Our use case is probably more complex than most. We have a form that does a lot Ajax field updates that appear to break the reset function on some browsers. That's why resorted to doing the reset via Ajax. From: Paul Bors <p...@bors.ws> To: <users@wicket.apache.org> Date: 09/30/2013 09:41 AM Subject: RE: Form Reset Problems I'll like to hear more about Richard's use-case as to me using Ajax to perform a form reset that could be done by the browser is a bit of an overkill. Unless some sort of a user workflow through the app happens in stages for which I would recommend using a Wizard. ~ Thank you, Paul Bors -----Original Message----- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Monday, September 30, 2013 9:57 AM To: users@wicket.apache.org Subject: Re: Form Reset Problems Hi, I'm going to write a blog article about Form component's input vs. model. I've been asked few times about this last two weeks by colleagues of mine. It would be good to have it in the official guide though ( https://issues.apache.org/jira/browse/WICKET-5321). To reset a form you should: 1) use a button with default processing == false, to prevent form validation (or just AjaxLink) 2) call form.clearInput() 3) and to set the "default" model for each form component. Each application should know what "default" means for its form components. On Mon, Sep 30, 2013 at 3:46 PM, Richard W. Adams <rwada...@up.com> wrote: > We're having trouble making our form reset button work. It's defined > thusly: > > AjaxButton button = new AjaxButton("reset-button"); ... > <input type="button" value="Reset" wicket:id="reset-button" /> > _____________________________________________ > > Here's our reset code, executed when the button is clicked. The main > form seems to re-render OK, but a FormComponentPanel that is part of > the form does not. I see a lot of discussion on Wicket form resets on > the Web, but most is several years old. Is there an "officially" > endorsed pattern or example for doing Ajax form resets? > _____________________________________________ > > public void onReset(final AjaxRequestTarget target) { > > final Component.IVisitor<FormComponent<?>> visitor = new > Component.IVisitor<FormComponent<?>>() { > > @Override public Object component(final > FormComponent<?> > formComponent) { > > if (formComponent.getDefaultModel() != null) { > // Must have a model for the component > final Object currentValue = > formComponent.getDefaultModelObject(); // Save model value > formComponent.clearInput(); // Clear > out formComponent.setDefaultModelObject(currentValue); // Add the > value back > } > if (target != null) { > target.addComponent(formComponent); > } > return Component.IVisitor.CONTINUE_TRAVERSAL; > } > }; > visitChildren(FormComponent.class, visitor); > } > > > ** > > This email and any attachments may contain information that is > confidential and/or privileged for the sole use of the intended recipient. > Any use, review, disclosure, copying, distribution or reliance by > others, and any forwarding of this email or its contents, without the > express permission of the sender is strictly prohibited by law. If > you are not the intended recipient, please contact the sender > immediately, delete the e-mail and destroy all copies. > ** > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org ** This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient. Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law. If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies. ** --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org