下面是 页面部分:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=urf-8">
<title>调度任务列表</title>
<style type="text/css">@import url('${pageContext.request.contextPath}/styles/home.css');
.selected{ background:#F0F0F0;}
@import
url('${pageContext.request.contextPath}/css/jquery-ui-1.8.4.custom.css');
@import
url('${pageContext.request.contextPath}/css/ui.jqgrid.css');
</style>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-migrate-1.2.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/grid.locale-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/grid.custom.js"></script>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/js/common/triggerList.js"></script> --%>
<script type="text/javascript">
$(function() {
$("#tableList").jqGrid({
url : "${pageContext.request.contextPath}/JobProcessServlet?jobtype=100&action=query", // 提交的action地址
rownumbers : true, // 是否显示前面的行号
datatype : "json", // 返回的数据类型
mtype : "post", // 提交方式
height : "auto", // 表格宽度
autowidth : true, // 是否自动调整宽度
colNames:['Trigger 名称','Trigger 分组','下次执行时间','上次执行时间','优先级','Trigger 状态','Trigger 类型','开始时间','结束时间','操作'],
colModel : [ {
name : "display_name",
index : "display_name",
width : 60,
sortable : true,
align : 'center'
}, {
name : "trigger_group",
index : "trigger_group",
width : 60,
sortable : true,
align : 'center'
}, {
name : "next_fire_time",
index : "next_fire_time",
width : 60,
sortable : true,
align : 'center'
}, {
name : "prev_fire_time",
index : "prev_fire_time",
width : 60,
sortable : true,
align : 'center',
}, {
name : "priority",
index : "priority",
width : 60,
sortable : true,
align : 'center'
}, {
name : "statu",
index : "statu",
width : 60,
sortable : true,
align : 'center'
}, {
name : "trigger_type",
index : "trigger_type",
width : 60,
sortable : true,
align : 'center'
}, {
name : "start_time",
index : "start_time",
width : 60,
sortable : true,
align : 'center'
}, {
name : "end_time",
index : "end_time",
width : 60,
sortable : true,
hidden : true,
align : 'center'
} , {
name : "process",
index : "process",
sortable : true,
hidden : true,
align : 'center'
}],
gridComplete : function() {
$("#_empty", "#tableList")
.addClass("nodrag nodrop");
$("#tableList").tableDnDUpdate();
var ids = jQuery("#tableList").jqGrid('getDataIDs');
for ( var i = 0; i < ids.length; i++) {
var cl = ids[i];
update = "<input type='button' id='update' value='修改作业表达式' onclick='update("
+ cl + ")'/> ";
runOnce = "<input type='button' id='runOnce' value='立即执行一次' onclick='runOnce("
+ cl + ")'/> ";
pause = "<input type='button' id='runOnce' value='暂停' onclick='doCmd("
+ cl + ")'/> ";
recolve = "<input type='button' id='runOnce' value='恢复' onclick='doCmd("
+ cl + ")'/> ";
del = "<input type='button' id='runOnce' value='删除' onclick='doCmd("
+ cl + ")'/> ";
jQuery("#tableList").jqGrid('setRowData',
ids[i], {
process : update + runOnce + pause + recolve + del
});
}
},
viewrecords : true,
sortname : "display_name",
rowNum : 20,
rowList : [10, 15, 20],
prmNames : {
search : "search"
},
jsonReader : {
root : "dataList", // 服务端保存数据的集合
repeatitems : false,
page: "page",
total: "total",
records: "records",
cell: "dataList",
},
pager : "gridPager",
hidegrid : false
});
});
</script>
</head>
<body>
<br><br>
<table align="center" width="1100" border="0">
<tr>
<td align="left"><a href="${pageContext.request.contextPath}/addTrigger.jsp">添加调度任务</a></td>
</tr>
<tr>
<td align="left"><a href="${pageContext.request.contextPath}/logdb">查看作业日志表</a></td>
</tr>
<tr>
<td align="left"><a href="${pageContext.request.contextPath}/compleData.htm">补数</a></td>
</tr>
</table>
<div align="center" style="margin-bottom:5px">
<input type="button" id="update" style="margin-right:10px;" value="修改作业表达式" onclick="update()">
<input type="button" id="runOnce" style="margin-right:10px;" value="立即执行一次" onclick="runOnce()">
<input type="button" id="pause" style="margin-right:10px;" value="暂停" onclick="doCmd('pause')">
<input type="button" id="resume" style="margin-right:10px;" value="恢复" onclick="doCmd('resume')">
<input type="button" id="remove" style="margin-right:10px;" value="删除" onclick="doCmd('remove')">
</div>
<table id="tableList"></table>
<div id ="gridPager"></div>
<%-- <table id="tableList" align="center" width="1100" border="1">
<tr>
<th nowrap>
选择
</th>
<th nowrap>
Trigger 名称
</th>
<th nowrap>
Trigger 分组
</th>
<th nowrap>
下次执行时间
</th>
<th nowrap>
上次执行时间
</th>
<th nowrap>
优先级
</th>
<th nowrap>
Trigger 状态
</th>
<th nowrap>
Trigger 类型
</th>
<th nowrap>
开始时间
</th>
<th nowrap>
结束时间
</th>
<!-- <th nowrap>
动作命令
</th> -->
</tr>
<c:forEach var="map" items="${list}">
<tr align="center">
<td nowrap>
<input type="checkbox" value="${map.trigger_name}">
</td>
<td nowrap>
${map.display_name}
</td>
<td nowrap>
${map.trigger_group}
</td>
<td nowrap>
${map.next_fire_time}
</td>
<td nowrap>
${map.prev_fire_time}
</td>
<td nowrap>
${map.priority}
</td>
<td nowrap>
${map.statu}
</td>
<td nowrap>
${map.trigger_type}
</td>
<td nowrap>
${map.start_time}
</td>
<td nowrap>
${map.end_time}
</td>
<td nowrap>
<input type="button" id="update" value="修改作业表达式" onclick="update('${map.trigger_name}','${map.job_name}')">
<input type="button" id="runOnce" value="立即执行一次" onclick="runOnce('${map.job_name}')">
<input type="button" id="pause" value="暂停" onclick="doCmd('pause','${map.trigger_name}','${map.trigger_group}','${map.trigger_state}')">
<input type="button" id="resume" value="恢复" onclick="doCmd('resume','${map.trigger_name}','${map.trigger_group}','${map.trigger_state}')">
<input type="button" id="remove" value="删除" onclick="doCmd('remove','${map.trigger_name}','${map.trigger_group}','${map.trigger_state}')">
</td>
</tr>
</c:forEach>
</table> --%>
</body>
</html>
下面是java部分:
private void getQrtzTriggers(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
List<Map<String, Object>> results = this.schedulerService
.getQrtzTriggers();
String page = request.getParameter("page"); // 取得当前页数,注意这是jqgrid自身的参数
int rows = 20;
int qrtzTriggers = this.schedulerService.countQrtzTriggers();
JSONObject json = new JSONObject();
json.put("dataList", results);
json.put("records", qrtzTriggers);//总记录数
json.put("page", page); // 当前页
int total = qrtzTriggers/rows + ((qrtzTriggers%rows)>0?1:0); //计算得出的总页数
json.put("total", total); // 总页数
//System.out.println(rows);
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.write(json.toString());
System.out.println(json.toString());
/*request.setAttribute("list", results);*/
request.getRequestDispatcher("/list.jsp").forward(request, response);
}