1.创建Person类,相当于一张空表:
类名 extends AbstractUuidPersistenceObject
@Entity
@Table(name = "MM_TREATED_TYPE")
@AttributeOverrides({ @AttributeOverride(name = "id", column = @Column(name = "ROW_ID")) })
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Person extends AbstractUuidPersistenceObject {
private String companyId; //公司编号
private String typeCode; //类型编号
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getTypeCode() {
return typeCode;
}
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
}
2.建立Service
public interface IPersonService extends IGenericService<Person>{
}
3.Service实现
public class PersonServiceImpl extends GenericService<Person> implements IPersonService {
}
4.Bean类
public class PersonBean extends AbstractGenericBean<Person, IPersonService>{
}
5.配置文件resource-ServicesContext.xml
<bean id="regie.personService" class="com.whcyit.tobacco.regie.apcd.service.impl.PersonServiceImpl" parent="regie.abstractService" />
6.页面
webapp文件-pages-新建文档-(From、table、tree.jsp)
From.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/Taglibs.jsp"%>
<%@ include file="/commons/WindowHead.jsp"%>
<html:form action="/person/save" styleId="editForm">
<whcyit:QueryParameter/>
<input type="hidden" name="entity.id" reset="true"/>
<whcyit:QueryParameter/>
<table class="detail">
<tr>
<th width="20%">公司编码:</th>
<td width="30%">
<html:text property="entity.companyId" styleId="e_companyId" maxlength="32" styleClass="textfield validate-required"/>
</td>
<th width="20%">类型编码:</th>
<td width="30%">
<html:text property="entity.typeCode" maxlength="32" styleClass="textfield validate-requiredr"/>
</td>
</tr>
</table>
<div style="text-align: center;">
<input id="save" type="button" class="button" value="保 存">
</div>
</html:form>
<script language="javascript">
var vl = new Validation('editForm', {useTitles:false});
var options = {
urlInsert: '${contextPath}/apcd/person/save.do',
urlUpdate: '${contextPath}/apcd/person/save.do',
urlDelete: '${contextPath}/apcd/person/delete.do'
};
var afterCallback = function(grid) {
new OperationStyle(options, isShow);
};
</script>
Table.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/Taglibs.jsp"%>
<html:form action="/person/query" styleId="queryForm">
<table class="query">
<tr>
<th>公司编号:</th>
<td>
<input type="text" name="queryParameter.companyId" value="${personForm.queryParameterMap.companyId}" />
</td>
<th>类型编号:</th>
<td>
<input type="text" name="queryParameter.typeCode" value="${personForm.queryParameterMap.typeCode}" />
</td>
</tr>
<tr>
<td colspan="4" style="text-align:center;">
<input type="submit" value="查 询" class="queryButton"/>
</td>
</tr>
</table>
<ec:table form="queryForm" tableId="list" items="${BaseBean.PAGE_INFO}.items" var="vo">
<ec:row>
<ec:column title="选择" alias="check">
<input name="chk" type="checkbox" value="${vo.id}" />
<whcyit:HiddenCreator value="${vo}" />
</ec:column>
<ec:column property="companyId" title="公司编号"/>
<ec:column property="typeCode" title="类型编号"/>
</ec:row>
</ec:table>
<table width="100%">
<tr>
<td align="right">
<whcyit:Pager styleClass="textfield" formName="queryForm" pageAttributeName="${BaseBean.PAGE_INFO}" goStyleClass="gobutton"/>
</td>
</tr>
</table>
<table width="100%">
<tr>
<td align="center">
<input id="toInsert" type="button" class="button" value="新 增" />
<input id="all" type="button" class="button" value="全 选" />
<input id="delete" type="button" class="button" value="删 除" />
</td>
</tr>
</table>
</html:form>
Tree.jsp略
7.配置文件:
WEB-INF–(struts-config/tiles-defs.xml)
struts-config.xml:
<form-bean name="personForm" type="com.whcyit.tobacco.regie.apcd.bean.PersonBean"/>
tiles-defs.xml:
<definition name="regie.person.query" extends="ContentTemplate">
<put name="title" value="人员管理"></put>
<put name="table" value="/pages/apcd/person/Table.jsp"></put>
<put name="form" value="/pages/apcd/person/Form.jsp"></put>
</definition>