📄 conditionaltag.java
字号:
/*
* $Id: ConditionalTag.java,v 1.2 2001/10/18 00:46:06 ro89390 Exp $
* Copyright 2001 Sun Microsystems, Inc. All rights reserved.
*/
package com.sure.taglibs.smart;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import java.util.Collection;
/**
* 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 BodyTagSupport {
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -