Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added another example which uses form's onSubmit() and button's onSubmit()

...

Code Block
html
html
<form ...>
    <input type="submit" wicket:id="okbutton" value="OK" />
    <input type="submit" wicket:id="cancelbutton" value="Cancel" />
</form>

Alternatively, you could use form's onSubmit() method for the submit triggered by OK button and button's onSubmit() method for the submit triggered by the Cancel button.

Code Block

private static class MyForm extends Form {
    public MyForm(String name) {
        super(name);
        add(new Button("okbutton"));
        Button cancel = new Button("cancelbutton"){
            protected void onSubmit() {
                info("Cancel was pressed!");
            }
        };
        cancel.setDefaultFormProcessing(false);
        add(cancel);
    }

    protected void onSubmit() {
        info("OK was pressed!");
    }
}