⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 turnpagetag.java

📁 管理公司合同
💻 JAVA
字号:
package cn.com.juneng.system.common.taglib;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import cn.com.juneng.system.common.BaseForm;

public class TurnPageTag extends TagSupport {
	private int groupSize = 8;

	public void setGroupSize(int groupSize) {
		this.groupSize = groupSize;
	}

	// 当前页
	private int currentPage = 0;

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	// 总共页数
	private int pageCount = 0;

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	// 每页显示条数
	private int rowCount = 0;

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}

	// 总共记录条数
	private long allCount = 0;

	public void setAllCount(long allCount) {
		this.allCount = allCount;
	}

	// 从form中获取信息
	private String formName;

	private String pageMethod;

	public String getPageMethod() {
		return pageMethod;
	}

	public void setPageMethod(String pageMethod) {
		this.pageMethod = pageMethod;
	}

	private BaseForm bForm;

	private void setFormName(String name) {
		// this.formName=name;
		HttpServletRequest request = (HttpServletRequest) pageContext
				.getRequest();
		BaseForm model = (BaseForm) request.getAttribute("BaseForm");
		this.bForm = model;
		this.currentPage = model.getCurrentPage();
		this.rowCount = model.getRowCount();
		this.pageCount = model.getPageCount();
		this.allCount = model.getTotalCount();
	}

	public int doStartTag() {
		try {
			StringBuffer content = new StringBuffer();
			setFormName(null);
			if (pageMethod == null) {
				pageMethod = "list";
			}
			content
					.append("<input type=\"hidden\" name=\"actionType\" value=\""
							+ bForm.getActionType() + "\">\r\n");
			content
					.append("<input type=\"hidden\" name=\"currentPage\" value=\""
							+ this.currentPage + "\">\r\n");
			content.append("<input type=\"hidden\" name=\"orderCol\" value=\""
					+ bForm.getOrderCol() + "\">\r\n");
			content.append("<input type=\"hidden\" name=\"order\" value=\""
					+ bForm.getOrder() + "\">\r\n");
			
			int startRow = (currentPage - 1) * rowCount + 1;
			int endRow = currentPage * rowCount;
			if (endRow > allCount) {
				endRow = (int) allCount;
			}
			if (allCount == 0) {
				startRow = 0;
			}
			// content.append("<div style='background-color:#F4FCFF'>");
			content
					.append("<table style='border:0;background:#ECF5FF'><tr><td align='left'><span ><span class='redfont'>"
							+ allCount
							+ "</span>条记录,分<span class='redfont'>"
							+ pageCount
							+ "</span>页显示,每页显示"
							+ "<input type='text' class='numberTextInput' datatype='integer'  name='rowCount' value='"
							+ rowCount
							+ "' size='2' onKeyDown=\"javascript:if (event.keyCode==13) {document.getElementById('btnQueryID').click()}\"> ,"
							+ "当前显示<span class='redfont'>" + startRow + "-"
							+ endRow + "</span>条</span></td>");
			content.append("<td style='align:right'><div  align='right'>");
			if (currentPage > 1) {
				content.append("[<a href=\"javascript:changePage('1','"
						+ pageMethod + "')\">首页</a>]");
				content.append("[<a href=\"javascript:changePage('"
						+ (currentPage - 1) + "','" + pageMethod
						+ "')\">上页</a>]");
			} else {
				content.append("[首页]");
				content.append("[上页]");
			}
			content.append(" ");
			int startPage = groupSize * ((currentPage - 1) / groupSize);
			int endPage = groupSize * ((currentPage - 1) / groupSize)
					+ groupSize;
			if (endPage > pageCount) {
				endPage = pageCount;
			}
			for (int i = startPage + 1; i <= endPage; i++) {
				if (i != startPage + 1) {
					content.append(",");
				}
				if (i == currentPage) {
					content
							.append("<strong class='redfont'>" + i
									+ "</strong>");
				} else {
					content.append("<a href=\"javascript:changePage('" + i
							+ "','" + pageMethod + "')\" title=\"Go to " + i
							+ " page\">" + i + "</a>");
				}
			}
			content.append(" ");
			if (currentPage < pageCount) {
				content.append("[<a href=\"javascript:changePage('"
						+ (currentPage + 1) + "','" + pageMethod
						+ "')\">下页</a>]");
				content.append("[<a href=\"javascript:changePage('" + pageCount
						+ "','" + pageMethod + "')\">尾页</a>]");
			} else {
				content.append("[下页]");
				content.append("[尾页]");
			}
			content.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
			HttpServletRequest request = (HttpServletRequest) pageContext
					.getRequest();
			content.append("</div></td></tr></table>" );
			/*
			content
					.append("<img src=\""
							+ request.getContextPath()
							+ "/images/common/go.gif\" id='btnQueryID' onclick=\"form1.currentPage.value = '1';form1.actionType.value='"
							+ pageMethod
							+ "';form1.submit();\" style='cursor:hand' title='查询'></div></td></tr></table>");
			
			content
					.append(" <img src=\""
							+ request.getContextPath()
							+ "/images/common/excel.gif\" onclick=\"form1.submit()\" style='cursor:hand' title='导出Excel'>");
			*/
			// }
			JspWriter out = pageContext.getOut();
			out.println(content.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return (SKIP_BODY);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -