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

📄 itemattributetag.java

📁 一个用struts tiles的在线影院web系统
💻 JAVA
字号:
/*
 * ItemAttributeTag
 * ----------------
 * This abstract class works with the list tag package and prints out an
 * attribute of a particular type of item.  The item is retrieved from the
 * outer items tag (an exception is thrown if not inside one).  Depending on
 * the value of the "attribute" attribute a different string is printed - this
 * should be determined in the implementation of createText(), which allows
 * for the details of the class of the item.
 */

package com.eline.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.blue.web.common.util.AppLogger;
/**
 * 
 * @author Lucifer
 *
 */
public abstract class ItemAttributeTag extends TagSupport {

	private static final long serialVersionUID = -965028925620230330L;

	protected Object item = null;
	protected String name = null;

	/**
	 * 
	 * @throws JspException
	 */
	public int doStartTag() throws JspException {
		// check if itemAttribute tag is in items tag
		ItemsTag itemsTag = (ItemsTag) findAncestorWithClass(this, ItemsTag.class);
		if (itemsTag == null) {
			throw new JspTagException("ItemAttributeTag: itemsAttribute tag not inside items tag");
		}
		item = itemsTag.getCurrentItem();

	    // print out attribute
	    try {
	    	JspWriter out = pageContext.getOut();
	    	out.print(createText());
	    } catch(IOException e) {
	        AppLogger.error("ItemAttributeTag: Error printing attribute: " + e);
	    }

	    // there should be no body to process
	    return SKIP_BODY;
	}

	/**
	 * setter for tag attribute
	 * @param attribute
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 
	 * protected abstract methods
	 */
	protected abstract String createText();
}

⌨️ 快捷键说明

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