1 Reply Latest reply on Mar 1, 2011 9:11 PM by Todd Sproule

    Global Message when field level validation fails

    Tom Goring Apprentice

      Hi,


      I have a seam app that works great !


      I'd like advise on the best way to add a global message when any field level validation happens.
      E.g. Update Failed: Some fields in your form are in error (see below)


      Currently in may pages I use


       <h:messages globalOnly="true" styleClass="message"/> 



      for global messages and


       <s:decorate..> 



      for field level validation.


      Ideas ?


      Thanks


      Tom

        • 1. Re: Global Message when field level validation fails
          Todd Sproule Newbie

          You can observe event 'org.jboss.seam.validationFailed'


               


          @Observer("org.jboss.seam.validationFailed")
          public void addFailMessage() {
              facesMessages.add("Update Failed: Some fields in your form are in error (see below)");
          }





          Or you could perform some conditional page actions in pages.xml based on org.jboss.seam.faces.Validation


          e.g.




          <page view-id="/widget.xhtml"  login-required="true">     
                <action execute="#{actiontoaddmessage}" if="#{validation.failed}"/>
          </page>



          Remember you'll need to rerender the <h:messages/> if you have ajax behaviour on individual fields.


          Hope this helps.


          Todd