DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
| Code Block |
|---|
new Button("submit").setDefaultFormProcessing(false);
|
Validating just the button-press
Simply add a validator to the button which checks if it was pressed:
| Code Block |
|---|
button.add(new IValidator<String>() {
@Override
public void validate(IValidatable<String> validatable) {
if (button.getForm().findSubmittingButton() == button) {
// ... do your test here
if (errorFound) {
ValidationError error = new ValidationError().addMessageKey("errorFound_button");
error.setVariables(Collections.singletonMap("parameter", (Object) "value"));
validatable.error(error);
}
}
}
});
|
Alternative Approach
Another approach to enabling validation based on which submit button was used is to take over the form processing workflow as follows.
...