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

📄 cachedpagertag.java

📁 j2ee源码
💻 JAVA
字号:
/*
 * Created on 2005/11/14
 */
package com.leeman.common.web.ui.tags;

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

import com.leeman.common.web.ui.CachedPager;

/**
 * @author Dennis
 */
public class CachedPagerTag extends TagSupport{
	
	private String pagerId;
	
	public int doStartTag() throws javax.servlet.jsp.JspException
	{
		try{
			HttpServletRequest request =(HttpServletRequest)pageContext.getRequest();
			CachedPager pager = (CachedPager)request.getAttribute(pagerId);
			
//			System.out.println("Record: " + pager.getPageRecordStart() + "-" + pager.getPageEnd() + "/" + (pager.getMaxRecordReached()) + (pager.isTotalRecordReached()?"":"+"));
//			System.out.println("Cache Record Start: " + pager.getCacheRecordStart());
//			System.out.println("Cache Record Current Size: " + pager.getCurrentCacheRecordSize());
//			System.out.println("Cache Size: " + pager.getCacheRecordSize());
//			System.out.println("Max Record Reached: " + pager.getMaxRecordReached());
//			System.out.println("IsTotalRecord Reached: " + pager.isTotalRecordReached());
//			System.out.println("IsNextPage: " + pager.isNextPage());
//			System.out.println("IsPrevPage: " + pager.isPrevPage());
			  
			StringBuffer shtml = new StringBuffer();
			
			//Previous Button
			String contextPath = request.getContextPath() + "/";
			String imageDirPath = contextPath + "common/images/";
			
			shtml.append("<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td valign=\"middle\">");
			shtml.append((pager.getPageRecordStart() + 1) + "-" + (pager.getPageEnd() + 1) + " / " + (pager.getMaxRecordReached() + 1) + (pager.isTotalRecordReached()?"":"+"));
			shtml.append("</td><td>");
			if (pager.isPrevPage()){
				shtml.append("<input type=\"image\" name=\"cmd.prevPage\" src=\"" + imageDirPath + "base/previous_button.gif" + "\" alt=\"\"> ");
			}
			if (pager.isNextPage()){
				shtml.append("<input type=\"image\" name=\"cmd.nextPage\" src=\"" + imageDirPath + "base/next_button.gif" + "\" alt=\"\"> ");
			}
			shtml.append("</td></tr></table>");
			
			pageContext.getOut().println(shtml.toString());
			
		}catch(Exception e){
			throw new javax.servlet.jsp.JspException("Error processing CachedPagerTag.doStartTag(): " + e.toString());
		}	
		
		return EVAL_BODY_INCLUDE;
	}
	/**
	 * @return
	 */
	public String getPagerId() {
		return pagerId;
	}

	/**
	 * @param string
	 */
	public void setPagerId(String string) {
		pagerId = string;
	}

}

⌨️ 快捷键说明

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