1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. * Copyright (c) 1999 The Apache Software Foundation. All rights
  5. * reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if
  20. * any, must include the following acknowlegement:
  21. * "This product includes software developed by the
  22. * Apache Software Foundation (http://www.apache.org/)."
  23. * Alternately, this acknowlegement may appear in the software itself,
  24. * if and wherever such third-party acknowlegements normally appear.
  25. *
  26. * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  27. * Foundation" must not be used to endorse or promote products derived
  28. * from this software without prior written permission. For written
  29. * permission, please contact apache@apache.org.
  30. *
  31. * 5. Products derived from this software may not be called "Apache"
  32. * nor may "Apache" appear in their names without prior written
  33. * permission of the Apache Group.
  34. *
  35. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This software consists of voluntary contributions made by many
  50. * individuals on behalf of the Apache Software Foundation. For more
  51. * information on the Apache Software Foundation, please see
  52. * <http://www.apache.org/>.
  53. *
  54. */
  55. package javax.servlet.jsp.tagext;
  56. import javax.servlet.jsp.*;
  57. /**
  58. * The IterationTag interface extends Tag by defining one additional
  59. * method that controls the reevaluation of its body.
  60. *
  61. * <p> A tag handler that implements IterationTag is treated as one that
  62. * implements Tag regarding the doStartTag() and doEndTag() methods.
  63. * IterationTag provides a new method: <code>doAfterBody()</code>.
  64. *
  65. * <p> The doAfterBody() method is invoked after every body evaluation
  66. * to control whether the body will be reevaluated or not. If doAfterBody()
  67. * returns IterationTag.EVAL_BODY_AGAIN, then the body will be reevaluated.
  68. * If doAfterBody() returns Tag.SKIP_BODY, then the body will be skipped
  69. * and doEndTag() will be evaluated instead.
  70. *
  71. * <p><B>Properties</B>
  72. * There are no new properties in addition to those in Tag.
  73. *
  74. * <p><B>Methods</B>
  75. * There is one new methods: doAfterBody().
  76. *
  77. * <p><B>Lifecycle</B>
  78. *
  79. * <p> Lifecycle details are described by the transition diagram
  80. * below. Exceptions that are thrown during the computation of
  81. * doStartTag(), BODY and doAfterBody() interrupt the execution
  82. * sequence and are propagated up the stack, unless the tag handler
  83. * implements the TryCatchFinally interface; see that interface for
  84. * details.
  85. *
  86. * <p>
  87. * <IMG src="doc-files/IterationTagProtocol.gif"/>
  88. *
  89. * <p><B>Empty and Non-Empty Action</B>
  90. * <p> If the TagLibraryDescriptor file indicates that the action must
  91. * always have an empty action, by an <body-content> entry of "empty",
  92. * then the doStartTag() method must return SKIP_BODY.
  93. *
  94. * Otherwise, the doStartTag() method may return SKIP_BODY or
  95. * EVAL_BODY_INCLUDE.
  96. *
  97. * <p>
  98. * If SKIP_BODY is returned the body is not evaluated, and then doEndTag()
  99. * is invoked.
  100. *
  101. * <p>
  102. * If EVAL_BODY_INCLUDE is returned, the body is evaluated and
  103. * "passed through" to the current out, then doAfterBody() is invoked
  104. * and, after zero or more iterations, doEndTag() is invoked.
  105. */
  106. public interface IterationTag extends Tag {
  107. /**
  108. * Request the reevaluation of some body.
  109. * Returned from doAfterBody.
  110. *
  111. * For compatibility with JSP 1.1, the value is carefully selected
  112. * to be the same as the, now deprecated, BodyTag.EVAL_BODY_TAG,
  113. *
  114. */
  115. public final static int EVAL_BODY_AGAIN = 2;
  116. /**
  117. * Process body (re)evaluation. This method is invoked by the
  118. * JSP Page implementation object after every evaluation of
  119. * the body into the BodyEvaluation object. The method is
  120. * not invoked if there is no body evaluation.
  121. *
  122. * <p>
  123. * If doAfterBody returns EVAL_BODY_AGAIN, a new evaluation of the
  124. * body will happen (followed by another invocation of doAfterBody).
  125. * If doAfterBody returns SKIP_BODY no more body evaluations will
  126. * occur, the value of out will be restored using the popBody method
  127. * in pageContext, and then doEndTag will be invoked.
  128. *
  129. * <p>
  130. * The method re-invocations may be lead to different actions because
  131. * there might have been some changes to shared state, or because
  132. * of external computation.
  133. *
  134. * <p>
  135. * The JSP container will resynchronize
  136. * any variable values that are indicated as so in TagExtraInfo after the
  137. * invocation of doAfterBody().
  138. *
  139. * @return whether additional evaluations of the body are desired
  140. * @throws JspException
  141. */
  142. int doAfterBody() throws JspException;
  143. }