rich:tree with recursiveTreeNodesAdaptor
jmoreira Apr 15, 2008 7:18 PMhi,
i'm trying to implement a rich:tree with recursiveTreeNodesAdaptor and i've read through all of the examples and cant figure what's wrong.
Environment is Seam 2.0.2CR1, JBoss 4.2 and RichFaces 3.1.4 I have seen examples where there was no need for writing TreeModel/Node adaptor.
The control is for selecting a category from a simple adjacency list object tree (parent, children) to assign to a item.
The model is correct as i have testng tests and the seam components get initialized correctly, all the controls appear except the tree itself.
Do i miss anything?
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" xmlns:a="https://ajax4jsf.dev.java.net/ajax" template="layout/template.xhtml" > <rich:tree style="width:300px; height: 200px; border: 1px solid red;" switchType="ajax"> <rich:recursiveTreeNodesAdaptor roots="#{rootCategories}" var="cat" nodes="#{cat.children}"> <rich:treeNode>#{cat.name}</rich:treeNode> </rich:recursiveTreeNodesAdaptor> </rich:tree> </ui:composition>
@Entity @Table(name = "T_CATEGORY") public class Category extends BaseBean implements Serializable { /** * */ private static final long serialVersionUID = 1L; /** * */ private Long id; /** * */ private String name; /** * */ private Category parent; /** * */ private Set<Category> children = new HashSet<Category>(); /** * */ private Set<Item> items = new HashSet<Item>(); /** * * @return */ @Id @GeneratedValue @Column(name = "CATEGORY_ID") public Long getId() { return id; } /** * * @param id */ public void setId(Long id) { this.id = id; } /** * * @return */ @Column(name = "CATEGORY_NAME", length = 255, nullable = false) @NotNull public String getName() { return name; } /** * * @param name */ public void setName(String name) { this.name = name; } /** * * @return */ @ManyToOne @JoinColumn(name = "FK_PARENT_CATEGORY_ID", nullable = true) public Category getParent() { return parent; } /** * * @param parent */ public void setParent(Category parent) { this.parent = parent; } /** * * @return */ @OneToMany(mappedBy = "category", fetch = FetchType.LAZY) public Set<Item> getItems() { return items; } /** * * @param items */ public void setItems(Set<Item> items) { this.items = items; } /** * @return the children */ @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY) public Set<Category> getChildren() { return children; } /** * @param children * the children to set */ public void setChildren(Set<Category> children) { this.children = children; } }
/** * @author josemoreira * */ @Name("categoryHome") public class CategoryHome extends EntityHome<Category> { @In CategoryDAO categoryDAO; private List<Category> rootCategories; @Factory("rootCategories") public void initRootCategories() { rootCategories = categoryDAO.getRootCategories(); } }