So does mean that I need to add to my button's onSubmit() method:

   protected void onSubmit() {
        getForm.validate();

        Person person = (Person) getParent().getModelObject();
        ... etc
   }

Unfortunately I can't do that as the validate() method is protected.

-Matt

>>> [EMAIL PROTECTED] 04/22/05 11:07a.m. >>>

we probably should have an example on this and now that i think more 
about it, i think we may want to change the design slightly.

the problem right now is that you need to validate the form (as 
documented in the Form class javadoc).  with one-button forms this 
happens automatically.

in Form, the submit even listener method (which is internal), simply 
calls Form.onValidate(), which looks like this:

    protected void onValidate()
    {
        final int buttons = countButtons();
        if (buttons <= 1)
        {
            validate();
        }
        else if (buttons > 1)
        {
            final Button button = findSubmittingButton();
            if (button == null)
            {
                throw new WicketRuntimeException("Unable to find 
submitting button");
            }
            else
            {
                button.onSubmit();
            }
        }
    }

so, if you have a single button form, validate() gets called on the
form 
automatically.  but if you have more than one button, wicket locates
the 
button and calls button.onSubmit().  it's currently up to the button 
code itself to validate the form in this case.  so you would call 
Form.validate() in your button onSubmit().  i agree that this is a 
little asymetrical and it seems like it ought to be fixed.... 

we could change the code so that validate() is always called before the

Button.onSubmit() method.  this would result in

1. Form.validate()
2. Form.onSubmit()
3. Button.onSubmit()

and such behavior would be more consistent in some sense, but it would

also mean that you couldn't just directly handle a multi-button form 
submission without validation (and model updating) occurring first.

maybe a better alternative would be to have a Button.onValidate() like

the Form.onValidate() with a default implementation that validates the

form that the button is attached to?  then it would behave the way 
you're expecting, but still be flexible enough to handle the case where

someone wants full control over the submit/validate process...

anyone on the dev team have some thoughts here?

    jon

Matthew Watson wrote:

>I'm working on a wizard that includes three buttons: cancel, save,
>next.
>
>The wizard extends WebPage, which imbeds a form that in turn includes
>three buttons. See below:
>
>public class Wizard extends WebPage {
>
>    public Wizard() {
>        super();
>        add(new WizardForm("form"));
>    }
>
>    private class WizardForm extends Form {
>
>        public WizardForm(String s) {
>            super(s);
>
>            CompoundPropertyModel model = new
CompoundPropertyModel(new
>Person());            
>            setModel(model);
>
>            add(new TextArea("summary"));
>            add(new TextArea("description"));
>
>            add(new CancelButton());
>            add(new SaveButton());
>            add(new NextButton(Whatever.class));
>        }
>
>        protected void onSubmit() {
>        }
>    }
>}
>
>
>public class SaveButton extends Button {
>
>    public SaveButton() {
>        super("save");
>    }
>
>    protected void onSubmit() {
>        Person person = (Person) getParent().getModelObject();
>
>        MockDatabase.getInstance().addPersont(person);
>
>        RequestCycle cycle = getRequestCycle();
>        cycle.setResponsePage(new People());
>        cycle.setRedirect(true);
>    }
>}
>
>When the save button is pressed the above is executed. However
>regardless of what I type into the html form the values I enter for
>summary + description never get set on the person object.
>
>I've more or less followed the guestbook example, but I don't
>understand why they aren't being set automatically.
>
>Any ideas?
>
>Thanks,
>Matt
>
>********************************************************************************
>This email may contain legally privileged information and is intended
only for the addressee. It is not necessarily the official view or 
>communication of the New Zealand Qualifications Authority. If you are
not the intended recipient you must not use, disclose, copy or
distribute this email or 
>information in it. If you have received this email in error, please
contact the sender immediately. NZQA does not accept any liability for
changes made to this email or attachments after sending by NZQA. 
>
>All emails have been scanned for viruses and content by MailMarshal. 
>NZQA reserves the right to monitor all email communications through
its network.
>
>********************************************************************************
>
>
>-------------------------------------------------------
>SF email is sponsored by - The IT Product Guide
>Read honest & candid reviews on hundreds of IT Products from real
users.
>Discover which products truly live up to the hype. Start reading now.
>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click 
>_______________________________________________
>Wicket-user mailing list
>[email protected] 
>https://lists.sourceforge.net/lists/listinfo/wicket-user 
>
>  
>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real
users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click 
_______________________________________________
Wicket-user mailing list
[email protected] 
https://lists.sourceforge.net/lists/listinfo/wicket-user

********************************************************************************
This email may contain legally privileged information and is intended only for 
the addressee. It is not necessarily the official view or 
communication of the New Zealand Qualifications Authority. If you are not the 
intended recipient you must not use, disclose, copy or distribute this email or 
information in it. If you have received this email in error, please contact the 
sender immediately. NZQA does not accept any liability for changes made to this 
email or attachments after sending by NZQA. 

All emails have been scanned for viruses and content by MailMarshal. 
NZQA reserves the right to monitor all email communications through its network.

********************************************************************************


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to