0 Replies Latest reply on Jul 4, 2008 6:51 PM by José Moreira

    inconvertible types found with Richfaces UITree

    José Moreira Newbie

      i'm getting an compile time error setting up a Tree:


      - Richfaces deploy with this seam version and tried with richfaces-ui-3.2.1.GA also
      - jboss-seam-2.0.2.SP1



      Error  inconvertible types found   : javax.faces.component.UIComponent required: org.richfaces.component.UITree



      CategoryHome.java


      
      import org.jboss.seam.annotations.Factory;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.datamodel.DataModel;
      import org.jboss.seam.framework.EntityHome;
      import org.jboss.seam.log.Log;
      
      import java.util.ArrayList;
      import java.util.Collections;
      import java.util.List;
      
      
      import org.richfaces.component.UITree;
      import org.richfaces.event.NodeSelectedEvent;
      
      import org.richfaces.model.TreeNode;
      import org.richfaces.model.TreeNodeImpl;
      
      @Name("categoryHome")
      public class CategoryHome extends EntityHome<Category> {
      
          /**
           * 
           */
          private static final long serialVersionUID = 1L;
      
          private Long catid;
      
          @Logger
          Log log;
      
          @DataModel
          public List<Category> categoryList;
      
          @DataModel
          public List<Category> categoryBreadcrumList;
      
          /**
           * 
           */
          @Factory("categoryList")
          public void initTypificationList() {
              if (getCatid() == null) {
                  categoryList = new ArrayList<Category>(findRootCategories());
              } else {
                  categoryList = new ArrayList<Category>(findCategoryChildren(getCatid()));
              }
          }
      
          /**
           * Breadcrumb
           */
          @Factory("categoryBreadcrumList")
          public void initCategoryBreadcrumList() {
              if (getCatid() != null) {
                  categoryBreadcrumList = findCategoryBreadCrumb(getCatid());
              } else {
                  categoryBreadcrumList = new ArrayList<Category>();
              }
          }
      
          /**
           * 
           * @return
           */
          public List<Category> findRootCategories() {
              log.info("finding roots");
              List<Category> results = getEntityManager().createQuery("from Category c where c.parent is null").getResultList();
              return results;
          }
      
          /**
           * 
           * @return
           */
          public List<Category> findCategoryChildren(Long id) {
              log.info("finding children of <" + id + ">");
              List<Category> results = getEntityManager().createQuery("from Category c where c.parent.id=:id").setParameter("id", id).getResultList();
              return results;
          }
      
          /**
           * 
           * @param id
           * @return
           */
          public List<Category> findCategoryBreadCrumb(Long id) {
              List<Category> results = new ArrayList<Category>();
              Category t = findByID(id);
              if (t != null) {
                  results.add(t);
                  while (t.getParent() != null) {
                      t = findByID(t.getParent().getId());
                      if (t != null) {
                          results.add(t);
                      }
                  }
              }
              Collections.reverse(results);
              return results;
          }
      
          /**
           * 
           * @param id
           * @return
           */
          public Category findByID(Long id) {
              return getEntityManager().find(Category.class, id);
          }
      
          /**
           * @return the tid
           */
          public Long getCatid() {
              return catid;
          }
      
          /**
           * @param tid the tid to set
           */
          public void setCatid(Long tid) {
              this.catid = tid;
          }
          // --------------- Tree ui
          private TreeNode rootNode = null;
      
          private String nodeTitle;
      
          /**
           * 
           */
          private void loadTree() {
              List<Category> roots = findRootCategories();
              rootNode = new TreeNodeImpl();
              for (Category category : roots) {
                  addNodes(rootNode, category);
              }
          }
      
          /**
           * 
           * @param node
           * @param category
           */
          private void addNodes(TreeNode node, Category category) {
              TreeNodeImpl nodeImpl = new TreeNodeImpl();
              nodeImpl.setData(category.getName());
              node.addChild(category.getId(), nodeImpl);
          }
      
          /**
           * 
           * @return
           */
          public TreeNode getTreeNode() {
              if (rootNode == null) {
                  loadTree();
              }
      
              return rootNode;
          }
      
          public void processSelection(NodeSelectedEvent event) {
              UITree tree = (UITree) event.getComponent();
              nodeTitle = (String) tree.getRowData();
          }
      
          public String getNodeTitle() {
              return nodeTitle;
          }
      
          public void setNodeTitle(String nodeTitle) {
              this.nodeTitle = nodeTitle;
          }
      }
      


      any ideas?


      thanks