• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
thankgoodness
博客园    首页    新随笔    联系   管理    订阅  订阅

structs中dtree的应用

经过一段时间的研究,终于把structs _menu 给换掉了,因为我感觉这个有点麻烦,应用有事费事,现在是,时间经济,越快,完成,就越快取得经济效益.

我用的myeclipse 6.1 + sdk6.0做的,以下,是数据结构表.

id字段:varchar 10 主键--节点标识码
            pid字段:varchar 10 not null--父节点标识码
            name字段:varchar 20 not null
            url字段:varchar 50 not
            null--这个字段存储的是点击该节点时,要定位的资源(比如一个页面的url),
            为了不使本文的篇幅过长,暂时不给出相应的页面,
            您可以随便输入一个字母比如:a,以使本例能够正常运行。
            title字段:varchar 20
            target字段:varchar 10
            icon字段:varchar 20
            iconopen字段:varchar 20
            opened字段:char 1

用myeclipse 生成vo,po 以及操作办法,最后,用structs 起草了一个action,在action事件事,调用了两个事件,一个事件,

public ActionForward execute(ActionMapping mapping, ActionForm form,
     HttpServletRequest request, HttpServletResponse response) {
    FunctionsDAO functiondao = new FunctionsDAO();

     List list=functiondao.findAll();
  
         
   
     request.setAttribute("treeList",list);

    // request.setAttribute("list", list);
          //System.out.println(list.size());

    return mapping.findForward("findsuc");
       
}

把值传到了页面.注意,是自动生成的vo ,po 方法.

这是页面.

<%@ page language="java" pageEncoding="gb2312"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="
http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="
http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="
http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ page import="java.util.*" %>
<html>

<head>
<title>Destroydrop &raquo; Javascripts &raquo; Tree</title>

<link rel="StyleSheet" href="dtree.css" type="text/css" />
<script type="text/javascript" src="js/dtree.js"></script>

</head>

<body>

<div class="dtree">

<p><a href="javascript: tree.openAll();">全部打开</a> | <a href="javascript: tree.closeAll();">全部关闭</a></p>

<script type='text/javascript'>
tree = new dTree('d');
tree.config.folderLinks=false;
tree.config.useCookies=false;
<logic:iterate id="functionsForm" name="treeList" scope="request">
      tree.add("<bean:write name="functionsForm" property="id"/>","<bean:write
name="functionsForm" property="pid"/>","<bean:write name="functionsForm"
property="name"/>","<bean:write name="functionsForm"
property="url"/>","<bean:write name="functionsForm"
property="title"/>","<bean:write name="functionsForm"
property="target"/>","<bean:write name="functionsForm" property="icon"/>");
</logic:iterate>
        document.write(tree);
</script>


</div>


</body>

</html>

以下,strcts 架构

    <action path="/findtree" type="org.longxin.struts.action.Functions1Action">
    

<forward name="findsuc" path="/example021.jsp"></forward>

      </action>

加上就好使.

posted @ 2008-06-23 11:22  宇晨  阅读(242)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3