firstformtag.java

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

JAVA
75
字号
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 FirstFormTag extends TagSupport {

	private static final long serialVersionUID = -8133086217901462333L;

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

    /**
     * 
     * @throws JspException
     */
    public int doStartTag() throws JspException {
        // 检查是否处于ListTag中
    	listTag = (ListTag) findAncestorWithClass(this, ListTag.class);
    	if (listTag == null)
    		throw new JspTagException("第一页标记不在列表标记中");

        // 形成Form处理第一页显示
        try {
            JspWriter out = pageContext.getOut();
            out.println("<form method=\"" + method + "\" action=\"" + action + "\">");
            out.println("	<input type=\"hidden\" name=\"" + listTag.getParamPrefix() + listTag.getPageIndexParam() + "\" value=\"0\" />");
            out.println("	<input type=\"hidden\" name=\"" + listTag.getParamPrefix() + listTag.getNextParam() + "\" value=\"true\" />");

        } catch (IOException e) {
        	AppLogger.error("FirstFormTag.doStartTag(): 形成第一页标记FirstFormTag失败!");
        }
        
        return EVAL_BODY_INCLUDE;
    }

    /**
     * 
     * @throws JspException
     */
	public int doEndTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			out.print("</form>");
		} catch (IOException ex) {
			AppLogger.error("FirstFormTag.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 + -
显示快捷键?