2 Replies Latest reply on Nov 9, 2012 4:00 PM by strannik

    Double notification message

    strannik

      Hi

       

      I would like to display information message upon completing ajax request.

       

      Here is the code

       


      public void addNotificationMessage(String message) {


      FacesContext.getCurrentInstance().addMessage("info", new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));

      }

       

      <a4j:commandButton value="#{msg['buttons.save']}"
      oncomplete="#{adminController.addNotificationMessage('page.saved')}"
      action="#{adminController.savePage(currentPage)}">
      </a4j:commandButton>
      <rich:notifyMessages stayTime="2000" nonblocking="true" />

       

      Everything goes fine except the fact that two notification messages are displayed in the top right corner simultaneously. Is it some programmatic way to display single message?

        • 1. Re: Double notification message
          martam

          Hi

           

          I'm using similar code (the only difference is that I don't use addNotificationMessage method in 'oncomplete', but my message is displayed at the end of the savePage method) and everything works correct - the message is displayed only once.

          Are you sure that you don't have two 'rich:notifyMessage' by accident (eg. the second one is in the template for this page)?

           

          Marta

          • 2. Re: Double notification message
            strannik

            Hi, Marta

             

            Thank you for looking onto that.

             

            What is weird debugger shows that backend method is invoked several times. I changed a bit flow and called my

            notify method the following way. After that only one notification message is shown.

             

            <a4j:ajax event="click"
            listener="#{adminController.addNotificationMessage('page.saved')}"
            />