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

📄 nestedtags.java

📁 servlet与jsp核心编程 书籍源码 部分
💻 JAVA
字号:
/** Template for nested tags.
 *  <P>
 *  Taken from Core Servlets and JavaServer Pages
 *  from Prentice Hall and Sun Microsystems Press,
 *  http://www.coreservlets.com/.
 *  &copy; 2000 Marty Hall; may be freely used or adapted.
 */

public class OuterTag extends TagSupport {
  public void setSomeValue(SomeClass arg) { ... }
  public SomeClass getSomeValue() { ... } 
}

public class FirstInnerTag extends BodyTagSupport {
  public int doStartTag() throws JspTagException {
    OuterTag parent =
      (OuterTag)findAncestorWithClass(this, OuterTag.class);
    if (parent == null) {
      throw new JspTagException("nesting error");
    } else {
      parent.setSomeValue(...);
    }
    return(EVAL_BODY_TAG);
  }
  ...
}

public class SecondInnerTag extends BodyTagSupport {
  public int doStartTag() throws JspTagException {
    OuterTag parent =
      (OuterTag)findAncestorWithClass(this, OuterTag.class);
    if (parent == null) {
      throw new JspTagException("nesting error");
    } else {
      SomeClass value = parent.getSomeValue();
      doSomethingWith(value);
    }
    return(EVAL_BODY_TAG);
  }
  ...
}

⌨️ 快捷键说明

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