4 Replies Latest reply on Feb 6, 2013 7:05 AM by Gonçalo Almeida

    a4j:queue doesn't delay request processing though requestDelay set

    Gonçalo Almeida Newbie

      Hi everyone!

       

      I have the exact same problem as described this issue:

       

      https://issues.jboss.org/browse/RF-9355

       

      but the workaround doesn't fix it.

       

      I have a very simple XHTML page with an ajax event and I want to delay the requests by 5 seconds.

      I'm using <a4j:queue> for achieving it, but the requestDelay parameter is completely ignored.

       

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core" 
          xmlns:ui="http://java.sun.com/jsf/facelets" 
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:s="http://jboss.org/schema/seam/taglib"
          xmlns:p="http://primefaces.org/ui">
          <h:head>
                    <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
          </h:head>
          <h:body>
                    <a4j:queue requestDelay="5000"/>
                    <h:form id="form">
                       <h:inputText id="myinput" value="#{messageComposer.messageTitle}"
                           disabled="#{not (facesContext.maximumSeverity==null)}">
                           <a4j:ajax event="keyup" render="outtext"/>
                       </h:inputText>
                       <h:outputText value="#{messageComposer.messageTitle}" id="outtext" style="font-weight:bold;" />
                    </h:form>
      
                    <a4j:log level="ALL" hotkey="L" popup="false"/>
                  </h:body>
      </ui:composition>
      
      

       

      The Richfaces console log displays a request delay of 0 milliseconds, when it should be the value defined in <a4j:queue>

      a4j_queue.png

       

      I've tried <a4j:attachQueue> under <h:inputText>, override the global queue (<context-param> -> org.richfaces.queue.global.enabled).

       

      Anyone knows why is this happening?

       

      I'm using the followin technologies:

      • JBoss AS 7.1.1
      • Seam 2.3
      • Richfaces 4.2.2.Final
        • 1. Re: a4j:queue doesn't delay request processing though requestDelay set
          Gonçalo Almeida Newbie

          I tried to debug the Ajax call through the Javascript files and found out that the queue options may not being passed to richfaces.queue.js.

           

          I can see that Richfaces is trying to get requestDelay, ignoreDupResponses and other options but these are all undefined, which leads me to think that <a4j:queue> is not applying its attributes to the Ajax call.

           

          Has anyone gone through this problem?

          • 2. Re: a4j:queue doesn't delay request processing though requestDelay set
            Dejan Gunjić Newbie

            I have same problem. Problem is because I am using richfaces and primefaces. When I remove primefaces from my project requestDelay works perfectly.

            1 of 1 people found this helpful
            • 3. Re: a4j:queue doesn't delay request processing though requestDelay set
              Gonçalo Almeida Newbie

              I'm also using Primefaces.

              I'll try to find a way of overcoming this issue. If you find one, please post it here.

              • 4. Re: a4j:queue doesn't delay request processing though requestDelay set
                Gonçalo Almeida Newbie

                I finally came up with a solution, so I'm going to share it.

                 

                I was using Richfaces 4.3.0 and Primefaces 3.4.2 and both have custom renderers for the <head> node. Primefaces adds its CSS and Javascript, while Richfaces adds the queueing stuff (among others).

                When using both at the same time only the Primefaces renderer is called, so my solution was to override it.

                 

                 

                1- First add your custom renderer to your faces-config.xml.

                 

                <faces-config
                     xmlns="http://java.sun.com/xml/ns/javaee"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
                     version="2.0">
                     <render-kit>
                          <renderer>
                               <component-family>javax.faces.Output</component-family>
                               <renderer-type>javax.faces.Head</renderer-type>
                               <renderer-class>com.cardmobili.util.renderers.CardmobiliHeadRenderer</renderer-class>
                          </renderer>
                     </render-kit>
                     <application>
                          <locale-config>
                               <default-locale>en</default-locale>
                               <supported-locale>en</supported-locale>
                               <supported-locale>pt</supported-locale>
                               <supported-locale>nl</supported-locale>
                               <supported-locale>es</supported-locale>
                          </locale-config>
                     </application>
                </faces-config>
                
                

                 

                2- Then create the renderer java class.

                 

                 

                package com.cardmobili.util.renderers;
                  
                import java.io.IOException;
                  
                import javax.faces.component.UIComponent;
                import javax.faces.component.UIOutput;
                import javax.faces.context.FacesContext;
                  
                import org.primefaces.renderkit.HeadRenderer;
                
                public class CardmobiliHeadRenderer extends HeadRenderer {
                  
                          private static final String QUEUE_RESOURCE_COMPONENT_RENDERER_TYPE = "org.richfaces.QueueResourceComponentRenderer";
                    
                          @Override
                          public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
                  
                                    context.getRenderKit().getRenderer(UIOutput.COMPONENT_TYPE, QUEUE_RESOURCE_COMPONENT_RENDERER_TYPE).encodeEnd(context, component);
                                      super.encodeEnd(context, component);
                          }
                  }
                
                

                 

                And that's it. You have your Richfaces queues back