[jboss-user] [JBoss Seam] - Richfaces Tree

mokua_ombati do-not-reply at jboss.com
Fri Aug 17 08:43:01 EDT 2007


Hi everyone
I have tried using rich-faces tree, but quite frankly
am not able to display a tree.
Note that other rich-faces components are being displayed correctly.
I followed this 
http://www.jboss.com/index.html?op=loginscreen&module=user
 and this http://www.jboss.com/index.html?op=loginscreen&module=user
but still got no-where!

Is there anyone using rich-faces tree?I will greatly appreciate any help.

Environment: 
seam 1.2.1 GA
jboss-4.0.5 GA
richfaces-3.0.1-SNAPSHOT.jar

Here is the Node :

  | package com.triad.treeNodes;
  | 
  | import java.util.Iterator;
  | import java.util.LinkedHashMap;
  | import java.util.Map;
  | 
  | import org.jboss.seam.ScopeType;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Scope;
  | import org.richfaces.component.TreeNode;
  | 
  | @Name("tree")
  | @Scope(ScopeType.PAGE)
  | public class RichTreeNode implements TreeNode {
  | 
  | 	/**
  | 	 * 
  | 	 */
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	// private TreeNode treeNode;
  | 	private String name;
  | 
  | 	private String type;
  | 
  | 	private Map<Object, TreeNode> childrenMap = new LinkedHashMap<Object, TreeNode>();
  | 
  | 	public Object getData() {
  | 		// return treeNode;
  | 		return this;
  | 	}
  | 
  | 	public void setData(Object arg0) {
  | 
  | 	}
  | 
  | 	public boolean isLeaf() {
  | 		return childrenMap.size() == 0;
  | 	}
  | 
  | 	public Iterator getChildren() {
  | 		return childrenMap.entrySet().iterator();
  | 	}
  | 
  | 	public TreeNode getChild(Object identifier) {
  | 		return childrenMap.get(identifier);
  | 	}
  | 
  | 	public void addChild(Object identifier, TreeNode treeNode) {
  | 		childrenMap.put(identifier, treeNode);
  | 
  | 	}
  | 
  | 	public void removeChild(Object arg0) {
  | 		// TODO Auto-generated method stub
  | 
  | 	}
  | 
  | 	public TreeNode getParent() {
  | 
  | 		return null;
  | 
  | 	}
  | 
  | 	public RichTreeNode() {
  | 
  | 		this.name = "parent-node";
  | 		this.type = "root";
  | 
  | 	}
  | 
  | 	public void setParent(TreeNode arg0) {
  | 		// TODO Auto-generated method stub
  | 		
  | 
  | 	}
  | 
  | 	public String getName() {
  | 		return name;
  | 	}
  | 
  | 	public void setName(String name) {
  | 		this.name = name;
  | 	}
  | 
  | 	public String getType() {
  | 		return type;
  | 	}
  | 
  | 	public void setType(String type) {
  | 		this.type = type;
  | 	}
  | 
  | }
  | 


Manager bean:

  | package com.triad.sessionBeans.tree;
  | 
  | import java.io.Serializable;
  | import java.util.Iterator;
  | 
  | import javax.faces.component.UIComponent;
  | import javax.faces.component.html.HtmlOutputText;
  | import javax.faces.component.html.HtmlPanelGrid;
  | import javax.faces.component.html.HtmlPanelGroup;
  | 
  | import javax.faces.context.FacesContext;
  | 
  | import org.jboss.seam.ScopeType;
  | import org.jboss.seam.annotations.Create;
  | import org.jboss.seam.annotations.Logger;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Scope;
  | import org.jboss.seam.log.Log;
  | import org.richfaces.component.html.HtmlPanel;
  | import org.richfaces.component.html.HtmlTree;
  | import org.richfaces.component.html.HtmlTreeNode;
  | 
  | import com.triad.treeNodes.RichTreeNode;
  | 
  | 
  | 
  | @Name("menu")
  | @Scope(ScopeType.SESSION)
  | public class MenuBean implements Serializable{
  | 
  | 	/**
  | 	 * 
  | 	 */
  | 	private static final long serialVersionUID = 1L;
  | 	@Logger
  | 	private Log log;
  | 	
  | 	private RichTreeNode richTree;
  | 	
  | 	@Create
  | 	public void init(){
  | 		log.info("********* init **********************");
  | 		richTree=new RichTreeNode();
  |     	richTree.setName("Ka-Name");
  |     	richTree.setType("root");
  |     	
  |     	log.info("has created the tree==>"+richTree);
  |     	RichTreeNode node1=new RichTreeNode();
  |     	node1.setName("Node 1");
  |     	node1.setType("leaf");
  |     	
  |     	richTree.addChild("node1",node1);
  |     	log.info("the tree with children *********");
  |     	Iterator it=richTree.getChildren();
  |     	while(it.hasNext()){
  |     		log.info("***** the node ==>"+it.next());
  |     	}
  | 	}
  | 	
  |     public RichTreeNode getRichTree() {
  |     	
  |     	
  | 		return richTree;
  | 	}
  | 
  | 
  | 	public void setRichTree(RichTreeNode richTree) {
  | 		this.richTree = richTree;
  | 	}
  | 
  | 
  | 	public MenuBean() {
  |     }
  |     
  |     
  |    
  |       
  | }
  | 

Now display:

  | <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  |                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <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.ajax4jsf.org/rich"
  | 	 xmlns:a="https://ajax4jsf.dev.java.net/ajax"
  | 	template="layout/template.xhtml">
  | 
  | 	<ui:define name="body">
  | 
  | 		<h:messages globalOnly="true" styleClass="message" />
  | 		 
  | 		<rich:panel>
  | 		<h:form >
  | 		 <h:outputText value="Node - Test"/>
  | 		
  | 		<a:outputPanel ajaxRendered="true">
  | 			 <rich:tree id="directoryTree" switchType="ajax"
  |                        value="#{menu.richTree}" var="d"
  |                        style="margin: 10px;width:300px" 
  |                       
  |                        >
  |                 <rich:treeNode>
  |                       <h:outputText value="Node - ** #{d.name}"/>
  |                 </rich:treeNode>
  |         </rich:tree>
  |         </a:outputPanel>
  | 		</h:form>
  | 		</rich:panel>
  | 
  | 
  | 
  | 	</ui:define>
  | </ui:composition>
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4075191#4075191

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4075191



More information about the jboss-user mailing list