notetag.java

来自「一个jsp写的bbs」· Java 代码 · 共 83 行

JAVA
83
字号
package com.laoer.bbscs.web.taglib;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import org.apache.struts.taglib.TagUtils;
import com.laoer.bbscs.bean.Note;

/**
 * <p>Title: Tianyi BBS</p>
 *
 * <p>Description: BBSCS</p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: Laoer.com</p>
 *
 * @author Gong Tianyi
 * @version 7.0
 */
public class NoteTag
    extends TagSupport {

  protected String name = "";

  protected String property = null;

  protected String scope = null;

  public NoteTag() {
  }

  public int doStartTag() throws JspException {
    return (SKIP_BODY);
  }

  public int doEndTag() throws JspException {
    //Note note;
    Object value = TagUtils.getInstance().lookup(pageContext, name, property, scope);
    if (value == null) {
      return (SKIP_BODY);
    }
    int isNew = ( (Integer) value).intValue();
    StringBuffer sb = new StringBuffer();
    if (isNew == 0) {
      sb.append("<img src=\"images/note_old.gif\" alt=\"\"/>");
    }

    if (isNew == 1) {
      sb.append("<img src=\"images/note_new.gif\" alt=\"\"/>");
    }
    //if (isNew == 2) {
      //sb.append("<img src=\"images/note_replied.gif\"/>");
    //}
    TagUtils.getInstance().write(pageContext, sb.toString());
    return (SKIP_BODY);

  }

  public String getName() {
    return name;
  }

  public String getProperty() {
    return property;
  }

  public String getScope() {
    return scope;
  }

  public void setName(String name) {
    this.name = name;
  }

  public void setProperty(String property) {
    this.property = property;
  }

  public void setScope(String scope) {
    this.scope = scope;
  }
}

⌨️ 快捷键说明

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