lastformtag.java

来自「一个免费wap站」· Java 代码 · 共 74 行

JAVA
74
字号
package com.eline.wap.common.taglib;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.eline.wap.common.util.AppLogger;

/**
 * 显示最后一页
 * @author Lucifer
 *
 */
public class LastFormTag extends TagSupport {

	private static final long serialVersionUID = 2528517940972095283L;

    private String action = null;
    private String method = "post";
    private ListTag listTag = null;

    /**
     * 
     * @throws JspException
     */
    public int doStartTag() throws JspException {
		// 验证本标记在列表标记内
		listTag = (ListTag) findAncestorWithClass(this, ListTag.class);
		if (listTag == null) {
			throw new JspTagException("形成最后页标记没有对应的列表标记");
		}

		try {
			JspWriter out = pageContext.getOut();
			out.println("<form method=\"" + method + "\" action=\"" + action + "\">");
			out.println("	<input type=\"hidden\" name=\"" + listTag.getParamPrefix() + listTag.getPageIndexParam() + "\" value=\"" + (listTag.totalPages - 1) + "\" />");
			out.println("	<input type=\"hidden\" name=\"" + listTag.getParamPrefix() + listTag.getNextParam() + "\" value=\"true\" />");
		} catch (IOException ex) {
			AppLogger.error("LastFormTag.doStartTag(): 形成最后页标记错误!");
		}

		return EVAL_BODY_INCLUDE;
	}

    /**
     * 
     * @throws JspException
     */
	public int doEndTag() throws JspException {
        try {
			JspWriter out = pageContext.getOut();
			out.print("</form>");
		} catch (IOException ex) {
			AppLogger.error("LastFormTag.doEndTag(): 形成第一页标记FirstFormTag失败!");
		}

		return (EVAL_PAGE);
	}

	public void setAction(String action) {
		this.action = action;
	}

	public void setMethod(String method) {
		if (method != null && !method.equals("") && !method.equalsIgnoreCase("null"))
			this.method = method;
		else
			this.method = "post";
	}
}

⌨️ 快捷键说明

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