1 Reply Latest reply on Jan 24, 2008 2:04 AM by nickarls

    Validation messages are inconsistent

    ristretto

      Can anyone explain why I can control the message for @Pattern, but the message for @NotNull is ignored.

      Explanation:

      If I annotate a field on an @Entity with these annotations

      @NotNull(message="field is null")
      @Pattern("^\W$",message="field not valid")
      


      and then reference the entity in a JFS/Facelets page like this

      <h:messages/>
      <h:inputText value="#{entity.name}" required="true">
       <s:validate/>
      </h:inputText>
      


      and then test it, the @NotNull message doesn't doesn't display. I get the default message: {0}: Validation Error: Value is required.

      But, when I test it for the Pattern validation, the @Pattern message DOES display!?

      I haven't tested using a message.properties, and from what I know, we don't have one (though there could be a default one in a jar somewhere that is setup for NotNull but not Pattern.)

      Can anyone clear this up for me?

        • 1. Re: Validation messages are inconsistent
          nickarls

          This is probably because the required=true means that it hits JSF validation first and therefore the message displayed (and the key you want to change) is the JSF one.

          Probably the "javax.faces.component.UIInput.REQUIRED" but do look it up somewhere.