conditionaltag.java

来自「招标投标网上系统」· Java 代码 · 共 65 行

JAVA
65
字号
/*
 * $Id: ConditionalTag.java,v 1.2 2001/10/18 00:46:06 ro89390 Exp $
 * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
 */

package com.neusoft.taglibs.smart;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

/**
 * A conditional tag.
 *
 * <waf:conditional id="id" scope="scope">
 *   <waf:true>blah</waf:true>
 *   <waf:false>blah</waf:false>
 * </waf:conditional>
 */
public class ConditionalTag
    extends TagSupport {

  boolean value;

  String id;
  String scope;

  public void setId(String i) {
    id = i;
  }

  public void setScope(String s) {
    scope = s;
  }

  public boolean getValue() {
    return value;
  }

  public int doStartTag() throws JspTagException {
    Object o = null;

    if (scope.equals("request")) {
      o = pageContext.getRequest().getAttribute(id);
    }
    else if (scope.equals("session")) {
      o = pageContext.getSession().getAttribute(id);
    }
    else if (scope.equals("page")) {
      o = pageContext.getAttribute(id);
    }

    value = doTest(o);

    return EVAL_BODY_INCLUDE;
  }

  protected boolean doTest(Object o) throws JspTagException {
    return false;
  }

  public int doEndTag() throws JspTagException {
    return EVAL_PAGE;
  }
}

⌨️ 快捷键说明

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