xtree在struts下动态加载树
来源:互联网 发布:火影忍者特效ps软件 编辑:程序博客网 时间:2024/05/17 07:49
显示树的页面
<script type="text/javascript">
var tree = new WebFXLoadTree("Hello World", "treeView.do");
tree.write();
</script>
var tree = new WebFXLoadTree("Hello World", "treeView.do");
tree.write();
</script>
treeView.do对应的action方法
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)...{
if(form instanceof TreeForm)...{
try ...{
TreeForm f = (TreeForm)form;
TreeBo bo = new TreeBo();
bo.getTreeList(f.getDeptNo(),response);
} catch (IOException e) ...{
e.printStackTrace();
} catch (NamingException e)...{
e.printStackTrace();
} catch (SQLException e)...{
e.printStackTrace();
}
}
return null;
}
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)...{
if(form instanceof TreeForm)...{
try ...{
TreeForm f = (TreeForm)form;
TreeBo bo = new TreeBo();
bo.getTreeList(f.getDeptNo(),response);
} catch (IOException e) ...{
e.printStackTrace();
} catch (NamingException e)...{
e.printStackTrace();
} catch (SQLException e)...{
e.printStackTrace();
}
}
return null;
}
action调用的方法
public void getTreeList(String deptNo,HttpServletResponse response) throws SQLException,IOException...{
Connection t = dataSource.getConnection();
PreparedStatement p = t.prepareCall("select a.deptname name,a.deptcode code,(select count(b.deptcode)-1 from t_dept b where b.deptcode like a.deptcode||'%') num from t_dept a where length(a.deptcode)=nvl(length(?),0)+4 and a.deptcode like ? || '%'");
String tmp = deptNo;
p.setString(1,deptNo);
p.setString(2,tmp);
ResultSet set = p.executeQuery();
response.setCharacterEncoding("gb2312");
response.setContentType("text/xml charset=gb2312");
PrintWriter out = response.getWriter();
out.write("<?xml version="1.0" encoding="gb2312"?>");
out.write("<tree>");
while(set.next())...{
out.write("<tree text="""+set.getString("name")+""" "+(set.getInt("num")>0?"src="treeView.do?deptNo="+set.getString("code")+""":"action="xxx.html"")+"/>");
}
out.write("</tree>");
out.flush();
set.close();
p.close();
t.close();
}
Connection t = dataSource.getConnection();
PreparedStatement p = t.prepareCall("select a.deptname name,a.deptcode code,(select count(b.deptcode)-1 from t_dept b where b.deptcode like a.deptcode||'%') num from t_dept a where length(a.deptcode)=nvl(length(?),0)+4 and a.deptcode like ? || '%'");
String tmp = deptNo;
p.setString(1,deptNo);
p.setString(2,tmp);
ResultSet set = p.executeQuery();
response.setCharacterEncoding("gb2312");
response.setContentType("text/xml charset=gb2312");
PrintWriter out = response.getWriter();
out.write("<?xml version="1.0" encoding="gb2312"?>");
out.write("<tree>");
while(set.next())...{
out.write("<tree text="""+set.getString("name")+""" "+(set.getInt("num")>0?"src="treeView.do?deptNo="+set.getString("code")+""":"action="xxx.html"")+"/>");
}
out.write("</tree>");
out.flush();
set.close();
p.close();
t.close();
}
通过sql得到此级别的全部元素和每个此级别元素所包含的子元素数量,以便判断在显示层是否需要显示 “+“ 号
欢迎交流
- xtree在struts下动态加载树
- acts_as_tree 加xtree在ROR下生成动态树形结构
- xtree在rails下的应用
- struts-menu xtree
- xtree dwr (ajax)异步加载每个树结点的代码
- js 动态树形控件 xtree
- xtree树的使用
- xtree
- Xtree
- struts动态加载多级菜单
- 利用ExtJS Tree的TreeNode(Json格式)在Struts 2中实现Ajax真正的动态异步加载树
- ExtJS+Struts 实现树的动态加载小例子
- ExtJS+Struts 实现树的动态加载小例子
- Sfilter在Win2000下动态加载的实现
- Sfilter在Win2000下动态加载的实现
- Linux下动态加载
- ExtJS Tree利用json(直接传List TreeNode,不需要转化为JSONArray或通过JSP传)在Struts 2实现Ajax动态加载树结点
- (更新版)ExtJS Tree利用json(直接传List TreeNode,不需要转化为JSONArray)在Struts 2实现Ajax动态加载树结点
- Process的使用
- Java 理论与实践: 正确使用 Volatile 变量
- 诚招工作约2年的delphi程序员(北京-上地)
- 建立WORD文档例子(1)
- 鼠标双击DataGridView单元格变成ComboBox
- xtree在struts下动态加载树
- 安装Ms SQL Server 2005 开发版时出现性能计数器要求安装错误的解决办法
- E文积累_20070905
- 简单工厂模式SimpleFactory
- skyeye试验环境搭建
- 什么是FPGA
- executeUpdate()返回值
- (转)2007北京高考作文题目(太有才了.我都看了无数遍了)
- VxWorks启动过程详解(上)