前台Tree.zul

<?page title="Tree使用" contentType="text/html;charset=UTF-8"?>
<zk xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.zkoss.org/2005/zul"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul">
<window title="" border="normal" apply="test.treeCtrl">
<tree id="tree" pageSize="10" mold="paging" rows="10" >
<treecols>
<treecol label="Name"/>
<treecol label="Description"/>
</treecols>
<treefoot>
<treefooter label="底部"/>
</treefoot>
</tree>
</window>
</zk>

后台treeCtrl.java:

package test;

import java.util.ArrayList;
import java.util.List; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericAutowireComposer;
import org.zkoss.zul.DefaultTreeModel;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Tree;
import org.zkoss.zul.Treecell;
import org.zkoss.zul.Treeitem;
import org.zkoss.zul.TreeitemRenderer;
import org.zkoss.zul.Treerow; public class treeCtrl extends GenericAutowireComposer<Component>{ private static final long serialVersionUID = 1L;
private Tree tree; @Override
public void doAfterCompose(Component comp) throws Exception {
// TODO Auto-generated method stub super.doAfterCompose(comp); DefaultTreeModel<FileInfo> model = new DefaultTreeModel<FileInfo>(getFileInfoTreeData());
tree.setModel(model);
tree.setItemRenderer(new FileInfoRenderer());
} private DefaultTreeNode<FileInfo> getFileInfoTreeData() {
List<DefaultTreeNode<FileInfo>> inner3 = new ArrayList<DefaultTreeNode<FileInfo>>();
inner3.add(new DefaultTreeNode<FileInfo>(new FileInfo("zcommon.jar", "ZK Common Library")));
inner3.add(new DefaultTreeNode<FileInfo>(new FileInfo("zk.jar", "ZK Core Library"))); List<DefaultTreeNode<FileInfo>> inner2 = new ArrayList<DefaultTreeNode<FileInfo>>();
inner2.add(new DefaultTreeNode<FileInfo>(new FileInfo("/lib", "ZK Libraries"), inner3));
inner2.add(new DefaultTreeNode<FileInfo>(new FileInfo("/src", "Source Code")));
inner2.add(new DefaultTreeNode<FileInfo>(new FileInfo("/xsd", "XSD Files"))); List<DefaultTreeNode<FileInfo>> inner1 = new ArrayList<DefaultTreeNode<FileInfo>>();
inner1.add(new DefaultTreeNode<FileInfo>(new FileInfo("/doc", "Release and License Notes")));
inner1.add(new DefaultTreeNode<FileInfo>(new FileInfo("/dist", "Distribution"), inner2)); return new DefaultTreeNode<FileInfo>(null, inner1);
} public class FileInfoRenderer implements TreeitemRenderer<DefaultTreeNode<FileInfo>>{ @Override
public void render(Treeitem item, DefaultTreeNode<FileInfo> data, int index)
throws Exception {
// TODO Auto-generated method stub item.setValue(data);
final FileInfo fi = data.getData();
item.setOpen(false);
//for update treeNode data
Treerow tr = item.getTreerow();
if(tr == null) {
tr = new Treerow();
} else {
tr.getChildren().clear();
}
item.appendChild(tr);
//render file path cell
Treecell pathCell = new Treecell();
pathCell.setLabel(fi.getPath());
pathCell.setParent(tr);
//render file description cell
Treecell descriptionCell = new Treecell();
descriptionCell.setLabel(fi.getDescription());
descriptionCell.setParent(tr);
} } public class FileInfo {
private String path;
private String description; public FileInfo() {} public FileInfo(String path, String description) {
this.path = path;
this.description = description;
} public String getPath() {
return path;
} public void setPath(String path) {
this.path = path;
} public String getDescription() {
return description;
} public void setDescription(String description) {
this.description = description;
}
} }

参考:

http://zkfiddle.org/sample/21g0stt/2-Another-new-ZK-fiddle#source-1

