View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  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  
18  //
19  // This source code implements specifications defined by the Java
20  // Community Process. In order to remain compliant with the specification
21  // DO NOT add / change / or delete method signatures!
22  //
23  
24  package javax.servlet.jsp.tagext;
25  
26  import javax.servlet.jsp.JspException;
27  
28  /**
29   * The IterationTag interface extends Tag by defining one additional
30   * method that controls the reevaluation of its body.
31   *
32   * <p> A tag handler that implements IterationTag is treated as one that
33   * implements Tag regarding  the doStartTag() and doEndTag() methods.
34   * IterationTag provides a new method: <code>doAfterBody()</code>.
35   *
36   * <p> The doAfterBody() method is invoked after every body evaluation
37   * to control whether the body will be reevaluated or not.  If doAfterBody()
38   * returns IterationTag.EVAL_BODY_AGAIN, then the body will be reevaluated.
39   * If doAfterBody() returns Tag.SKIP_BODY, then the body will be skipped
40   * and doEndTag() will be evaluated instead.
41   *
42   * <p><B>Properties</B>
43   * There are no new properties in addition to those in Tag.
44   *
45   * <p><B>Methods</B>
46   * There is one new methods: doAfterBody().
47   *
48   * <p><B>Lifecycle</B>
49   *
50   * <p> Lifecycle details are described by the transition diagram
51   * below.  Exceptions that are thrown during the computation of
52   * doStartTag(), BODY and doAfterBody() interrupt the execution
53   * sequence and are propagated up the stack, unless the tag handler
54   * implements the TryCatchFinally interface; see that interface for
55   * details.
56   *
57   * <p>
58   * <IMG src="doc-files/IterationTagProtocol.gif"
59   *      alt="Lifecycle Details Transition Diagram for IterationTag"/>
60   *
61   * <p><B>Empty and Non-Empty Action</B>
62   * <p> If the TagLibraryDescriptor file indicates that the action must
63   * always have an empty element body, by a &lt;body-_content&gt; entry of 
64   * "empty", then the doStartTag() method must return SKIP_BODY.
65   *
66   * <p>Note that which methods are invoked after the doStartTag() depends on
67   * both the return value and on if the custom action element is empty
68   * or not in the JSP page, not on how it's declared in the TLD.
69   *
70   * <p>
71   * If SKIP_BODY is returned the body is not evaluated, and then doEndTag()
72   * is invoked.
73   *
74   * <p>
75   * If EVAL_BODY_INCLUDE is returned, and the custom action element is not
76   * empty, the body is evaluated and "passed through" to the current out, 
77   * then doAfterBody() is invoked and, after zero or more iterations, 
78   * doEndTag() is invoked.
79   */
80  
81  public interface IterationTag extends Tag {
82  
83      /**
84       * Request the reevaluation of some body.
85       * Returned from doAfterBody.
86       *
87       * For compatibility with JSP 1.1, the value is carefully selected
88       * to be the same as the, now deprecated, BodyTag.EVAL_BODY_TAG,
89       * 
90       */
91   
92      public final static int EVAL_BODY_AGAIN = 2;
93  
94      /**
95       * Process body (re)evaluation.  This method is invoked by the
96       * JSP Page implementation object after every evaluation of
97       * the body into the BodyEvaluation object. The method is
98       * not invoked if there is no body evaluation.
99       *
100      * <p>
101      * If doAfterBody returns EVAL_BODY_AGAIN, a new evaluation of the
102      * body will happen (followed by another invocation of doAfterBody).
103      * If doAfterBody returns SKIP_BODY, no more body evaluations will occur,
104      * and the doEndTag method will be invoked.
105      *
106      * <p>
107      * If this tag handler implements BodyTag and doAfterBody returns
108      * SKIP_BODY, the value of out will be restored using the popBody 
109      * method in pageContext prior to invoking doEndTag.
110      *
111      * <p>
112      * The method re-invocations may be lead to different actions because
113      * there might have been some changes to shared state, or because
114      * of external computation.
115      *
116      * <p>
117      * The JSP container will resynchronize the values of any AT_BEGIN and
118      * NESTED variables (defined by the associated TagExtraInfo or TLD) after
119      * the invocation of doAfterBody().
120      *
121      * @return whether additional evaluations of the body are desired
122      * @throws JspException if an error occurred while processing this tag
123      */
124 
125     int doAfterBody() throws JspException;
126 }