summaryrefslogtreecommitdiffstats
path: root/src/de/fhswf
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/fhswf')
-rw-r--r--src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java b/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java
index d644ff9..2702f79 100644
--- a/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java
+++ b/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java
@@ -3,8 +3,6 @@
*/
package de.fhswf.in.inf.fit.aufgabe4;
-import java.io.IOException;
-
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
@@ -48,28 +46,38 @@ public class Repeat extends BodyTagSupport
}
/*
- * (non-Javadoc)
+ * Make sure that the input body will be printed.
*
- * @see javax.servlet.jsp.tagext.BodyTagSupport#doEndTag()
+ * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag()
*/
@Override
- public int doEndTag() throws JspException
+ public int doStartTag() throws JspException
{
- String bodyText = bodyContent.getString();
-
- for (int i = 0; i < times; i++)
+ if (times <= 0)
{
- try
- {
- pageContext.getOut().print(bodyText);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
+ return SKIP_BODY;
+ }
+ else
+ {
+ return EVAL_BODY_INCLUDE;
}
-
- return EVAL_PAGE;
}
+ /*
+ * Repeat the body a given time.
+ *
+ * @see javax.servlet.jsp.tagext.BodyTagSupport#doAfterBody()
+ */
+ @Override
+ public int doAfterBody() throws JspException
+ {
+ if (--times > 0)
+ {
+ return EVAL_BODY_AGAIN;
+ }
+ else
+ {
+ return SKIP_BODY;
+ }
+ }
}