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

📄 inserttag.java.svn-base

📁 一个timesheet程序,用来统计开发人员的度量衡web在线程序.用于软件行业
💻 SVN-BASE
字号:
package com.nsi.taglib;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.nsi.constants.AppConstants;
import com.nsi.control.web.Parameter;
import com.nsi.control.web.ScreenManager;
import com.nsi.util.ValHelper;

/**
 * @author Chris Ye, created on Oct 10, 2008
 *
 * InsertTag
 */
public class InsertTag extends TagSupport
{
	private static final long serialVersionUID = 3410432247527874989L;
	private static Log log = LogFactory.getLog(InsertTag.class);
	private boolean directinclude;
	private String parameter;
	private Parameter paramref;
	private ScreenManager sm;
	/**
	 * constructor of InsertTag
	 */
	public InsertTag()
	{
		directinclude = false;
		parameter = AppConstants.EMPTY_STRING;
		paramref = null;
	}
	/**
	 * @param parameter
	 */
	public void setParameter(String parameter)
	{
		this.parameter = parameter;
	}
	/**
	 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
	 */
	public int doStartTag() throws JspTagException
	{
		try
		{
			super.pageContext.getOut().flush();
		}
		catch(Exception ex)
		{
			log.error("doStartTag() flushing content -- caught Exception : ", ex);
		}
		try
		{
			sm = (ScreenManager)super.pageContext.getServletContext().getAttribute(AppConstants.ScreenManagerKey);
		}
		catch(NullPointerException nulex)
		{
			log.error("doStartTag() -- caught NullPointerException : ", nulex);
			throw new JspTagException("Error extracting screenManager from session: " + nulex);
		}
		if(sm != null && (ValHelper.getInstance().isNotNullAndEmpty(parameter))) 
		{
			paramref = sm.getParameter(parameter, super.pageContext.getSession());
		}
		else
		{
			log.error("doStartTag() -- screenManager is null");
		}
		if(paramref != null) 
		{
			directinclude = paramref.isDirect();
		}
		return SKIP_BODY;
	}
	/**
	 * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
	 */
	public int doEndTag() throws JspTagException
	{
		try
		{
			if(directinclude && paramref != null)
			{
				super.pageContext.getOut().print(paramref.getValue());
			}
			else if(paramref != null && paramref.getValue() != null)
			{
				super.pageContext.getRequest().getRequestDispatcher(paramref.getValue()).include(super.pageContext.getRequest(), super.pageContext.getResponse());
			}
		}
		catch(Exception ex)
		{
			log.error("doEndTag() --  caught Exception: ", ex);
		}
		return EVAL_PAGE;
	}
}

⌨️ 快捷键说明

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