6 Replies Latest reply on Jul 31, 2009 3:33 PM by israel.bgf

    Hibernate Validator {0}

    israel.bgf

      I'm trying to use the {0} in my bundles, to put the parameter on my components with the label attribute, but it's not working.


      Bundle:


      validator.notEmpty={0} : não pode ser nulo ou vazio 



      Component:


      <h:inputText id="nomeEstado" styleClass="input medium_field" value="#{manterEstado.estado.nome}" label="Nome"/>
      



      The message show is:



      {0} : não pode ser nulo ou vazio

      What am I missing?


      I'm using JBoss 4.2.3, and the Hibernate Validator is the default one that come with the server.

        • 1. Re: Hibernate Validator {0}
          asookazian

          from SiA:


          registration.welcome=Welcome to the club, {0}!
          
          facesMessages.addFromResourceBundle("registration.welcome",
          newGolfer.getName());



          HTH


          sorry, the spanish or portugese throws me off...

          • 2. Re: Hibernate Validator {0}
            israel.bgf

            That's not the case Arbi. The problem is when trying to override the default Hibernate Validator messages.


            From Seam Reference Chapter 10:


            <h:inputText value="#{location.zip}" required="true" label="Zip:">
            
                <s:validate/>
            
            </h:inputText>
            



            You can then inject this value into the message string using the placeholder {0} (the first and only parameter passed to a JSF message for a Hiberate Validator restriction).



            validator.length={0} length must be between {min} and {max}



            I'm trying to do the same thing that the reference does, and it's not working.

            • 3. Re: Hibernate Validator {0}
              asookazian

              So you have @Range or @Max and @Min specified on your entity methods?


              http://docs.jboss.org/hibernate/stable/validator/reference/en/html/validator-defineconstraints.html#validator-defineconstraints-builtin


              I don't quite understand this:


              You can then inject this value into the message string using the placeholder {0} (the first
              and only parameter passed to a JSF message for a Hiberate Validator restriction).



              There is no code/example but perhaps it has to do with FacesMessages?  Did you look in SiA or Yuan book?

              • 4. Re: Hibernate Validator {0}
                israel.bgf

                Yes i put the annotations in my attributes. The problem is, when using the placeholder {0} in the message bundle, i should be able to replace it with the label attribute of an input component. Example:


                class Person
                
                @Length(min = 1, max = 10)
                String name;
                



                <h:inputText value="#{person.name} label="Name"/>
                



                validator.length={0} length must be between {min} and {max}
                



                The validation message (automatically triggered in the JSF validation phase) should be somethig like:



                Name length must be between 1 and 10

                And i'm getting:



                {0} length must be between 1 and 10



                • 5. Re: Hibernate Validator {0}
                  joblini

                  Hello Isreal,


                  Should work, see JBSEAM-3438


                  What version of Seam are you using?  Check the source code to be sure the patch is included.


                  Regards, Ingo

                  • 6. Re: Hibernate Validator {0}
                    israel.bgf

                    2.1.1, the patch should be here. But well.. i found the possible problem, i'm using the rich:graphValidator not the s:validateAll, maybe that's the problem. I tried to use the s:validateAll to test it, but it not worked; the validations errors don't get triggered in the JSF validation phase. Strange. Anyway, I will ask the richfaces guys about this, maybe the seam component that makes it possible. Thks ingo.