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