转:传智播客—jbpm与OA项目(六)续
4、 显示分页信息的pageView.jspf页面
多处使用到分页页面,所以我们将分页页面单独提取出来。如果有哪个页面需要显示分页信息,直接include就可以了。
?
<%@?page?language="java"?pageEncoding="utf-8"?%>
<%@?taglib?prefix="c"?uri="http://java.sun.com/jsp/jstl/core"?%>
?
<c:if?test="${pageView.totalPage gt 1 }">
?
<!-- 分页信息 -->
页码:${pageView.currentPage}/${pageView.totalPage}页
每页显示:${pageView.pageSize}条
总记录数:${pageView.recordCount}条
?
分页:
<a?href="javascript:gotoPage(1)">[首页]</a>?
<c:if?test="${pageView.currentPage gt 1}">
<a?href="javascript:gotoPage(${pageView.currentPage - 1})">[上一页]</a>?
</c:if>
<c:if?test="${pageView.currentPage lt pageView.totalPage}">
<a?href="javascript:gotoPage(${pageView.currentPage + 1})">[下一页]</a>?
</c:if>
<a?href="javascript:gotoPage(${pageView.totalPage})">[尾页]</a>
<!-- 显示页码 -->
<c:forEach?begin="${pageView.startPageIndex}" end="${pageView.endPageIndex}" var="pageNum">
<c:if?test="${pageNum eq pageView.currentPage}">
<span?class="current_page">${pageNum}</span>
</c:if>
<c:if?test="${pageNum ne pageView.currentPage}">
<a?href="javascript:gotoPage(${pageNum})">${pageNum}</a>
</c:if>
</c:forEach>
转到:
<input?type="text"?id="txtPageNum"?size="4"?class="input_pagenum"/>
<input?type="button"?onclick="gotoPage(document.getElementById('txtPageNum').value)"?value="Go"/>
<script?type="text/javascript">
/**
* 跳转到指定的页码
*/
function gotoPage( pageNum ){
if( isNaN(pageNum) ){ // not a number
alert("请输入正确的页码");
document.getElementById('txtPageNum').focus();
return?false;
}
if( pageNum < 1 || pageNum > ${pageView.totalPage} ){
alert("请输入正确的页码,范围为 1-${pageView.totalPage}");
document.getElementById('txtPageNum').focus();
return?false;
}
window.location.href = getPageViewUrl( pageNum );
// getPageViewUrl为在include页面添加的javscript代码,
???? // 所以此页面可以适用于任何分页信息的显示。例如下:
//function getPageViewUrl( pageNum ){
// return "?method=list&pageNum=" + pageNum;
//}
}
</script>
</c:if>
?
二、审批流转管理
审批流转就是把单位内部的各项审批电子化,如工作请求、出差申请、采购申请、请假、报销等日常工作流程。
?
审批流转(工作流):
1.流程与表单管理
2.执行流程
3.查询
?
有类似的审批请求,有两大重点:流程定义和表单模板,一个表单对应一个流程。
?
要求:
1.方便 定义/修改 与 管理 流程定义
2.方便 定义/修改 与 管理 表单模板
3.执行流程(让表单(数据)按指定的流程进行流转,并且记录)
4.方便查询所有的表单实例(数据) 记录(查询流转过的表单)
?
今日没有讲解设计与审批流转相关的模块,只是讲解将打包成zip的JBPM工作流自动部署到OA项目中,并可查看显示工作流的文件信息以及删除工作流。
?
1.显示部署流程
?
/**?
?*?部署流程页面?
?*/
public?ActionForward deployUI(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("deployUI"); // deployUI.jsp
}
?
2.部署流程
?
/**?
?*?部署流程?
?*/
public ActionForward deploy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
?
try {
// 获取<html:file>表单提交过来的流程资源
ProcessDefinitionActionForm adaf = (ProcessDefinitionActionForm) form;
ZipInputStream zipIn = new ZipInputStream(adaf.getParResource().getInputStream());
// 创建流程定义
ProcessDefinition pd = ProcessDefinition.parseParZipInputStream(zipIn);
// 部署流程定义
this.processDefinitionService.deploy(pd);
} catch (Exception e) {
// 发生异常显示错误
ActionErrors errors = new ActionErrors();
errors.add("error", new ActionMessage("非法的文件格式!",false));
this.saveErrors(request, errors);
return mapping.findForward("deployUI");
}
return mapping.findForward("toList"); // path="/pd.do?method=list" redirect="true"
}
因为部署流程时确保一个线程使用的是同一个“JbpmContext”,并确保Jbpm事件的正确提交或回滚。所以我们还需要为JbpmContext添加一个过滤器。
?
3.删除流程
?
/**
?*?删除流程
?*/
public ActionForward del(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 获取流程ID并删除
Long id = Long.parseLong(request.getParameter("id"));
this.processDefinitionService.delete(id);
?
// 需要刷新流程显示列表
String pageNum = request.getParameter("pageNum");
ActionForward af = mapping.findForward("toList");
return?new ActionForward(af.getPath() + "&pageNum=" + pageNum, af.getRedirect());
}
?
4.查看流程中的“processdefinition.xml”文件
?
/**
?*?查询流程定义文件(processdefinition.xml)
?*/
public ActionForward showProcessFile(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
// 获取流程id
Long id = Long.parseLong(request.getParameter("id"));
// 获取流程定义
ProcessDefinition pd = this.processDefinitionService.getById(id);
// 获取文件
byte[] content = pd.getFileDe