5 Replies Latest reply on May 17, 2011 9:12 AM by ssamayoagt

    Richfaces messages

    fbarboza

      Greetings,

       

      I would like to do something like the growl effect from Primefaces but using rich:messages.

      Everytime that I show some message, I would like that the message disappear after sometime.

       

      Ex: the user click on the save button, he/she recieves the message "User successfully saved!" and 5 seconds later the message disapear.

       

      Does anyone made something like this using rich:messages?

       

      Regards,

       

      Fábio

        • 1. Re: Richfaces messages
          ssamayoagt

          Something like this?

           

          <html xmlns="http://www.w3.org/1999/xhtml"

                    xmlns:h="http://java.sun.com/jsf/html"

                    xmlns:a4j="http://richfaces.org/a4j"

                    xmlns:rich="http://richfaces.org/rich"

                    xmlns:f="http://java.sun.com/jsf/core"

                    xmlns:ui="http://java.sun.com/jsf/facelets">

           

           

          <h:head>

                    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

                    <meta http-equiv="pragma" content="no-cache" />

                    <meta http-equiv="cache-control" content="no-cache" />

                    <meta http-equiv="expires" content="-1" />

                    <script type="javascript">

                    function timeOut() {

                                   var m = document.getElementById("f1:ms");

                 m.style.cssText = "display:none;"

                    }

                    function startTimer() {

                                   var t = setTimeout("timeOut()", 5000);

                    }

                    </script>

          </h:head>

          <h:body>

                    <rich:panel>

                              <h:form id="f1">

                                        <a4j:commandButton value="Save" action="#{test2.save()}" oncomplete="startTimer();" />

                                        <rich:messages id="ms" globalOnly="true" />

                              </h:form>

                    </rich:panel>

          </h:body>

          </html>

           

          @Named

          @SessionScoped

          public class Test2 implements Serializable {

           

             public void save() {

                                   FacesContext.getCurrentInstance().addMessage(null,

                                                            new FacesMessage(FacesMessage.SEVERITY_INFO, "Saved", "Saved"));

                    }

          }

          • 2. Re: Richfaces messages
            fbarboza

            Exactly!

            Thank you very much my friend!

            • 3. Re: Richfaces messages
              ssamayoagt

              You wellcome.

               

              Note that I just tested in IE 8 and didn't work, it complained about some RF or JSF js code.

               

              Regards.

              • 4. Richfaces messages
                blabno
                • 5. Richfaces messages
                  ssamayoagt

                  Very nice!

                  Thanks for the info.

                  Regards.