9 Replies Latest reply on Aug 30, 2013 1:08 PM by bleathem

    prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load

    typek_pb

      Hi all,

       

      as described in title:

      I'm running: Richfaces 4.1

      and I'm trying to use rich:notify. It works however I don't want to show all my notifications on page load/reload. How can I prevent it?

      As I inspired myself from the showcase:

      http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=notify&sample=notifyAttributes&skin=blueSky

      where there is the same problem on load/reload.

       

      Any idea?

      Thanks.

       

      pb

        • 1. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
          lfryc

          Hi Peter, could you please describe where you want to show notifications?

           

          You have two options:

           

          • use rich:notifyMessage/-s and use FacesContext.addMessage(FacesMessage)
          • nest rich:notify in a4j:outputPanel and make rich:notify conditionally renderer

           

          e.g.

           

          <a4j:outputPanel ajaxRenderer="true">

                 <a4j:repeat value="#{messages}" var="m" rendered="#{not empty messages}">

                       <rich:notify summary="m" />

                 </a4j:repeat

          </a4j:outputPanel>

           

           

          Nice use case is using Push to render the notification:

           

          <a4j:push>

               <f:ajax render="notification" />

          </a4j:push>

           

          <a4j:outputPanel render="notification">

                 <rich:notify summary="#{message}" rendered="#{not empty message}" />

          </a4j:outputPanel>

           

           

          To determine the rich:notify API change needs, you would need to explain your use case in more detail.

          1 of 1 people found this helpful
          • 2. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
            typek_pb

            Hi Lukas,

             

            thanks a lot for clarification.

            However using FacesMessage is not the case for me, as I have it bound to submit button in the form and in case of creating new FacesMessages it causes these to be shown in the form as a validation result rather then notification.

             

            I might try to go for push, however this seems to be a too big gun for my simple problem.

            • 3. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
              healeyb

              Peter, can you post the code that you're having a problem with? I'm not sure why validation errors should be triggered

              on page load/reload, I'd only expect this to happen with submit.

               

              Regards,

              Brendan.

              • 4. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
                ultrapod

                I'm having the same problem with rich:notify, in that it is always displaying on page load regardless of whether or not I have a message for it to display.  I've hooked it up to an a4j:push component that is working in almost the exact way I want it to, except for displaying on every page load even when there is no message to display.  I've tried conditionally rendering it, but I've had no success.  I'd welcome any insight!!  Here's my mostly working code:

                 

                <a4j:push id="application_push" address="application_push_cdi">
                    <a4j:ajax event="dataavailable" render="application_notify"/>
                </a4j:push>
                
                <a4j:outputPanel id="application_notification_panel">
                    <rich:notifyStack id="application_notification_stack" 
                                        position="topRight" 
                                        direction="vertical" 
                                        method="first">
                        <rich:notify id="application_notify" 
                                        summary="#{TestPushBean.date}" 
                                        detail="#{TestPushBean.message}"/>
                    </rich:notifyStack>
                </a4j:outputPanel>
                

                 

                @Named("TestPushBean")
                @SessionScoped
                public class TestPushBean implements Serializable
                {
                    private static final long serialVersionUID = 8332861070986783051L;
                
                    private static final String CDI_PUSH_TOPIC = "application_push_cdi";
                    private final Logger logger = Logger.getLogger(this.getClass().getName());
                
                    @Inject
                    @Push(topic=CDI_PUSH_TOPIC)
                    private @TestBeanEvent Event<String> pushEvent;
                
                    private String message = "";
                    
                    public void sendMessage(ActionEvent event) 
                    {
                        pushEvent.fire("test message from INSIDE THE HOUSE");
                    }
                
                    public void onSendMessageEvent(@Observes @TestBeanEvent String event)
                    {
                        message = event;
                    }
                   
                    public String getDate()
                    {
                        return new Date().toString();
                    }
                    
                    public String getMessage()
                    {
                        String retval = message;
                        // clear it out
                        message = "";
                        return retval;
                    }
                    
                    public String getRenderName()
                    {
                        return "";
                    }
                    
                    public boolean isMessageToDisplay()
                    {
                        boolean retval = !StringUtils.isEmpty(message);
                        
                        logger.info("isMessageToDisplay: " + retval);
                        
                        return retval;
                    }
                    
                }
                
                • 5. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
                  haseeb

                  Hello,

                  I am also facing the same problem. i want to show notifications on button click like confirmation message rather than on page load. I also understand that i can achieve this by using rich:notifyMessage but the problem is it shows severity level icons and i don't want those. I want simple notification message.

                   

                  Early response will be highly appreciated.

                  • 6. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
                    vyme

                    Hello,

                     

                    although this thread is a little bit older, the problem it describes seems to persists. I've noticed that the showcase example in http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=notify&sample=notifyAttributes&skin=blueSky has the same behavior, due to the fact, that the getDetail() method in the NotifyBean always returns a certain string value. Which is perfectly ok for the example, where there is an initial message. Unfortunately this is not always the desired effect. In my case the initial message is null (or reseted = set to null after it is shown). But then an empty message appears on every page reload. If the "rendered" attribute of the rich:notify / rich:notifyStack is set conditionally, no messages are shown at all. I'm setting the message property through a jsFunction (because I want to pass messages from the client to the rich:notify component). Rendering the notify component conditionally from it ("if message not empty") leads to nothing. An empty message still appears on page reload. How can I prevent rich:notify from doing so?

                    Thank you in advance for replies.

                     

                    (P.S. I'm using Richfaces 4.3.0.Final)

                    • 7. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
                      bleathem

                      To me it sounds like you are asking for a javascript API to control the visibility of the rich:notify notifications?

                       

                      Can you file a feature request in jira describing precisely what you are looking for?

                      • 8. Re: Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
                        vyme

                        Hey Brian,

                         

                        thank you for your reply!

                        What I actually want is that no empty messages are displayed in the rich:notify bubble. Now even if there is no detail message set (explicitly set to null) an empty notify bubble is rendered once at view render time. If I try to conditionally set the render attribute of the rich:notify and try to reRender it when a message is set, then the notify bubble doesn't appear at all. Here is the code:

                        <a4j:jsFunction name="updateNotifyDetail" render="#{masterPageRequestBean.infoMessageExists() ? 'infoNotify' :''}" execute="@this">
                            <a4j:param name="notifyMessage" assignTo="#{masterPageRequestBean.infoMessageDetail}" />
                        </a4j:jsFunction>
                        <rich:notifyStack id="infoStack" position="topRight" direction="vertical" method="last" rendered="true" />
                        <rich:notify id="infoNotify" sticky="false" stack="infoStack" showCloseButton="true" stayTime="5000" escape="false"
                                     showShadow="true" detail="#{masterPageRequestBean.infoMessageDetail}" rendered="#{masterPageRequestBean.infoMessageExists()}" />
                        
                        

                         

                        Maybe I'm using the notify component incorrectly?

                        • 9. Re: prevent rendering of notifications (rich:notify) in Richfaces 4.1 on page re/load
                          bleathem
                          What I actually want is that no empty messages are displayed in the rich:notify bubble.

                           

                          Great - can you file a jira bug report on that?  Then we can start the verification and fix process.

                          See: Submitting effective issue reports