今天是大年初一,赶快开学吧,每天很无聊,唯一感
觉还有点新年的味道就是昨天公司老师带我们去海丽
轩吃年夜饭,兄弟还是挺多的,心情也很好的!今天
复习OA的映射,对这不熟悉啊,还得努力。。。
一.
多对多:对role.java文件,其中映射文件如下:
<set name="employees" table="itcast_employee_role">
<key column="roleId"></key>
<many-to-many class="Employee"
column="employeeId"></many-to-many>
</set>
对员工Employee.java来说,映射文件如下:
<set name="roles" table="itcast_employee_role">
<key column="employeeId"></key>
<many-to-many class="Role"
column="roleId"></many-to-many>
</set>
一对一:员工和帐号,对于附属类帐号,映射文件如
下:
<id name="id">
<generator class="foreign">
<param name="property">employee</param>
</generator>
</id>
<one-to-one name="employee" constrained="true"></one-to-one>
主类(employee),映射文件:
<one-to-one name="user"></one-to-one>
二.方法:
/** 列表 */
public ActionForward list(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response)
throws Exception {
return mapping.findForward("list"); // list.jsp
}
/** 添加页面 */
public ActionForward addUI(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response)
throws Exception {
return mapping.findForward("saveUI");
}
/** 添加 */
public ActionForward add(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response)
throws Exception {
return mapping.findForward("toList"); }
/** 修改页面 */
public ActionForward editUI(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response)
throws Exception {
return mapping.findForward("saveUI");
}
/** 修改 */
public ActionForward edit(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response)
throws Exception {
return mapping.findForward("toList");
}
/** 删除 */
public ActionForward del(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response)
throws Exception {
return mapping.findForward("toList");
}
三.
标签复习:
<html:form>
<html:text>
<html:hidden>
<html:textarea>
javascript复习:
<html:link action="/role?method=del&id=${role.id}" onlick="return
window.confirm('您确定要删除一条记录吗?');">删除
</html:link>
在页面中
<html:rewrite action="/role?method=addUi"/>
<script type="text/javascript">
funcion addUI(){
window.location.href="<html:rewrite action='/role?method=addUI'";
}
</script>
<srcipt type="text/java"
<script type="text/javascript">
funcion checkForm(form){
if($.trim(form.name.value) == "" ){}
alert("");
form.name.focus();
return false;
}
return true;
}
</script>
四.在Action中进行验证
ActionErrors errors = form.validate(mapping,request);
if(errors!=null&&errors.size()>0){
saveErrors(request,errors);
return mapping.findForward("addUI");
}
五.HQL语句
getSession().createQuery("FROM Department d WHERE d.parent is
NULL")//
.list();
六.树形展示菜单
List<Department> list = new ArrayList<Department>();
printInfo(topLevel,"",list);
return list;
注意空格是全角空格,全角空格是中文字符,不会合
并。
public static void printInfo(Collection<Department>
departmentList,String prefix,List<Department> list){
for(Department department : departmentList){
department.setName(prefix + "|-" + department.getName());
list.add(department);
printInfo(department.getChildren(),prefix+" ",list);
}
}
今天就做到这了!
posted on 2010-02-16 01:06
d66380022 阅读(195)
评论(0) 编辑 收藏