View Javadoc

1   /*
2   * Licensed to the Apache Software Foundation (ASF) under one or more
3   * contributor license agreements.  See the NOTICE file distributed with
4   * this work for additional information regarding copyright ownership.
5   * The ASF licenses this file to You under the Apache License, Version 2.0
6   * (the "License"); you may not use this file except in compliance with
7   * the License.  You may obtain a copy of the License at
8   *
9   *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17  package examples;
18  
19  import javax.servlet.jsp.JspException;
20  import javax.servlet.jsp.PageContext;
21  import javax.servlet.jsp.tagext.BodyContent;
22  import javax.servlet.jsp.tagext.BodyTagSupport;
23  import javax.servlet.jsp.tagext.Tag;
24  
25  public abstract class ExampleTagBase extends BodyTagSupport {
26  
27      public void setParent(Tag parent) {
28          this.parent = parent;
29      }
30  
31      public void setBodyContent(BodyContent bodyOut) {
32          this.bodyOut = bodyOut;
33      }
34  
35      public void setPageContext(PageContext pageContext) {
36          this.pageContext = pageContext;
37      }
38  
39      public Tag getParent() {
40          return this.parent;
41      }
42  
43      public int doStartTag() throws JspException {
44          return SKIP_BODY;
45      }
46  
47      public int doEndTag() throws JspException {
48          return EVAL_PAGE;
49      }
50  
51  
52      // Default implementations for BodyTag methods as well
53      // just in case a tag decides to implement BodyTag.
54      public void doInitBody() throws JspException {
55      }
56  
57      public int doAfterBody() throws JspException {
58          return SKIP_BODY;
59      }
60  
61      public void release() {
62          bodyOut = null;
63          pageContext = null;
64          parent = null;
65      }
66  
67      protected BodyContent bodyOut;
68      protected PageContext pageContext;
69      protected Tag parent;
70  }