I understand that Wicket automatically handles the assignment of user entered values to model entries on submit. In the example of having an okay and cancel button, how would you prevent this behaviour when the cancel button has been pressed. I would like the example to be expanded with a TextField on the form that would on okay change the model (which could be made visible with a label, like the HelloWorld example) but on cancel would not.


Some observation I have made about the button processing with IE. First off, don't use <button> tag since all the button will always call the same method. Secondly, when using <input>, you have to add to your form the method onSubmit. When you will it enter in the middle of the form, it will simply call the onSubmit of the form, not the one of the default button of your form. I hope it will help some people to debug their application since IE don't react like firefox.

Here is a the code I place in the form if I want IE and firefox to do the samething. It will also add some indication for the comment seen before me

private class TempForm extends Form { String _name; TempForm(String id) { super(id); add(new Label("LBL_name", "Name : ")); add (new RequiredTextField ("name", new PropertyModel(this, "name"))); add(new Button("submit")); Button cancelBtn = new Button("cancel"){ public void onSubmit() { System.out.println("*********************************"); System.out.println("Cancel Button"); System.out.println("*********************************"); } }; this.setDefaultButton (submitBtn); cancelBtn.setDefaultFormProcessing (false); add(cancelBtn); } protected void onSubmit() { System.out.println("*********************************"); System.out.println("Name entered is :" + _name); System.out.println("Submit Button"); System.out.println("*********************************"); } public String getName(){ return _name; } public void setName(String name) { _name= name; } }
  • No labels