2 Replies Latest reply on Nov 18, 2011 5:42 PM by rafaeltscs

    Richfaces tree is giving me an “Uncaught ReferenceError tree is not defined”

    dale12

      I believe my problem is in a settings file somewhere, but I have no idea what file/setting that would be. I have a standalone project with a working tree, but when I try to integrate it with my real project I start getting the mentioned error. That's what makes me think I have a setting somewhere that's off. I'm using JSF1.2 and richfaces 3.3.3. Here's my JSP file.

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <%-- jsf:pagecode language="java" location="/src/java/pagecode/agencyMappingPages/mapping/Mapping.java" --%><%-- /jsf:pagecode --%>
      <%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
      <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
      <%@taglib prefix="rich" uri="http://richfaces.org/rich"%>
      <html>
         
      <f:view>
             
      <body>
                 
      <rich:tree switchType="client" value="#{mappingBean.nodes}" var="node">
                 
      </rich:tree>
             
      </body>
         
      </f:view>
      </html>

      Here's my bean code:

      public TreeNode<String> getNodes() {
         
      TreeNodeImpl<String> nodes = new TreeNodeImpl<String>();
         
      TreeNodeImpl<String> root = new TreeNodeImpl<String>();
          root
      .setData("Test Tree Root");
          nodes
      .addChild(0, root);

         
      return nodes;
      }

      I'm using the following jars. These are also the three jars I'm using in the functioning version of my tree.

      richfaces-api-3.3.3.Final.Jar
      richfaces
      -impl-3.3.3.Final.Jar
      richfaces
      -ui-3.3.3.Final.Jar

      I've got the following in my web.xml file.

      <filter> 
        
      <display-name>RichFaces Filter</display-name>
        
      <filter-name>richfaces</filter-name>
        
      <filter-class>org.ajax4jsf.Filter</filter-class>
      </filter>
      <filter-mapping>
        
      <filter-name>richfaces</filter-name>
        
      <servlet-name>Faces Servlet</servlet-name>
        
      <dispatcher>REQUEST</dispatcher>
        
      <dispatcher>FORWARD</dispatcher>
        
      <dispatcher>INCLUDE</dispatcher>
      </filter-mapping>
      <servlet>
         
      <servlet-name>Faces Servlet</servlet-name>
         
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
         
      <load-on-startup>-1</load-on-startup>
      </servlet>
      <servlet>
         
      <servlet-name>JavaScript Resource Servlet</servlet-name>
         
      <servlet-class>com.ibm.faces.webapp.JSResourceServlet</servlet-class>
         
      <load-on-startup>-1</load-on-startup>
      </servlet>
      <servlet>
         
      <servlet-name>Tiles2Servet</servlet-name>
         
      <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
         
      <init-param>
             
      <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
             
      <param-value>/WEB-INF/tiles20-defs.xml</param-value>
         
      </init-param>
         
      <load-on-startup>2</load-on-startup>
      </servlet>
      <servlet-mapping>
         
      <servlet-name>Faces Servlet</servlet-name>
         
      <url-pattern>*.faces</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
         
      <servlet-name>Faces Servlet</servlet-name>
         
      <url-pattern>/faces/*</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
         
      <servlet-name>JavaScript Resource Servlet</servlet-name>
         
      <url-pattern>/.ibmjsfres/*</url-pattern>
      </servlet-mapping>
      <welcome-file-list>
         
      <welcome-file>index.html</welcome-file>
         
      <welcome-file>index.htm</welcome-file>
         
      <welcome-file>index.jsp</welcome-file>
         
      <welcome-file>default.html</welcome-file>
         
      <welcome-file>default.htm</welcome-file>
         
      <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>

      Not sure if this'll be helpful, but here's the javascript it chokes on. I had to omit quite a bit because the form wouldn't submit. I copied this from Chrome's developers window. It throws the exception at the second line: var tree = new tree......

      <script type="text/javascript">(function() {
      var tree = new Tree("j_id_jsp_1558828084_1", "j_id_jsp_1558828084_1:input", "client",
          {
          onselect: "",
          onexpand: "",
          oncollapse: "",
          oncontextmenu: ""
      },
      function(event) {var params = {'j_id_jsp_1558828084_1:selectedNode':event.selectedNode} ;
      if (!params.ajaxSingle && event.ajaxSingle) {
      params.ajaxSingle = event.ajaxSingle;
      }

      So, what necessary file/setting am I missing? I'm sure I'm forgetting the most important piece of info which is why I need you. Thanks, Dale