`
ludaojuan21
  • 浏览: 221854 次
  • 性别: Icon_minigender_1
  • 来自: 回龙观
社区版块
存档分类
最新评论

从后台传过一个LIST,页面上直接根据这个LIST进行翻页操作而无须借助外部类

    博客分类:
  • JSP
阅读更多
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import = "javax.naming.*"%>
<%@ page import = "javax.sql.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*"%>
<%@ page import = "Login.Loginer"%>
<%@ page import = "principal.WorkBillDataBean"%>
<%@ page session = "true"%>
<%
   if (session.getAttribute("loginer")==null){
      response.sendRedirect("../err/nologerror.jsp");
   }
%>
<%!
public String getStr(String str) {
                try {
if(str == null) str = "";
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859-1");
String temp = new String(temp_t);
return temp;
}catch (Exception ee) {
ee.printStackTrace();
}
return "";
}
%>
<script language="javascript" src="js/div.js"></script>
<script type="text/javascript" src="../../../js/displayDiv.js"></script>
<html>
<head>
<title>查询结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../frames/Css/table.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
  String strDiv = "<div id='sponsorAdDiv' style='left: 230px; top: 120px;position:relative;'>";
  strDiv = strDiv + "<table width='300' height='50' bgcolor='#0099cc' border=0 cellspacing=1>";
  strDiv = strDiv + "<tr><td><table width='100%' height='100%' border=0 cellspacing=0>";
  strDiv = strDiv + "<tr bgcolor='#d2e9fe'><td>&nbsp;&nbsp;&nbsp;&nbsp;";
  strDiv = strDiv + "系统正在进行操作,可能需要几秒钟<br>&nbsp;&nbsp;&nbsp;&nbsp;";
  strDiv = strDiv + "请您稍候......</td></tr></table></td></tr></table></div>";
  out.print(strDiv);
  out.print("<script type='text/javascript'>hideDiv();</script>");
%>
<div align="center"><strong>查询结果</strong></div>
<table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" class="report_new">
  <tr bgcolor="#FEFAC9">
    <td width="24%" height="28" align="center">工作票名</td>
     <td width="27%" height="28" align="center" scope="col">工作票类型</td>
    <td width="15%" height="28" align="center" scope="col">建立时间</td>
    <td width="15%" height="28" align="center" scope="col">完成时间</td>
    <td width="8%" align="center" scope="col" nowrap>当前状态</td>
    <td width="11%" height="28" align="center" scope="col">详细情况</td>
  </tr>
  <%!
    int curPage=1;//当前是第几页
int maxPage=1;//共多少页
int maxRowCount=1;//共多少行
int rowsPerPage=10;//每页多少行
int jumpCount=0;//要跳过多少行
  %>
<%
ArrayList al=(ArrayList)session.getAttribute("workbill");
maxRowCount=al.size();//最大行数
//求得共多少页
if(maxRowCount%rowsPerPage==0)
   maxPage=maxRowCount/rowsPerPage;
else
   maxPage=maxRowCount/rowsPerPage+1;
  //得到跳转到第几页
  if(request.getParameter("jumpPage")!=null&&!request.getParameter("jumpPage").equals(""))
  {
     curPage=Integer.parseInt(request.getParameter("jumpPage"));
  }
%>
<%
  //计算要跳过多少行
  if(curPage!=1)
  {
    jumpCount=rowsPerPage*(curPage-1);
  }
  else
  {
    jumpCount=0;
  }
  String workBillId="";
  String workBillTypeId="";
  String workBillTypeName="";
  String workBillName="";
  String beginDay="";
  String enDay="";
  String statusIdResult="";
  String statusNameResult="";
  String workDataId="";
  int i=0;
%>
<%
    try{
    for(int j=jumpCount;j<jumpCount+rowsPerPage;j++)
{
  if(j>maxRowCount-1)
    break;
  WorkBillDataBean wb=(WorkBillDataBean)al.get(j);
  workBillId= wb.getWorkBillId();
  workBillTypeId=wb.getWorkBillId();
  workBillTypeName= wb.getWorkBillTypeName();
  workBillName=wb.getWorkBillName();
      beginDay=wb.getBeginDay();
  enDay=wb.getEnDay();
  statusIdResult=wb.getStatusIdResult();
  statusNameResult=wb.getStatusNameResult();
  workDataId=wb.getWorkDataId();
          i++;  
%>
<tr bgcolor="#FFFFEE" onmouseover="this.style.backgroundColor='#FEFAC9'" onmouseout="this.style.backgroundColor='#ffffee'">
<td width="24%" align="center" nowrap><%=workBillName%></td>
    <td width="27%" align="center" nowrap><%=workBillTypeName%></td>
    <td width="15%" align="center" nowrap><%=beginDay%></td>
    <td width="15%" align="center" nowrap><%=enDay%></td>
    <td width="8%" align="center" nowrap><%=statusNameResult%></td>
    <td width="11%" align="center" nowrap>
<div align="center" id='Dev<%=i%>Parent'>
<a href="#" onclick="expandIt('Dev<%=i%>');LinkFrame('iframedetail<%=i%>','workbill_query_safety.jsp','<%=workDataId%>');return false">安全措施
    </a>
</div></td>
</tr>
<tr bgcolor="#FFFFEE">
   <td height="0" colspan="6">
<div class=child align="center" id='Dev<%=i%>Child'>
   <iframe src="" id="iframedetail<%=i%>" frameborder="0" align="center" width="850" height="280"></iframe>
</div>
   </td>
</tr>
<%}
}catch(Exception e){
            out.print(e);
      }   
%>
<!--分页用20060529-->
<form action="workbill_query_result_next.jsp" method="post" name="PageForm">
<tr>
      <td height="24" colspan="7">
<div align="center">每页<%=rowsPerPage%>行
  共<%=maxRowCount%>行
  第<%=curPage%>页
  共<%=maxPage%>页</div></td></tr>
    <tr>
  </tr>
<tr>
      <td height="27" colspan="7">
        <div align="center">
      <%if(curPage==1){out.print("首页  上一页");}else{%>
      <a href="javascript:gotoPage(1)">首页</a>
      <a href="javascript:gotoPage(<%=curPage-1%>)">上一页</a>
      <%}%>
      <%if(curPage==maxPage){out.print("下一页  尾页");}else{%>
      <a href="javascript:gotoPage(<%=curPage+1%>)">下一页</a>
      <a href="javascript:gotoPage(<%=maxPage%>)">尾页</a>
      <%}%>
  转到第
  <select name="jumpPage" onchange="Jumping()">
    <% for(int v=1;v<=maxPage;v++)
   {
     if(v==curPage)
     {
%>
    <option selected value=<%=v%>><%=v%></option>
    <%}else{%>
    <option value=<%=v%>><%=v%></option>
    <%}}%>
  </select>
  页
  </div></td></tr>
</form>     
</table>
<%
  out.print("<script type='text/javascript'>hideDiv();</script>");
  out.flush();
%>
</body>
<script language="JavaScript">
  <!--
      function Jumping()
      {
        document.PageForm.submit();
        return;
      }
      function gotoPage(pagenum)
      {
        document.PageForm.jumpPage.value=pagenum;
        document.PageForm.submit();
        return;
      }
   -->
</script>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics