@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>
分享到:
相关推荐
今天在学习angularjs的分页插件时遇到了一个前端的问题,谷歌浏览器开发者模式调试的时候发现每次点击分页刷新按钮会触发两次后台请求,ajax向后台发送了两次请求,这对于强迫症患者来说是一个比较恶心和感到不舒服...
我实在是被各种版本不兼容恶心到了,如果你也一样,恭喜你找到了这个项目,此项目各种兼容性已经被调整到最佳。而且已经写了分页,数据库在src目录下。只有一张表,增删改查都已经实现,接下来可以根据自己需求去...
创建一个包含thead和tbody的容器,使用`display: flex`或`display: grid`,然后对thead应用相应的固定样式。 ```css .table-container { display: flex; overflow-y: auto; } .table-container thead { ...
版本号3.4,从网上找的例子分组都不支持对象,我把我做的分享给大家,不需要资源积分去下载,分页暂时没做,用3.4有点恶心,数据是从后台读取的,只要吧url写对了,稍微修改下就能用
这些应用服务可能包括请求路由(对一个 MVC 结构),错误处理,以通用的方式产生的客户端脚本和已准备好的标签库。 2. Tapestry 的优势 Tapestry 是一种基于组件的 Web 框架,拥有生命周期由重结构简单,容易一旦...