6 Replies Latest reply on Apr 2, 2009 5:12 AM by iimirela

    Error handling with richfaces

    iimirela

      Hello,

      I'd like to manage errors using the modalPanel. I'm using richfaces 3.3.0, templates, and I'd like to achieve the following: whenever there is an error (like.. wrong format in user input, but also oracle errors when saving/deleting) to show the message error in a modal panel.

      Any suggestions?

      Thanks,
      Ioana.

        • 1. Re: Error handling with richfaces
          ilya_shaikovsky

          1) surround the modal panel with a4j:outputPanel with ajaxRendered=true
          2) define showWhenRendered="not facesContext.maximumSeverity==null" on the modal
          3) place rich:messages inside.
          4) include to your main template.

           <a4j:outputPanel ajaxRendered="true">
           <rich:modalPanel showWhenRendered="#{not (facesContext.maximumSeverity==null)}">
           <rich:messages passedLabel="Data is allowed to be stored." layout="list">
           <f:facet name="header">
           <h:outputText value="Entered Data Status:"></h:outputText>
           </f:facet>
           <f:facet name="passedMarker">
           <h:graphicImage value="/images/ajax/passed.gif" />
           </f:facet>
           <f:facet name="errorMarker">
           <h:graphicImage value="/images/ajax/error.gif" />
           </f:facet>
           </rich:messages>
           </rich:modalPanel>
           </a4j:outputPanel>
          


          • 2. Re: Error handling with richfaces
            iimirela

            Beautiful. Now of, course, depending on the page, I have different types of errors, and different messages. Should I use a binding? Can I set the message?

            THanks

            • 3. Re: Error handling with richfaces
              nbelaevski

               

              Should I use a binding?
              Please clarify what binding are you referring to?

              Can I set the message?
              Messages are customized at component producing messages (e.g. using requiredMessage attribute) or at application level using message bundle. rich:messages just displays them.

              • 4. Re: Error handling with richfaces
                iimirela

                Right. I want to customize messages at application level, using messages bundle. How can I do that?

                P.S: I meant a binding to the messages component... to set the message? Obviously I'm new in jsf :(

                • 5. Re: Error handling with richfaces
                  nbelaevski

                  Please take a look: http://www.ibm.com/developerworks/library/j-jsf3/ or consult JSF specification documents.

                  Binding is not required unless you want to create/modify component programmatically.

                  • 6. Re: Error handling with richfaces
                    iimirela

                    Thank you very much. Very interesting and helpful article.