5 Replies Latest reply on Jan 29, 2010 12:53 AM by asookazian

    Extend Seam-Hibernate validation?

    arw

      Hey all,


      We're using SEAM in a pretty standard setup here ... Jboss/JSF/Richfaces, pretty much the standard seam setup.


      What I'm wondering is if it's possible to extend/communicate with with Seam/Hibernate validator such that I can get a List or something similar of all items which failed the last validation run.


      I know its possible to use the ClassValidator directly but ideally we would like to continue using the normal validation model; just be able to keep track of failed attempts.


      Thanks if anyone has any insight into this.

        • 1. Re: Extend Seam-Hibernate validation?
          dan.j.allen

          If you are performing a persistence operation, you can get the failed validations by catching the Hibernate-specific exception:


          try
          {
              return super.persist();
          }   
          catch (org.hibernate.validator.InvalidStateException ex)
          {
              for (org.hibernate.validator.InvalidValue iv : ex.getInvalidValues())
              {
                  org.jboss.seam.faces.FacesMessages.instance().add(iv.getMessage());
              }   
              
              return "invalid";
          }

          • 2. Re: Extend Seam-Hibernate validation?
            dan.j.allen

            As for multiple error messages per field when using <s:validate>, currently there is no way to print any exception except the first since the validator ignores the others.

            • 3. Re: Extend Seam-Hibernate validation?
              arw

              Thanks for the suggestion Dan but unfortunately at the point where we want to add this functionality we are not persisting anything.


              A bit more info...


              The user enters data into an HTML field, the value is applied to the backing bean onblur; the validators fire at this point and if the validation fails the area is rerendered and the field shows the 'errored state' on the page.


              The idea is that behind the scenes we want to keep track of this failure... we aren't so much concerned with which validation rule failed just that the field in general failed to validate.

              • 4. Re: Extend Seam-Hibernate validation?
                carvo

                Hi,


                any suggestion to this My Link ?!?!



                Thanks,



                Carvo.

                • 5. Re: Extend Seam-Hibernate validation?
                  asookazian

                  al whiting wrote on Apr 20, 2009 19:20:


                  Thanks for the suggestion Dan but unfortunately at the point where we want to add this functionality we are not persisting anything.

                  A bit more info...

                  The user enters data into an HTML field, the value is applied to the backing bean onblur; the validators fire at this point and if the validation fails the area is rerendered and the field shows the 'errored state' on the page.

                  The idea is that behind the scenes we want to keep track of this failure... we aren't so much concerned with which validation rule failed just that the field in general failed to validate.


                  If you are simply trying to count the number of validation error occurrences then maybe you can have a method which persists this data to a DB table by observing a raised event from the code above.