This is a bizarre use-case to some extent. You want the user's input to be saved prior to the user's session expiring.
Wouldn't it be easier to run validation and save the user's input as the field level? This way as the user leaves a form field, the validation kicks in and if correct the new input is saved. Granted you would have to work some other flows, you might want different states of saving the user input. One committed to the storage tier, the other committed to the user's name space as one can navigate through your UI and leave from one page to another. Should you still show the "auto-saved" form fields which override the actual state of the application? Probably not, so you'll have to reset the auto-saved data each time the page is rendered. Is a cool idea duh, persist the user's input between sessions (although not right as you'll hide the actual state). ie: What happens when it takes me 1 hr to time out my session, I come back tomorrow and see my old input instead of what's really in the database? ~ Thank you, Paul Bors On Tue, Jan 7, 2014 at 2:52 PM, Marios Skounakis <msc...@gmail.com> wrote: > In a similar case I've used a wrapper around validators which controls > whether they run or not. This way you can automatically parse the form > component tree, find all validators and wrap them in a new Validator that > runs them only if needed. > > I've done this because I wanted to be able to have the standard wicket > validators run in onValidateModelObjects(). I.e. I wanted my model to be > updated even if some validations did not pass. > > So here's the basic idea (this is slightly modified from my actual code so > it may have small errors). > > public abstract class ValidatorWrapper<T> implements IValidator<T> { > IValidator<T> validator; > public DelayedValidator(IValidator<T> validator) { > super(); > this.validator = validator; > } > > protected abstract boolean shouldRun(); > > @Override > public void validate(IValidatable<T> validatable) { > if (!shouldRun()) > return; > if (validatable.getValue() == null) { > if (!(validator instanceof INullAcceptingValidator<?>)) { > return; > } > } > validator.validate(validatable); > } > } > > It is reasonably easy to extend this for FormValidators as well. > > This does not handle the case of conversion errors, i.e. in an Integer > TextField if the user input is not a valid integer, it won't update the > model object. So if you auto-save and the reload, such fields will be > empty. This is something that would actually be a lot of work to handle > because you would need a custom model that would actually store string > values. > > Cheers > Marios > > > On Tue, Jan 7, 2014 at 9:32 PM, gmparker2000 <greg.par...@brovada.com > >wrote: > > > Interesting but unfortunately our form is very complex with repeaters, > etc. > > So I don't think this would work for us. > > > > -- > > View this message in context: > > > http://apache-wicket.1842946.n4.nabble.com/Auto-save-feature-tp4663517p4663522.html > > Sent from the Users forum mailing list archive at Nabble.com. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > >