struts-menu 构建动态树的方法(树已出来,但是……)

struts-menu 的功能还比较完善,我已经做出了左边的树形图(从数据库中取的数据),
但是下一步确不知道怎么走了,就是点击左边的某一个节点,在右边的Frame中要把这个节点
下面(逻辑上)的一些节点都展示出来?----例如点击“物理”,在右边的frame中显示“初中物理”

和“高中物理”,有谁做过么? 该如何做呢?

ps:我现在所做的是在用来显示这个树的代码中添加了(红色的,对应图中最下面的链接地址)setLocation()-----已经取到每一个节点在数据库中的ID号,接下来希望通过另外一个GetfilesAction.java来实现对点击节点的跳转。问题是GetfilesAction.java对于传进来的ID我不知道如何处理,因为要取到这个ID下面所有的子节点的ID,那么是不是数据库表所对应的hibernate文件要进行修改?

/************************************************************************************/

for (int i=0; i < list.size(); i++)
{
MenuComponent mc = new MenuComponent();
MenuItem mi=(MenuItem) list.get(i);
String name = mi.getName();
mc.setName(name);
String parent = (String) mi.getParentName();
System.out.println(name + ", parent is: " + parent);
if (parent != null)
{
MenuComponent parentMenu = repository.getMenu(parent);
if (parentMenu == null)
{
System.out.println("parentMenu '" + parent + "' doesn't exist!");
// create a temporary parentMenu
parentMenu = new MenuComponent();
parentMenu.setName(parent);
repository.addMenu(parentMenu);
}
mc.setParent(parentMenu);
// if (parent != null)
}
String title = (String)mi.getTitle();
mc.setTitle(title);

// String location = (String) mi.getLocation();
// mc.setLocation(location);
// I add
mc.setLocation("http://10.0.0.72:8081/menu/getFiles.do?id="+mi.getId());
mc.setTarget("_blank");
repository.addMenu(mc);

/******************************************************************************************/

我对hibernate的修改,红色的是我添加的

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="hj.hci.vo.MenuItem" table="menu_item" catalog="treeview">
<id name="id" type="long">
<column name="id" />
<generator class="native" />
</id>
<property name="parentName" type="string">
<column name="parent_name" length="30" />
</property>
<property name="name" type="string">
<column name="name" length="30" />
</property>
<property name="title" type="string">
<column name="title" length="30" />
</property>
<property name="description" type="string">
<column name="description" length="50" />
</property>
<property name="location" type="string">
<column name="location" />
</property>
<property name="target" type="string">
<column name="target" length="10" />
</property>
<property name="onclick" type="string">
<column name="onclick" length="100" />
</property>
<property name="onmouseover" type="string">
<column name="onmouseover" length="100" />
</property>
<property name="onmouseout" type="string">
<column name="onmouseout" length="100" />
</property>
<property name="image" type="string">
<column name="image" length="50" />
</property>
<property name="altImage" type="string">
<column name="altImage" length="30" />
</property>
<property name="tooltip" type="string">
<column name="tooltip" length="100" />
</property>
<property name="roles" type="string">
<column name="roles" length="100" />
</property>
<property name="page" type="string">
<column name="page" />
</property>
<property name="width" type="string">
<column name="width" length="5" />
</property>
<property name="height" type="string">
<column name="height" length="5" />
</property>
<property name="forward" type="string">
<column name="forward" length="50" />
</property>
<property name="action" type="string">
<column name="action" length="50" />
</property>
</class>
<sql-query name="hj.hci.vo.QueryMenuItem">
<![CDATA[
select {menuitem.*} from menu_item menuitem where menuitem = :id
]]>
<return alias="menutiem" class="hj.hci.vo.MenuItem" />
</sql-query>
</hibernate-mapping>

/***********************************************************************************************/

想了好几天了:《

你可能感兴趣的:(sql,Hibernate,.net,struts,MyEclipse)