Re: [Wicket-user] onSubmit vs onClick for form submission
In the following code: add(new Button("saveButton") { public void onSubmit() { //save form values, redirect@@ Product product = (Product)getModelObject(); ProductProxy.addProduct(product); setResponsePage(new EditProduct()); } });The line marked @@ is wrong. You ask from the submit button the modelobject. Because the button doesn't have a model (model == null), and the form has a compound model, it will use the component id "saveButton" as an OGNL _expression_ with the form modelobject as base. This happened because you create an anonymous subclass on the Button. The event handler 'onSubmit' has a this pointer to the button.This can be solved by changing the line to the following:Product product = (Product)getParent().getModelObject(); MartijnOn 3/20/06, Vincent Jenks <[EMAIL PROTECTED]> wrote: OK, believe it or not, I did just that and *still* cannot get it to work.Here's my Form class: 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 TextArea("description").add(RequiredValidator.getInstance())); add(new TextField("unitPrice")); add(new TextField("weight")); add(new TextField("height")); add(new TextField("width")); add(new TextField("length")); add(new TextField("insuredValue")); add(new CheckBox("freeShipping")); add(new TextField("thumbnail").add(RequiredValidator.getInstance())); add(new TextField("photo").add(RequiredValidator.getInstance ())); //add reset button add(new Button("cancelButton") { public void onSubmit() { setResponsePage(new EditProduct()); } }.setDefaultFormProcessing(false)); //add reset button add(new Button("saveButton") { public void onSubmit() { //save form values, redirect Product product = (Product)getModelObject(); ProductProxy.addProduct(product); setResponsePage(new EditProduct()); } }); } }The cancel button works now but the save button is now throwing an exception:wicket.WicketRuntimeException : Method public abstract void wicket.markup.html.form.IFormSubmitListener.onFormSubmitted () of interface java.lang.reflect.Method threw an exception ..Caused by: java.lang.reflect.InvocationTargetException ..Caused by: wicket.WicketRuntimeException: OGNL Exception: _expression_='saveButton'; path='4:editProductForm:saveButton' ...Caused by: ognl.NoSuchPropertyException: com.myapp.model.Product.saveButton...Here's the form HTML just in case I'm goofing something there: ... What's wrong w/ this?Thanks!On 3/19/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote: the easiest way to do this is add two buttons with two onsubmit handlers instead of using the form's onsubmit. so add(new Button("save") { onsubmit() { // do the saving here } })add(new Button("cancel") { onsubmit() { //navigate away here } }.setDefaultFormProcessing(false)); notice the call to setDefaultFormProcessing(false) on the cancel button. this will tell wicket that when this button is pressed it should not validate/update model instead go directly to the button's onsubmit handler. -IgorOn 3/19/06, Riyad Kalla <[EMAIL PROTECTED]> wrote: Don't you need to commit the response?(just a lame guess from the servlet world)On 3/19/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:> Alright, did that, now the button doesn't do anything at *all*. >> Here's the HTML button:>> >> ...and the event handler:>>> add(new Bu
Re: [Wicket-user] onSubmit vs onClick for form submission
I "fixed" this by using Form.onSubmit() for the save button and keeping the cancel button the same...now both work just fine...but not exactly as Igor described.Good enough! On 3/20/06, Vincent Jenks <[EMAIL PROTECTED]> wrote: OK, believe it or not, I did just that and *still* cannot get it to work.Here's my Form class: 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 TextArea("description").add(RequiredValidator.getInstance())); add(new TextField("unitPrice")); add(new TextField("weight")); add(new TextField("height")); add(new TextField("width")); add(new TextField("length")); add(new TextField("insuredValue")); add(new CheckBox("freeShipping")); add(new TextField("thumbnail").add(RequiredValidator.getInstance())); add(new TextField("photo").add(RequiredValidator.getInstance ())); //add reset button add(new Button("cancelButton") { public void onSubmit() { setResponsePage(new EditProduct()); } }.setDefaultFormProcessing(false)); //add reset button add(new Button("saveButton") { public void onSubmit() { //save form values, redirect Product product = (Product)getModelObject(); ProductProxy.addProduct(product); setResponsePage(new EditProduct()); } }); } }The cancel button works now but the save button is now throwing an exception:wicket.WicketRuntimeException : Method public abstract void wicket.markup.html.form.IFormSubmitListener.onFormSubmitted () of interface java.lang.reflect.Method threw an exception ..Caused by: java.lang.reflect.InvocationTargetException ..Caused by: wicket.WicketRuntimeException: OGNL Exception: _expression_='saveButton'; path='4:editProductForm:saveButton' ...Caused by: ognl.NoSuchPropertyException: com.myapp.model.Product.saveButton...Here's the form HTML just in case I'm goofing something there: ... What's wrong w/ this?Thanks!On 3/19/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote: the easiest way to do this is add two buttons with two onsubmit handlers instead of using the form's onsubmit. so add(new Button("save") { onsubmit() { // do the saving here } })add(new Button("cancel") { onsubmit() { //navigate away here } }.setDefaultFormProcessing(false)); notice the call to setDefaultFormProcessing(false) on the cancel button. this will tell wicket that when this button is pressed it should not validate/update model instead go directly to the button's onsubmit handler. -IgorOn 3/19/06, Riyad Kalla <[EMAIL PROTECTED]> wrote: Don't you need to commit the response?(just a lame guess from the servlet world)On 3/19/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:> Alright, did that, now the button doesn't do anything at *all*. >> Here's the HTML button:>> >> ...and the event handler:>>> add(new Button("cancelButton") > {> public void onClick()> {> setResponsePage(new Home());> }> });>> Any ideas? >>> On 3/19/06, Justin Lee <[EMAIL PROTECTED]> wrote:> > -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 onCli
Re: [Wicket-user] onSubmit vs onClick for form submission
OK, believe it or not, I did just that and *still* cannot get it to work.Here's my Form class: 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 TextArea("description").add(RequiredValidator.getInstance())); add(new TextField("unitPrice")); add(new TextField("weight")); add(new TextField("height")); add(new TextField("width")); add(new TextField("length")); add(new TextField("insuredValue")); add(new CheckBox("freeShipping")); add(new TextField("thumbnail").add(RequiredValidator.getInstance())); add(new TextField("photo").add(RequiredValidator.getInstance ())); //add reset button add(new Button("cancelButton") { public void onSubmit() { setResponsePage(new EditProduct()); } }.setDefaultFormProcessing(false)); //add reset button add(new Button("saveButton") { public void onSubmit() { //save form values, redirect Product product = (Product)getModelObject(); ProductProxy.addProduct(product); setResponsePage(new EditProduct()); } }); } }The cancel button works now but the save button is now throwing an exception:wicket.WicketRuntimeException: Method public abstract void wicket.markup.html.form.IFormSubmitListener.onFormSubmitted () of interface java.lang.reflect.Method threw an exception ..Caused by: java.lang.reflect.InvocationTargetException ..Caused by: wicket.WicketRuntimeException: OGNL Exception: _expression_='saveButton'; path='4:editProductForm:saveButton' ...Caused by: ognl.NoSuchPropertyException: com.myapp.model.Product.saveButton...Here's the form HTML just in case I'm goofing something there: ... What's wrong w/ this?Thanks!On 3/19/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote: the easiest way to do this is add two buttons with two onsubmit handlers instead of using the form's onsubmit. so add(new Button("save") { onsubmit() { // do the saving here } })add(new Button("cancel") { onsubmit() { //navigate away here } }.setDefaultFormProcessing(false)); notice the call to setDefaultFormProcessing(false) on the cancel button. this will tell wicket that when this button is pressed it should not validate/update model instead go directly to the button's onsubmit handler. -IgorOn 3/19/06, Riyad Kalla <[EMAIL PROTECTED]> wrote: Don't you need to commit the response?(just a lame guess from the servlet world)On 3/19/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:> Alright, did that, now the button doesn't do anything at *all*. >> Here's the HTML button:>> >> ...and the event handler:>>> add(new Button("cancelButton") > {> public void onClick()> {> setResponsePage(new Home());> }> });>> Any ideas? >>> On 3/19/06, Justin Lee <[EMAIL PROTECTED]> wrote:> > -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
Re: [Wicket-user] onSubmit vs onClick for form submission
On Mon, 20 Mar 2006 06:32:23 +0530, Vincent Jenks <[EMAIL PROTECTED]> wrote: and also IDEA plugin ? Funny seeing you here! When are we gonna see Wicket support in MyEclipse buddy? ;) On 3/19/06, Riyad Kalla <[EMAIL PROTECTED]> wrote: Don't you need to commit the response? (just a lame guess from the servlet world) On 3/19/06, Vincent Jenks <[EMAIL PROTECTED]> wrote: > Alright, did that, now the button doesn't do anything at *all*. > > Here's the HTML button: > > > > ...and the event handler: > > > add(new Button("cancelButton") > { > public void onClick() > { > setResponsePage(new Home()); > } > }); > > Any ideas? > > > On 3/19/06, Justin Lee <[EMAIL PROTECTED]> wrote: > > -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 > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > --- 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?cmdlnk&kid0944&bid$1720&dat1642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ --- 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 codi
Re: [Wicket-user] onSubmit vs onClick for form submission
Funny seeing you here! When are we gonna see Wicket support in MyEclipse buddy? ;)On 3/19/06, Riyad Kalla <[EMAIL PROTECTED] > wrote:Don't you need to commit the response?(just a lame guess from the servlet world) On 3/19/06, Vincent Jenks <[EMAIL PROTECTED]> wrote:> Alright, did that, now the button doesn't do anything at *all*.>> Here's the HTML button: >> >> ...and the event handler:>>> add(new Button("cancelButton") > {> public void onClick()> {> setResponsePage(new Home());> }> });>> Any ideas? >>> On 3/19/06, Justin Lee <[EMAIL PROTECTED]> wrote:> > -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> > Wicket-user@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/wicket-user> >>>--- This SF.Net email is sponsored by xPML, a groundbreaking scripting languagethat extends applications into web and mobile media. Attend the live webcastand join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642___ Wicket-user mailing listWicket-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] onSubmit vs onClick for form submission
the easiest way to do this is add two buttons with two onsubmit handlers instead of using the form's onsubmit.so add(new Button("save") { onsubmit() { // do the saving here } })add(new Button("cancel") { onsubmit() { //navigate away here } }.setDefaultFormProcessing(false)); notice the call to setDefaultFormProcessing(false) on the cancel button. this will tell wicket that when this button is pressed it should not validate/update model instead go directly to the button's onsubmit handler. -IgorOn 3/19/06, Riyad Kalla <[EMAIL PROTECTED]> wrote: Don't you need to commit the response?(just a lame guess from the servlet world)On 3/19/06, Vincent Jenks <[EMAIL PROTECTED]> wrote:> Alright, did that, now the button doesn't do anything at *all*. >> Here's the HTML button:>> >> ...and the event handler:>>> add(new Button("cancelButton") > {> public void onClick()> {> setResponsePage(new Home());> }> });>> Any ideas? >>> On 3/19/06, Justin Lee <[EMAIL PROTECTED]> wrote:> > -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> > Wicket-user@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/wicket-user> >>>--- This SF.Net email is sponsored by xPML, a groundbreaking scripting languagethat extends applications into web and mobile media. Attend the live webcastand join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642___ Wicket-user mailing listWicket-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] onSubmit vs onClick for form submission
Don't you need to commit the response? (just a lame guess from the servlet world) On 3/19/06, Vincent Jenks <[EMAIL PROTECTED]> wrote: > Alright, did that, now the button doesn't do anything at *all*. > > Here's the HTML button: > > > > ...and the event handler: > > > add(new Button("cancelButton") > { > public void onClick() > { > setResponsePage(new Home()); > } > }); > > Any ideas? > > > On 3/19/06, Justin Lee <[EMAIL PROTECTED]> wrote: > > -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 > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > --- 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&kid0944&bid$1720&dat1642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] onSubmit vs onClick for form submission
Alright, did that, now the button doesn't do anything at *all*.Here's the HTML button:...and the event handler: add(new Button("cancelButton") { public void onClick() { setResponsePage(new Home()); } }); Any ideas?On 3/19/06, Justin Lee <[EMAIL PROTECTED]> wrote: -BEGIN PGP SIGNED MESSAGE-Hash: RIPEMD160Make 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 Leehttp://www.antwerkz.comAIM : evan chooly 720.299.0101-BEGIN PGP SIGNATURE-Version: GnuPG v1.4.2.1 (Cygwin)iD8DBQFEHc0jJnQfEGuJ90MRA/G9AJ0S8yAzsWWQH802nSef+LS23qNbMACcCWjRSDlWuEAvGEj6mweK4RudZ5U==WtvB-END PGP SIGNATURE- ---This SF.Net email is sponsored by xPML, a groundbreaking scripting languagethat 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 listWicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] onSubmit vs onClick for form submission
-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 Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
[Wicket-user] onSubmit vs onClick for form submission
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!