1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * Portions Copyright Apache Software Foundation.
7 *
8 * The contents of this file are subject to the terms of either the GNU
9 * General Public License Version 2 only ("GPL") or the Common Development
10 * and Distribution License("CDDL") (collectively, the "License"). You
11 * may not use this file except in compliance with the License. You can obtain
12 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
13 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
14 * language governing permissions and limitations under the License.
15 *
16 * When distributing the software, include this License Header Notice in each
17 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
18 * Sun designates this particular file as subject to the "Classpath" exception
19 * as provided by Sun in the GPL Version 2 section of the License file that
20 * accompanied this code. If applicable, add the following below the License
21 * Header, with the fields enclosed by brackets [] replaced by your own
22 * identifying information: "Portions Copyrighted [year]
23 * [name of copyright owner]"
24 *
25 * Contributor(s):
26 *
27 * If you wish your version of this file to be governed by only the CDDL or
28 * only the GPL Version 2, indicate your decision by adding "[Contributor]
29 * elects to include this software in this distribution under the [CDDL or GPL
30 * Version 2] license." If you don't indicate a single choice of license, a
31 * recipient has the option to distribute your version of this file under
32 * either the CDDL, the GPL Version 2 or to extend the choice of license to
33 * its licensees as provided above. However, if you add GPL Version 2 code
34 * and therefore, elected the GPL Version 2 license, then the option applies
35 * only if the new code is made subject to such option by the copyright
36 * holder.
37 */
38 package javax.servlet.jsp.tagext;
39
40 import javax.servlet.jsp;
41
42 /**
43 * The IterationTag interface extends Tag by defining one additional
44 * method that controls the reevaluation of its body.
45 *
46 * <p> A tag handler that implements IterationTag is treated as one that
47 * implements Tag regarding the doStartTag() and doEndTag() methods.
48 * IterationTag provides a new method: <code>doAfterBody()</code>.
49 *
50 * <p> The doAfterBody() method is invoked after every body evaluation
51 * to control whether the body will be reevaluated or not. If doAfterBody()
52 * returns IterationTag.EVAL_BODY_AGAIN, then the body will be reevaluated.
53 * If doAfterBody() returns Tag.SKIP_BODY, then the body will be skipped
54 * and doEndTag() will be evaluated instead.
55 *
56 * <p><B>Properties</B>
57 * There are no new properties in addition to those in Tag.
58 *
59 * <p><B>Methods</B>
60 * There is one new methods: doAfterBody().
61 *
62 * <p><B>Lifecycle</B>
63 *
64 * <p> Lifecycle details are described by the transition diagram
65 * below. Exceptions that are thrown during the computation of
66 * doStartTag(), BODY and doAfterBody() interrupt the execution
67 * sequence and are propagated up the stack, unless the tag handler
68 * implements the TryCatchFinally interface; see that interface for
69 * details.
70 *
71 * <p>
72 * <IMG src="doc-files/IterationTagProtocol.gif"
73 * alt="Lifecycle Details Transition Diagram for IterationTag"/>
74 *
75 * <p><B>Empty and Non-Empty Action</B>
76 * <p> If the TagLibraryDescriptor file indicates that the action must
77 * always have an empty element body, by a <body-content> entry of
78 * "empty", then the doStartTag() method must return SKIP_BODY.
79 *
80 * <p>Note that which methods are invoked after the doStartTag() depends on
81 * both the return value and on if the custom action element is empty
82 * or not in the JSP page, not on how it's declared in the TLD.
83 *
84 * <p>
85 * If SKIP_BODY is returned the body is not evaluated, and then doEndTag()
86 * is invoked.
87 *
88 * <p>
89 * If EVAL_BODY_INCLUDE is returned, and the custom action element is not
90 * empty, the body is evaluated and "passed through" to the current out,
91 * then doAfterBody() is invoked and, after zero or more iterations,
92 * doEndTag() is invoked.
93 */
94
95 public interface IterationTag extends Tag {
96
97 /**
98 * Request the reevaluation of some body.
99 * Returned from doAfterBody.
100 *
101 * For compatibility with JSP 1.1, the value is carefully selected
102 * to be the same as the, now deprecated, BodyTag.EVAL_BODY_TAG,
103 *
104 */
105
106 public final static int EVAL_BODY_AGAIN = 2;
107
108 /**
109 * Process body (re)evaluation. This method is invoked by the
110 * JSP Page implementation object after every evaluation of
111 * the body into the BodyEvaluation object. The method is
112 * not invoked if there is no body evaluation.
113 *
114 * <p>
115 * If doAfterBody returns EVAL_BODY_AGAIN, a new evaluation of the
116 * body will happen (followed by another invocation of doAfterBody).
117 * If doAfterBody returns SKIP_BODY, no more body evaluations will occur,
118 * and the doEndTag method will be invoked.
119 *
120 * <p>
121 * If this tag handler implements BodyTag and doAfterBody returns
122 * SKIP_BODY, the value of out will be restored using the popBody
123 * method in pageContext prior to invoking doEndTag.
124 *
125 * <p>
126 * The method re-invocations may be lead to different actions because
127 * there might have been some changes to shared state, or because
128 * of external computation.
129 *
130 * <p>
131 * The JSP container will resynchronize the values of any AT_BEGIN and
132 * NESTED variables (defined by the associated TagExtraInfo or TLD) after
133 * the invocation of doAfterBody().
134 *
135 * @return whether additional evaluations of the body are desired
136 * @throws JspException if an error occurred while processing this tag
137 */
138
139 int doAfterBody() throws JspException;
140 }