-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Make sure the cancel button is type="button" and not type="submit".
then just define an onClick for your cancel button to navigate where you
want.

Vincent Jenks wrote:
> So, I'm trying to figure out if I should do with my form buttons.  I
> have two buttons ('save' and 'cancel') but only the onSubmit event
> handler is fired.  I have a button inside of the form's constructor that
> has an onClick event but that never happens...apparently because the
> onSubmit 'trumps' the onClick event.
> 
> Here's my class as it stands:
> 
>     private static class EditProductForm extends Form
>     {
>         public EditProductForm(String name, Product product)
>         {
>             super(name, new CompoundPropertyModel(product));
>            
>             //get collection of Category items
>             IModel catsModel = new LoadableDetachableModel()
>             {
>                 protected Object load()
>                 {
>                     return ProductProxy.getAllCategories(); //via proxy
>                 }
>             };
>            
>             //add form components
>             add(new
> TextField("productCode").add(RequiredValidator.getInstance ()));
>             add(new TextField("name").add(RequiredValidator.getInstance()));
>             add(new
> TextArea("summary").add(RequiredValidator.getInstance()));
>             add(new Button("saveButton"));
>            
>             //add reset button DOESN'T WORK!
>             add(new Button("cancelButton")
>             {
>                 public void onClick()
>                 {
>                     modelChanged();
>                     setResponsePage(new EditProduct());
>                 }
>             });
>         }
>        
>         public void onSubmit()
>         {
>             //save form values, redirect
>             Product product = (Product)getModelObject();
>             ProductProxy.addProduct(product);
>             setResponsePage(new EditProduct());
>         }
>     }
> 
> Should I leave onSubmit empty and use two onClick events for the form
> buttons?
> 
> The form is doing validation, also, if that effects anything.
> 
> Thanks!

- --
Justin Lee
http://www.antwerkz.com
AIM : evan chooly
720.299.0101
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)

iD8DBQFEHc0jJnQfEGuJ90MRA/G9AJ0S8yAzsWWQH802nSef+LS23qNbMACcCWjR
SDlWuEAvGEj6mweK4RudZ5U=
=WtvB
-----END PGP SIGNATURE-----


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to