做了七天的动态树,虽然还没有做完但先把一些比较重要的东西记下来。
目前实现了点击节点动态加载树的功能,但点击左侧的箭头相应的事件还没有找到,还是希望有经验的朋友可以指点一二。
<h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
<rich:tree style="width:300px" nodeSelectListener="#{tree1bean.nodeload}" toggleOnClick="true" switchType="ajax" value="#{tree1bean.treeNode}">
</rich:tree>
</h:panelGrid>
以上的toggleOnClick实现了点击节点时展开、关闭树节点。
switchType="ajax"实现了局部刷新,只是树加载的部分刷新,但不重载整个页面。
package org.jboss.test.main;
import java.util.List;
import javax.ejb.Remove;
import javax.faces.event.AbortProcessingException;
import javax.persistence.EntityManager;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.richfaces.component.UITree;
import org.richfaces.event.NodeExpandedEvent;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
@Scope(ScopeType.SESSION)
@Name("tree1bean")
public class Tree1Bean{
private Tree tree;
private TreeNode treenode = null;
private List<Tree> onloadtree;
private List<Tree> onloadtree1;
private String selectnodesql = "from Tree t where t.parentid = ? order by t.id";
private int linkid;
private int flg;
private int parentid;
@In("entityManager")
private EntityManager em;
private void firstNode(int id,TreeNode node){
onloadtree = em.createQuery(selectnodesql).setParameter(1, id).getResultList();
for (int i=0;i<onloadtree.size();i++){
TreeNodeImpl nodeImpl = new TreeNodeImpl();
nodeImpl.setData(onloadtree.get(i).getName());
node.addChild(new Integer(onloadtree.get(i).getId()), nodeImpl);
secondeNode(onloadtree.get(i).getId(),nodeImpl);
}
}
private void secondeNode(int id,TreeNode node){
onloadtree1 = em.createQuery(selectnodesql).setParameter(1, id).getResultList();
for (int i=0;i<onloadtree1.size();i++){
TreeNodeImpl nodeImpl = new TreeNodeImpl();
nodeImpl.setData(onloadtree1.get(i).getName());
node.addChild(new Integer(onloadtree1.get(i).getId()), nodeImpl);
}
}
public TreeNode getTreeNode(){
if (treenode == null){
treenode = new TreeNodeImpl();
parentid = 0;
firstNode(parentid,treenode);
}
return treenode;
}
public void nodeload(NodeSelectedEvent event){
UITree tree = (UITree) event.getComponent();
String sss [] = tree.getRowKey().toString().split(":");
linkid = Integer.parseInt(sss[sss.length-1]);
System.out.println("linkid="+linkid);
tree.clearTreeNodeState();
firstNode(linkid,tree.getModelTreeNode());
}
public int getLinkid() {
return linkid;
}
public void setLinkid1(int linkid) {
this.linkid = linkid;
}
@Remove
public void destroy() {
// TODO Auto-generated method stub
}
}
以上的tree.clearTreeNodeState();实现了收缩节点以后其以后的节点都收缩了回去。回到了初始状态
分享到:
相关推荐
NULL 博文链接:https://yuexiangcheng007-sina-com.iteye.com/blog/444459
这是我用来测试的一个工程,都不能在rich:dataTable中使用action actionListener 博文链接:https://insomniask.iteye.com/blog/111030
主要介绍rich:message标签的使用方法
NULL 博文链接:https://windywindy.iteye.com/blog/413582
页面中r:listShuttle组件一定要指定converter属性值。
虽然资源分高了点,但是下载后你就发现很值了。里面的代码都依依做到了。无论你的数据有多少层,都可以生成一颗树形结构,十分清晰! 不明白加入群:73624154
rich_face 权限Tree 自定义选择
Eclipse Rich Ajax Platform: Bringing Rich Client to the Web Paperback: 148 pages Publisher: Apress; 1 edition (December 29, 2008) Language: English ISBN-10: 1430218835 ISBN-13: 978-1430218838 ...
Filthy Rich Clients: Developing Animated and Graphical Effects for Desktop Java Applications (Part 2)
Rich是一个Python库,用于在终端中提供富文本和精美的格式。 使您可以轻松地向终端输出添加颜色和样式。 Rich还可以直接提供漂亮的表格,进度条,降价,语法突出显示的源代码,回溯等等。 有关Rich的视频介绍,请...
richedit richedit richedit richedit richedit richedit richedit
JSF+rich 实现 fileUpload java代码实现上传文件和图片,代码已经测试过,架包完整,下载后可以直接运行
《Rich Client Programming: Plugging into the NetBeans Platform》电子书
画RICH PICTURE教程 包括规则、画法、原理。适用于软件开发前期客户需求分析。
I-Am-Rich:第一次Swift编程
RichEdit控件显示BMP图片 代码示例: //在RichEdit中图文混排显示资源中位图 void CRichEditTestDlg::OnBnClickedButton1() { // TODO: 在此添加控件通知处理程序代码 ..... } //在RichEdit中显示PNG、JPG、BMP等...
Filthy Rich Clients refers to ultra-graphically rich applications that ooze cool. They suck the user in from the outset and hang on to them with a death grip of excitement. Filthy Rich Clients: ...
利用richfaces的组件显示数据,有效,方便,各位夺下