2 Replies Latest reply on Mar 1, 2006 11:49 PM by Andrew

    Proposal for new functionality on ValidationInterceptor

    Andrew Apprentice

      I would be great if the "ifInvalid" interceptor annotation could take a severity so that it would not default to FacesMessage.INFO. I would rather have hibernate validation issues as error.

      Here is a patch to IfInvalid.java:

      Index: IfInvalid.java
      ===================================================================
      RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/annotations/IfInvalid.java,v
      retrieving revision 1.6
      diff -r1.6 IfInvalid.java
      10a11,12
      > import javax.faces.application.FacesMessage;
      >
      36a39,43
      > * The string value of the {@link FacesMessage.Severity FacesMessage.Severity} value.
      > * Defaults to "Info".
      > */
      > String severity() default "Info";
      > /**
      


      Here is a patch to ValidationInterceptor:
      ===================================================================
      RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/interceptors/ValidationInterceptor.java,v
      retrieving revision 1.10
      diff -r1.10 ValidationInterceptor.java
      58c58
      < addMessageToFacesContext(iv);
      ---
      > addMessageToFacesContext(iv, ifInvalid.severity());
      89c89
      < private void addMessageToFacesContext(InvalidValue iv)
      ---
      > private void addMessageToFacesContext(InvalidValue iv, String severity)
      94c94,97
      < facesContext.addMessage( clientId, new FacesMessage( iv.getMessage() ) );
      ---
      > FacesMessage msg = new FacesMessage();
      > msg.setSummary(iv.getMessage());
      > msg.setSeverity((FacesMessage.Severity)FacesMessage.VALUES_MAP.get(severity));
      > facesContext.addMessage( clientId, msg );