-
好久没有更新了
2004-03-30
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://piginzoo.blogbus.com/logs/123187.html
multibox使用过程中,参考:http://www.jguru.com/faq/view.jsp?EID=925277
ACCOUNT是setAttribute中的属性,
<logic:iterate id="role" name="ACCOUNT" property="roleList">
<html:multibox property="selectedRoles">
<bean:write name="role" property="value"/>
</html:multibox>
<bean:write name="role" property="label"/>
</logic:iterate>
<html:submit property="submit" value="提交"/>
</html:form>
采用mutilbox和LabelValueBean的方式来实现checkbox,对于roles要采用一个LableValueBean的List,对于selectedRoles要采用String数据的方式,至于为什么,需要看一看Multi的tag的源代码。List roleList = new ArrayList();
for(int i=0;i<roles.size();i++){
String guid = ((RoleBO)roles.get(i)).getGuid().trim();
String name = ((RoleBO)roles.get(i)).getName().trim();
roleList.add(new LabelValueBean(name,guid));
}==============================================
对于树状的数据结构的存储和读取,采用了hibernate,很爽
下面是它的hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"><hibernate-mapping>
<class
name="com.chinacomm.ccis.coa.document.bo.CategoryBO"
table="COADoc_Category"
dynamic-update="false"
dynamic-insert="false"
><id
name="guid"
column="CATEGORY_GUID"
type="java.lang.String"
>
<generator class="assigned">
</generator>
</id><property
name="desc"
type="java.lang.String"
update="true"
insert="true"
column="CATEGORY_DESC"
/><property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="CATEGORY_NAME"
/><property
name="no"
type="java.lang.Integer"
update="true"
insert="true"
column="CATEGORY_NO"
/><many-to-one
name="parent"
class="com.chinacomm.ccis.coa.document.bo.CategoryBO"
cascade="all"
outer-join="auto"
update="false"
insert="false"
column="CATEGORY_PARENT_ID"
/><set
name="children"
table="CoaDoc_category"
lazy="false"
inverse="true"
cascade="all"
sort="unsorted"
><key
column="CATEGORY_PARENT_ID"
/><one-to-many
class="com.chinacomm.ccis.coa.document.bo.CategoryBO"
/>
</set><property
name="parentGuid"
type="java.lang.String"
update="true"
insert="true"
column="CATEGORY_PARENT_ID"
/><!--
To add non XDoclet property mappings, create a file named
hibernate-properties-CategoryBO.xml
containing the additional properties and place it in your merge dir.
--></class>
</hibernate-mapping>
-------------------------
代码中需要定义以下属性
private Set children = new HashSet();
private CategoryBO parent;
//父节点的id-------------------------
查找到最高级别的父亲节点,就可以还原出这棵树:
bo = (CategoryBO)session.get(CategoryBO.class,"{000000000000000000000000000000000000}");
对于更新和创建:
2004-03-29 15:14:10,291 [ERROR] - 提交事务时发生异常:net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found) (DAOImpl.java:57)
(db.CategoryDAOOracleImpl 57 ) 提交事务时发生异常:net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
Hibernate: update COADoc_Category set CATEGORY_DESC=?, CATEGORY_NAME=?, CATEGORY_NO=?, CATEGORY_PARENT_ID=? where CATEGORY_GUID=?
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:688)
到了也没有找出什么原因,创建不成,我就试验了一下查找,我靠,居然可以,看来只有用它的复合特性来进行数据装载了,而不能用于更新。算啦,还是使用标准的方式存取Category了,即使用parentGuid,而不是parentBO了随机文章:
明天是马拉松的日子 2004-10-16最近的体会 2004-10-15Spring is Coming 2004-04-13关于用struts传递多个参数的问题 2004-03-30这两日blogbus发生了问题 2004-03-20
收藏到:Del.icio.us







