4 Replies Latest reply on Jan 20, 2012 10:27 AM by jdessey

    rich:graphValidator message assignment

    jdessey

      When using a <rich:graphValidator>, is there any way to assign a cross-field validation error message to a particular id?  The goal is to be able to define multiple rich:message tags in different locations on the same page, all resulting from a single graphValidator.

       

      A (very) rough example -

       

      on the bean -

      @AssertTrue

      public boolean isValid1(){

      return false}

       

      @AssertTrue

      public boolean isValid2(){

      return false}

       

      on the page -

       

      <rich:graphValidator value="#{gvBean}">

           <rich:message id="message1" for="isValid1" \>

           <rich:message id="message2" for="isValid2" \>

      </rich:graphValidator>

       

      Looking for the ability to associate a message1 with isValid1().  I believe I could accomplish this with multiple graphValidators which each execute a particular group of annotations, but I would rather not introduce that complexity, along with multiple clones of the same object.  Thanks

        • 1. Re: rich:graphValidator message assignment
          iabughosh

          welcome to the community Joseph,

          you can attach your message to rich:graphValidator itself :

           

          <rich:message id="message1" for="validator"/>

          <rich:graphValidator id="validator" value="#{gvBean}">

               .

               .

               .

          </rich:graphValidator>

           

          regards.

          • 2. Re: rich:graphValidator message assignment
            jdessey

            Thanks for the response.  I need to clarify my question though.  For the same graphValidator, I want to use one rich:message tag to indicate a failure for one of the @AssertTrue methods (isValid1), and use another rich:message tag to indicate failure of the other @AssertTrue (isValid2).

            • 3. Re: rich:graphValidator message assignment
              iabughosh

              ok Joseph, you can use the same code from previous reply but use messagese instead of single message, and add a bean validation messages to your bean :

              @AssertTrue(message="valid 1 message")

              public boolean isValid1(){

              return false}

               

              @AssertTrue(message="valid 2 message")

              public boolean isValid2(){

              return false}

               

              regards.

              • 4. Re: rich:graphValidator message assignment
                jdessey

                The issue is that I want to use two separate message tags, which would allow me to place each of them in a different physical location on the page.

                 

                The problem there appears to be that with a graphValidator, all of the resulting messages must be attributed to the graphValidator itself.  So any rich:messages tag would need to represent all of the error messages.