4 Replies Latest reply on May 30, 2013 5:48 AM by multanis

    render h:commandlink: keeps reloading js

    multanis

      Hi all,

       

      I just faced a strange situation where my page was becoming slower and slower at each performed render. After some investigation it seems the packed.js is reloaded at each render, and so javascript was becoming heavier and heavier to run (to end by a not responsive alter on FF).

       

      After more investigation, I noticed it is due to the h:commandlink tag which was inside my rerendered part.

       

      So I create a small example:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html>
      <html xmlns="http://www.w3.org/1999/xhtml" 
          xmlns:h="http://java.sun.com/jsf/html" 
          xmlns:rich="http://richfaces.org/rich"
          xmlns:a4j="http://richfaces.org/a4j">
          
          <h:head>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
              
              <h:outputScript name="jquery.js"/>
      
              <title>Test Face</title>
          </h:head>
          <h:body>
          
              <h:form prependId="false">
                  <a4j:poll limitRender="true" interval="1000" render="content" status="null" enabled="true"/>
                            
                  <h:panelGroup id="content">
                      <h:commandLink immediate="true" action="#{testFace.action}" title="action">
                          <h:outputText value="edit"/>
                      </h:commandLink>
                  </h:panelGroup>
              </h:form>
          </h:body>
      </html>
      

       

      Running this keeps reloading the packed.js at each poll event. After 10 sec, my FF eats one entire CPU and becomes irresponsive. I also tried to disable the resource optimization with the same behavior (except that jsf.js is reloaded instead of packed.js)

      If I replace the h:commandlink by a a4j:commandlink, the problem disapear.

       

      The problem is the same with any render event, not only with the poll.

       

      So my question is: is that a bug ? If so, is that a JSF one or a richfaces one ?

       

      My conf:

      jsf: 2.1.5-jbossorg-1

      richfaces: 4.2.3.Final

       

      Thanks a lot for your lights !

        • 1. Re: render h:commandlink: keeps reloading js
          multanis

          Actually, this problem is even more annoying than expected because I cannot replace all my h:commandlink by a4j:commandlink:

           

          1. a4j:commandlink has no 'target' attribute

          2.My h:commandlink is used to download file, which doesn't work with a4j:commandlink

           

          Any idea on how to fix this (This is slowing down most of my pages) ?

          • 2. Re: render h:commandlink: keeps reloading js
            multanis

            Hi,

             

            I just tried with new RichFaces version 4.3.2.Final (and so JSF 2.1.19-jbossorg-1) with exactly the same behaviour :-(

             

            Nobody else has the same problem ?

             

            This is really annoying, any workarround will be more than welcome !

             

            Thanks !

            • 3. Re: render h:commandlink: keeps reloading js
              multanis

              Some more info:

               

              1. Using a <f:ajax> to perform the render is not causing the problem
              2. Weirder: If I've a <f:ajax> and a <a4j:commandLink> in my page, the <a4j:commandLink> is not causing the issue anymore
              3. <a4j:commandLink> without <f:ajax> is still causing reloading of js

               

              So it seems to be linked to rich faces, and not jsf.

               

              Code:

               

              Case 1: No problem

               

              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE html>
              <html xmlns="http://www.w3.org/1999/xhtml" 
                  xmlns:h="http://java.sun.com/jsf/html" 
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:f="http://java.sun.com/jsf/core">
                  
                  <h:head>
                      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                      
                      <h:outputScript name="jquery.js"/>
              
                      <title>Test Face</title>
                  </h:head>
                  <h:body>
                  
                      <h:form prependId="false">
                          <h:commandLink immediate="true" title="action" value="hlink">
                              <f:ajax event="click" render="content"/> 
                          </h:commandLink>
                          <br/>
                          <h:panelGroup id="content">
                              <h:commandLink immediate="true" title="action" >
                                  <h:outputText value="edit" />
                              </h:commandLink>
                          </h:panelGroup>
                      </h:form>
                  </h:body>
              </html>
              

               

              Case 2: No problem

               

               

              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE html>
              <html xmlns="http://www.w3.org/1999/xhtml" 
                  xmlns:h="http://java.sun.com/jsf/html" 
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:f="http://java.sun.com/jsf/core">
                  
                  <h:head>
                      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                      
                      <h:outputScript name="jquery.js"/>
              
                      <title>Test Face</title>
                  </h:head>
                  <h:body>
                  
                      <h:form prependId="false">
                          <a4j:commandLink value="a4jlink" render="content" />
                          <br/>
                          <h:commandLink immediate="true" title="action" value="hlink">
                              <f:ajax event="click" render="content"/> 
                          </h:commandLink>
                          <br/>
                          <h:panelGroup id="content">
                              <h:commandLink immediate="true" title="action" >
                                  <h:outputText value="edit" />
                              </h:commandLink>
                          </h:panelGroup>
                      </h:form>
                  </h:body>
              </html>
              

               

               

              Case 3: PROBLEM !

               

               

              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE html>
              <html xmlns="http://www.w3.org/1999/xhtml" 
                  xmlns:h="http://java.sun.com/jsf/html" 
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:f="http://java.sun.com/jsf/core">
                  
                  <h:head>
                      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                      
                      <h:outputScript name="jquery.js"/>
              
                      <title>Test Face</title>
                  </h:head>
                  <h:body>
                  
                      <h:form prependId="false">
                          <a4j:commandLink value="a4jlink" render="content" />
                          <br/>
                          <h:panelGroup id="content">
                              <h:commandLink immediate="true" title="action" >
                                  <h:outputText value="edit" />
                              </h:commandLink>
                          </h:panelGroup>
                      </h:form>
                  </h:body>
              </html>
              
              • 4. Re: render h:commandlink: keeps reloading js
                multanis

                Ok, so I found a nice workarround:

                 

                Adding in all my pages:

                 

                 

                <h:inputText rendered="false">
                <f:ajax />
                </h:inputText>
                

                 

                This fixes the problem.

                 

                However it still sounds like a bug to me, I will add an incident about that

                 

                EDIT:

                 

                Bug added:

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