@Entity
public class Employee extends XXXObject {
//...
/**
* 最近復職日期
*/
private Date lastReinstatementDate;
/**
* 核薪資料者
*/
private Set<BaseCheckSalary> baseCheckSalary = new HashSet<BaseCheckSalary>();
@OneToMany(mappedBy = "employee", fetch = FetchType.LAZY)
@Cascade(value = { org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
public Set<BaseCheckSalary> getBaseCheckSalary() {
return baseCheckSalary;
}
public void setBaseCheckSalary(Set<BaseCheckSalary> baseCheckSalary) {
this.baseCheckSalary = baseCheckSalary;
}
//...
}
@Entity
public class BaseCheckSalary extends XXXObject {
//...
private Employee employee;
private Date startDate;
@ManyToOne(fetch = FetchType.LAZY)
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
//...
}
@Name("baseCheckSalaryQuery")
@Scope(ScopeType.CONVERSATION)
public class BaseCheckSalaryQuery extends EntityQuery<Employee> {
/**
*
*/
private static final long serialVersionUID = 1L;
//未核薪員工查詢語句
private static final String UNCHECKED_EMPLOYEE = "select e from Employee e where e not in " +
"(select b.employee from BaseCheckSalary b) or " +
"(e.lastReinstatementDate is not null and e.lastReinstatementDate > " +
"(select max(b.startDate) from BaseCheckSalary b where b.employee = e ))";
//已核薪員工查詢語句
private static final String CHECKED_EMPLOYEE = "select e from Employee e where e not in " +
"(select emp from Employee emp where emp not in (select b.employee from BaseCheckSalary b) or " +
"(e.lastReinstatementDate is not null and emp.lastReinstatementDate > " +
"(select max(b.startDate) from BaseCheckSalary b where b.employee = emp )))";
//所有員工查詢語句
private static final String ALL_EMPLOYEE = "from Employee e";
public BaseCheckSalaryQuery() {
super.setEjbql(UNCHECKED_EMPLOYEE);
super.setOrder("e.employeeNumber");
super.setMaxResults(20);
}
/**
* 查詢所有員工
*
* @return
*/
public List<Employee> queryAllEmployee() {
super.setEjbql(ALL_EMPLOYEE);
return super.getResultList();
}
/**
* 查詢已核薪員工
*
* @return
*/
public List<Employee> queryCheckedEmployee() {
super.setEjbql(CHECKED_EMPLOYEE);
return super.getResultList();
}
/**
* 查詢未核薪員工
*
* @return
*/
public List<Employee> queryUnCheckedEmployee() {
super.setEjbql(UNCHECKED_EMPLOYEE);
return super.getResultList();
}
}
@Name("baseCheckSalaryHome")
@Scope(ScopeType.CONVERSATION)
public class BaseCheckSalaryAction {
//...
private static final Integer MAXRESULTS = 15;// 分頁查詢每頁顯示行數
@RequestParameter
private Integer firstResult = 0;// 分頁查詢開始頁
@In(required = false, create = true)
@Out(required = false, scope = ScopeType.CONVERSATION)
private ControlBean controlBean;// 注入控制類
/**
* 根據核薪狀態查詢符合條件的員工列表
*/
@Factory("employeeList")
public void getEmployeeList() {
baseCheckSalaryQuery.setFirstResult(firstResult);
baseCheckSalaryQuery.setMaxResults(MAXRESULTS);
if (queryStatus.equals("false")) {
employeeList = baseCheckSalaryQuery.queryUnCheckedEmployee();
} else if (queryStatus.equals("true")) {
employeeList = baseCheckSalaryQuery.queryCheckedEmployee();
} else {
employeeList = baseCheckSalaryQuery.queryAllEmployee();
}
controlBean.setPreviousExists(baseCheckSalaryQuery.isPreviousExists());
controlBean.setNextExists(baseCheckSalaryQuery.isNextExists());
}
//...
}
<rich:dataTable
id="empList" value="#{employeeList}" var="bcsl" width="90%"
onRowMouseOver="this.style.backgroundColor='#666666'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
<a4j:support event="onRowClick"
action="#{baseCheckSalaryHome.getBaseCheckSalaryDetail}"
reRender="empInfo,rsb,otherItemtable">
</a4j:support>
<h:column>
<f:facet name="header">
<h:outputText value="員工工號" />
</f:facet>
<h:outputText value="#{bcsl.employeeNumber}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="員工姓名" />
</f:facet>
<h:outputText value="#{bcsl.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="核薪樣板" />
</f:facet>
<h:outputText
value="#{baseCheckSalaryHome.getSalaryModelName(bcsl)}" />
</h:column>
<f:facet name="footer">
<h:panelGrid columns="4" >
<f:subview id="s_firstPage_y"
rendered="#{controlBean.previousExists}">
<a4j:commandLink action="#{baseCheckSalaryHome.getEmployeeList}"
value="<<第一頁" rendered="#{controlBean.previousExists}"
reRender="empList">
<f:param name="firstResult" value="0" />
</a4j:commandLink>
</f:subview>
<f:subview id="s_firstPage_n"
rendered="#{!controlBean.previousExists}">
<h:outputText value="<<第一頁" />
</f:subview>
<f:subview id="s_previousPage_y"
rendered="#{controlBean.previousExists}">
<a4j:commandLink action="#{baseCheckSalaryHome.getEmployeeList}"
value="< 上一頁" rendered="#{controlBean.previousExists}"
reRender="empList">
<f:param name="firstResult"
value="#{baseCheckSalaryQuery.previousFirstResult}" />
</a4j:commandLink>
</f:subview>
<f:subview id="s_previousPage_n"
rendered="#{!controlBean.previousExists}">
<h:outputText value="< 上一頁" />
</f:subview>
<f:subview id="s_nextPage_y" rendered="#{controlBean.nextExists}">
<a4j:commandLink action="#{baseCheckSalaryHome.getEmployeeList}"
value="下一頁>" rendered="#{controlBean.nextExists}"
reRender="empList">
<f:param name="firstResult"
value="#{baseCheckSalaryQuery.nextFirstResult}" />
</a4j:commandLink>
</f:subview>
<f:subview id="s_nextPage_n"
rendered="#{!controlBean.nextExists}">
<h:outputText value="下一頁>" />
</f:subview>
<f:subview id="s_lastPage_y" rendered="#{controlBean.nextExists}">
<a4j:commandLink action="#{baseCheckSalaryHome.getEmployeeList}"
value="最后頁>>" rendered="#{controlBean.nextExists}"
reRender="empList">
<f:param name="firstResult"
value="#{baseCheckSalaryQuery.lastFirstResult}" />
</a4j:commandLink>
</f:subview>
<f:subview id="s_lastPage_n"
rendered="#{!controlBean.nextExists}">
<h:outputText value="最后頁>>" />
</f:subview>
</h:panelGrid>
</f:facet>
</rich:dataTable>
分享到:
相关推荐
php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax分页php+ajax...
项目主体结构是dao+db+filter+pojo+servlet, 使用技术Servlet转发,代码中有注释帮助学者理解,数据库为MySQL资源...实现的数据库内容分页,查询分页,对初学者难点是根据get请求的中的url地址进行查询后的分页效果。
可以很好的实现页面的模糊查询+分页,我们在前台实现简单的增删改查,很好的实现页面功能。
JavaWeb+JSP+Servlet+JDBC分页查询和查询后分页界面优化最终版
SSH+模糊查询+分页+增删改查
SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part3 SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part2 SSH + Lucene + 分页 + 排序 + 高亮 ...
在一个兄弟分享的代码基础上,改造成spring mvc + mybatis框架,并增加了插件方式实现的分页功能。代码是完整的maven工程。
SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part3 SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part2 SSH + Lucene + 分页 + 排序 + 高亮 ...
SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part3 SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part2 SSH + Lucene + 分页 + 排序 + 高亮 ...
SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part3 SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part2 SSH + Lucene + 分页 + 排序 + 高亮 ...
SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part3 SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part2 SSH + Lucene + 分页 + 排序 + 高亮 ...
SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part3 SSH + Lucene + 分页 + 排序 + 高亮 模拟简单新闻网站搜索引擎--NewsWithSearch.part2 SSH + Lucene + 分页 + 排序 + 高亮 ...
本人博客中的代码Jsp+Servlet+MyBatis完成分页查询 http://blog.csdn.net/japanstudylang/article/details/51700874
完整thinkPHP增删改查+分页+模糊查询+Ajax登录+注册!
使用EL JSTL表达式 servlet和分页进行编码 新闻管理系统
node.js+express+mysql实现增删改查+分页,以及图片上传操作
实现无刷新分页、模糊查询, 大大的提高了用户的体验度。。。
基于存储过程+分页控件+分页类的无敌分页模式
struts2+spring+ibatis+oracle+分页搜索+上传附件实例!完整版!
基于三大框架struts2+Hibernate+Spring的使用session的高级查询和分页~