2 Replies Latest reply on Jul 25, 2008 3:21 AM by jan.ziegler

    Strange problems with Richfaces 3.2.2 Snapshot

    jan.ziegler

      Hi there,

      I have some problems with the latest richfaces 3.2.2 snapshot which are in my opinion better adressed to the developer than user community.

      First of all my environment:
      Tomcat 6.0.16
      MyFaces 1.2.3
      Facelets 1.1.15 Snapshot
      Tomahawk 1.1.17 Snapshot
      Richfaces 3.2.2 Snapshot

      Everthing was fine with the early 3.2.2 Snapshots and before. But I need to use one of the latest snapshots because jQuery 1.2.6 (which is necessary for me) is included only in that versions. Right now I have the following problems:

      1) If a use any a4j-component and do not wrap it in an <a4j:region>, the ajax call is not executed correctly (ajaxrequest=null in the request, empty response).

      This is a simple example which sets a beans value via ajax on click of a commandLink and reRenders the output of the beans value:

      <h:form>
       ...
      
       <!-- WORKING (-> wrapped in region) -->
      
       <a4j:region>
      
       <h:outputText id="output" value="#{ajaxBean.text}" />
      
       <a4j:commandLink reRender="output" value="click me!">
       <f:setPropertyActionListener target="#{ajaxBean.text}" value="you clicked the button" />
       </a4j:commandLink>
      
       </a4j:region>
      
      
       <!-- NOT WORKING ANYMORE! -->
      
       <h:outputText id="output" value="#{ajaxBean.text}" />
      
       <a4j:commandLink reRender="output" value="click me!">
       <f:setPropertyActionListener target="#{ajaxBean.text}" value="you clicked the button" />
       </a4j:commandLink>
      
       ...
      
      </h:form>
      



      I always thought that an <a4j:region> is not mandatory and therefor the viewroot is the default region - has this changed?

      2) I have a custom JSF component which has a renderer that includes some javascipt files programmatically by using HtmlLoadScript.
      This was no problem with the early snapshots of 3.2.2 and before but now it's not working anymore. Nothing gets included!
      Here's how I use HtmlLoadScript in the renderer's code:

      public void encodeBegin(FacesContext fc, UIComponent component)
      {
       ...
       UIResource loadScript = new HtmlLoadScript();
       loadScript.setId(fc.getViewRoot().createUniqueId());
       loadScript.setSrc("resource:///org/richfaces/renderkit/html/scripts/jquery/jquery.js"); // or any other js
       component.getChildren().add(loadScript);
       ...
      }
      


      The same problem is with css including by HtmlLoadStyle.
      If I use <a4j:script> or <a4j:style> directly on the xhtml-page there's no problem. but I want the component or better the component's renderer to handle this.

      I realized on thing - maybe this helps for debugging: the javascript and css files are included by the way explained above when I do a "reRender" with my custom component triggert by some ajax action. Then everthing is fine and the ajax reponse contains the javascipt and css references but it's not a solution to first reRender each component of course.

      So any suggestions or comments are welcome,

      thanks
      Jan Z.


        • 1. Re: Strange problems with Richfaces 3.2.2 Snapshot
          jan.ziegler

          and I also realized a third problem:

          It seems that <rich:jQuery> (with the new Version 1.2.6) does not play together with <rich:suggestionBox>.

          I tested with this code:

          ...
          
          <!-- jQuery for showing an alert when clicking on a div -->
          <div class="test">click me!</div>
          <rich:jQuery selector="div.test" timing="onload" query="click(function(){alert('you clicked the div!')})" />
          
          <!-- suggestion box -->
          <h:form>
          
           <h:inputText value="#{testBean.searchString}" id="normalStringSearch" />
          
           <!-- without a4j:region nothing happens at all (see first post!) -->
           <a4j:region>
           <rich:suggestionbox for="normalStringSearch" minChars="2" suggestionAction="#{testBean.autocomplete}" var="elements" >
           <h:column>
           <h:outputText value="#{elements}" />
           </h:column>
           </rich:suggestionbox>
           </a4j:region>
          
          </h:form>
          ...
          


          If i comment out the suggestion box the jQuery stuff works, otherwise not!

          In combination with my whole site (and more components) I get a stange firefox exception:

          [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMViewCSS.getComputedStyle]"
          nsresult: "0x80004005 (NS_ERROR_FAILURE)"
          location: "JS frame :: http://localhost:8080/test/a4j_3_2_2-SNAPSHOTorg/richfaces/renderkit/html/scripts/jquery/jquery.js.faces :: anonymous :: line 96" data: no]
          http://localhost:8080/test/a4j_3_2_2-SNAPSHOTorg.ajax4jsf.javascript.AjaxScript.faces
          Line 192
          


          also, I had no problems with my site with the early 3.2.2 snapshots...