Param Validation with Annotations.

Splash Forums Rewrite Users Param Validation with Annotations.

This topic contains 1 reply, has 2 voices, and was last updated by  Christian Kaltepoth 2 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26227

    jvr
    Participant

    Hi All,
    I am using the pretty faces annotations with this I would like to validate the query param values.
    My configuration is as follows.
    My Url is /test?issue=24542jsda
    For query param:
    @URLQueryParameter(“issue”)
    @URLValidator(validator=”issuevalidate”)
    Private Integer issue;
    For Validator class:
    @FacesValidator(“issuevalidate “)
    public class IssueValidator implements Validator{

    @Override
    public void validate(FacesContext context, UIComponent component,
    Object obj) throws ValidatorException {
    //………….
    //………..
    FacesMessage message = new FacesMessage();
    message.setDetail(strErrorMsg);
    message.setSummary(“error”);
    message.setSeverity(FacesMessage.SEVERITY_ERROR);
    throw new ValidatorException(message);
    }

    }
    }

    This validation is triggering only when the correct value is given in the url.
    If the user changes in the url for eg: issue is 1 to hgsad like this,
    then the validation should be triggered, but it is not.
    Could any one of you pls help me
    Could you pls provide the detail example for this.

    #26229

    If I remember correctly, PrettyFaces will first try to convert the query parameter value into the required target type before calling the validator. As something like 213gsdfgsd cannot be converted to an integer, the validation fails before your validator is called.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.