3 Replies Latest reply on Feb 25, 2010 7:27 PM by Juan Carlos Barragán Quintero

    IllegalArgumentException when expanding tree

    Juan Carlos Barragán Quintero Newbie

      Hi Friends:

       

      I get the following error when I try to follow the example in the documentation. I really would appreciate any help because this is a project for work.

       

      Juan C.

       

      --------------------------------------------

      HTTP Status 500 -


      type Exception report

      message

      descriptionThe  server encountered an internal error () that prevented it from  fulfilling this request.

      exception

      javax.servlet.ServletException: In AbstractTreeDataModel rowIndex must be -1.

      root  cause

      java.lang.IllegalArgumentException: In AbstractTreeDataModel rowIndex must be -1.

      --------------------------------------------

      Index.jxp

      <!doctype html public "-//w3c//dtd html 4.0 transitional//en">

      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <!-- RichFaces tag library declaration -->
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>



      <html>
          <head>
              <title>RichFaces Greeter</title>
          </head>
          <body>
              <f:view>
                  <a4j:form>
                      <rich:panel header="RichFaces Greeter" style="width: 315px">

                          <h:panelGroup>
                              <rich:tree value="#{tree.stationNodes}" var="station">
                                  <rich:treeNode>
                                      <h:outputText value="#{station}" />
                                  </rich:treeNode>
                              </rich:tree>
                          </h:panelGroup>
                      </rich:panel>
                  </a4j:form>
              </f:view>
          </body>

      </html>

      --------------------------------------------
      Tree.java

      package demo;

      import org.richfaces.model.TreeNodeImpl;

      public class Tree {

          private TreeNodeImpl<String> stationRoot = new TreeNodeImpl<String>();
          private TreeNodeImpl<String> stationNodes = new TreeNodeImpl<String>();
          private String[] kickRadioFeed = {"Hall & Oates - Kiss On My List",
              "David Bowie - Let's Dance", "Lyn Collins - Think (About It)",
              "Kim Carnes - Bette Davis Eyes",
              "KC & the Sunshine Band - Give It Up"};

          public Tree() {
              stationRoot.setData("KickRadio");
              stationNodes.addChild(0, stationRoot);

              for (int i = 0; i < kickRadioFeed.length; i++) {
                  TreeNodeImpl<String> child = new TreeNodeImpl<String>();
                  child.setData(kickRadioFeed[i]);
                  stationRoot.addChild(i, child);
              }

          }

          public TreeNodeImpl<String> getStationNodes() {
              return stationNodes;
          }

          public void setStationNodes(TreeNodeImpl<String> stationNodes) {
              this.stationNodes = stationNodes;
          }
      }

      --------------------------------------------
      faces-config.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <faces-config version="1.2"
                    xmlns="http://java.sun.com/xml/ns/javaee"
                    xmlns:xi="http://www.w3.org/2001/XInclude"
                    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_1_2.xsd">


          <managed-bean>
              <description>Tree Bean</description>
              <managed-bean-name>tree</managed-bean-name>
              <managed-bean-class>demo.Tree</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
          </managed-bean>
      </faces-config>


      --------------------------------------------
      Libraries

      commons-beanutils-1.8.0.jar
      commons-collections-3.2.jar
      commons-digester-1.8.1.jar
      commons-logging-1.0.4.jar
      jhighlight-1.0.jar
      log4j-1.2.14.jar
      richfaces-api-3.3.3.CR1.jar
      richfaces-impl-3.3.3.CR1.ja
      richfaces-ui-3.3.3.CR1.jar