I've done this before by implementing the notion of "Draft Mode" in the
form.
Like Igor suggested, if you have fields that are incompatible with your
model (i.e. string in a number field) you'll either need to decide to force
the user to fix those things in all cases, or alternatively change your
model to accept strings across the board.
All you need to do to implement a draft mode is to have your form's onSubmit
essentially do nothing. Then any validations that you add just check the "am
I in draft mode" flag.
Then you can override the "process" method of your form to change the draft
mode on the basis of which submit button (i.e. save or submit) was pressed
-
e.g.
private final SubmitButton submitButton = new SubmitButton("submit");
private boolean draftMode = true;
@Override
public void process(IFormSubmittingComponent submittingComponent) {
draftMode = !(submittingComponent == submitButton);
super.process(submittingComponent);
}
This is necessary since we need to update the flag prior to validation being
run.
This does mean that you can't use Wicket's built in required field
validator, you'll need to create your own.
For our application we do this quite a bit, so we built our own standard way
of doing this internally.
HTH
On Thu, Sep 16, 2010 at 6:16 AM, Clint Checketts wrote:
> I have a form with 2 buttons: Save and Submit. If the user hits Save I want
> to bypass my validations, but still update the underlying model objects so
> i
> can persist them in a partially completed state, then have the full
> validation run when the Submit button is clicked.
>
> If I call setDefaultFormProcessing(false) then the underlying model isn't
> updated either, right? This seems like a pretty common issue, has anyone
> else implemented a genius way of dealing with save/submit logic?
>
> Thanks,
>
> -Clint
>
--
Richard Nichols
http://www.richardnichols.net/ :: http://onmydoorstep.com.au/