@OnSubmitValidationLogic

This annotation is defined on the Presentation Layer.

Target: Method of a POJO annotated with @StageDefinition.

Description: Marks a method to be executed when a given form is submitted to validate data entered. For custom business rules. This method can be called for server side validations or client side, through an AJAX call. See the form tag component for more details.

JavaDoc: Click here

Attributes:

Name Description Data type Required Default value
value The name of the form to link to the method. String Yes -

Example:

public class LoginStage {
        @ParameterErrors errors;

    // Ties the method to the OnSubmit event of the "myform" form.
    @OnSubmitValidationLogic("myform")
    public void aValidationMethod() {
        // Validation logic that
        errors.discardErrors("someParameter");
        errors.addParameterError("dateOfBirth", new ParameterError(messages.get("dateMustBeInThePast"),
            ParameterErrorType.OTHER));
        ...
    }

    // Ties the method to the OnSubmit event of the "myform" form.
    @OnSubmit("myform")
    public void aMethod() {
        if (!errors.hasErrors())
                ...
    }
}

See also:

Back to annotation reference