ZK tree使用mold的更多相关文章

  1. zk master-slaver机制

    1.基本概念 >>zookeeper handler (zk句柄)有点类似文件句柄,打开一个文件就保持了一个文件句柄!同样的道理: 建立一个到zk server的session就会有一个z ...

  2. ZK框架的分析与应用

    前言:本文是在下的在学习ZK官方文档时整理出来的初稿.本来里面有很多的效果图片和图片代码的.奈何博客园中图片不能粘贴上去,所以感兴趣的筒子们就将就吧.内容中,如有不好的地方,欢迎斧正! ZK框架的分析 ...

  3. Mysql Index、B Tree、B+ Tree、SQL Optimization

    catalog . 引言 . Mysql索引 . Mysql B/B+ Tree . Mysql SQL Optimization . MySQL Query Execution Process 1. ...

  4. [置顶] ZK(The leading enterprise Ajax framework)入门指南

    1. Why ZK JavaEE领域从来就不缺少Framework尤其是Web Framework,光是比较流行的就有:SpringMVC.Struts2.JSF系列…… 其它不怎么流行的.小众的.非 ...

  5. LeetCode: Validate Binary Search Tree 解题报告

    Validate Binary Search Tree Given a binary tree, determine if it is a valid binary search tree (BST) ...

  6. zk键值数据结构

    首先看一张zk官网上的图: zk为我们提供了一种类似于文件存储的树形数据结构,那么它是如何实现的呢? 先假定我们有一个map,以路径名作为键,以节点作为值,如下: “/” -> 节点1,“/ap ...

  7. OAF_OAF控件系列7 - Tree的实现(案列)

    2014-06-02 Created By BaoXinjian

  8. ZK的数据结构特点

    ZK的数据结构特点 ZooKeeper这种数据结构有如下这些特点: 1. 每个子目录项如NameService都被称作znode,这个znode是被它所在的路径唯一标识,如Server1这个znode ...

  9. 如何在 Linux 和 windows 启动使用 Dubbo 和 ZK

    今天的知识点有 3 个: Linux 下安装.配置 JDK. Windows 下启启动 dubbo 和 zookeeper. Linux 下启动 dubbo 和 zookeeper. 1.Linux ...

随机推荐

  1. LoadRunner脚本实例来验证参数化的取值

    LoadRunner脚本实例来验证参数化的取值 SINM {3]!G0问题提出:  主要想试验下,在Controller中,多个用户,多次迭代中参数的取值.51Testing软件测试网(['H5f,d ...

  2. 记录java基础的学习过程

    标识符(类名:变量.属性.方法名: ) 组成:类名开头不能是数字,只能有字母数字_$组成. 命名规范: 类名每一个单词首字母大写(HelloWorld大驼峰法则), 方法名 属性名 变量名首字母小写之 ...

  3. 简单区分VMware的三种网络连接模式(bridged、NAT、host-only)

    艺搜简介 VMware在安装时默认安装了两块虚拟网卡,VMnet1和VMnet8,另外还有VMnet0.这些虚拟网卡的配置都是由Vmware虚拟机自动生成的,一般来说不需要用户自行设置. Vmware ...

  4. Http协议提要

    HTTP协议提要 简单来说,HTTP就是一个基于应用层的通信规范:双方要进行通信,大家就要遵守一个规范---HTTP协议.HTTP协议从WWW服务器超文本到本地浏览器 ,可以使浏览器更加高效.HTTP ...

  5. localhost和127.0.0.1 的区别

  6. 【转】详解C#中的反射

    原帖链接点这里:详解C#中的反射   反射(Reflection) 2008年01月02日 星期三 11:21 两个现实中的例子: 1.B超:大家体检的时候大概都做过B超吧,B超可以透过肚皮探测到你内 ...

  7. 安装配置hive中遇到的问题

    1. mysql中添加用户名时总出现如下问题:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables ...

  8. NoSql之MongoDB--Ubuntu下安装

    MongoDB只提供了64位LTS(长期支持)Ubuntu发行版的packages.例如,12.04 LTS,14.04 LTS,16.04 LTS等等. 1.导入被包管理系统使用的公钥 Ubuntu ...

  9. 2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest D. Do it Right!

    D. Do it Right! time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  10. soapui中文操作手册(五)----入门与安全测试

    在SoapUI4.0引入的安全测试特点使它非常容易为你来验证你的目标服务的功能性安全,就可以评估您的系统常见的安全攻击的漏洞.特别是如果系统是公开可用的,即使不是这种情况,确保了完全安全的环境也是非常 ...