diff options
Diffstat (limited to 'src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java')
| -rw-r--r-- | src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java b/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java new file mode 100644 index 0000000..d644ff9 --- /dev/null +++ b/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java @@ -0,0 +1,75 @@ +/** + * + */ +package de.fhswf.in.inf.fit.aufgabe4; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.BodyTagSupport; + +/** + * Handler for the repeat tag. + * + * @author Stefan Suhren + * @version 1.0 + */ +public class Repeat extends BodyTagSupport +{ + /** + * Required attribute for {@link BodyTagSupport}. + */ + private static final long serialVersionUID = 1L; + + /** + * The number of times the Body will be printed. + */ + private int times = 0; + + /** + * Getter for property times. + * + * @return Returns the times. + */ + public int getTimes() + { + return times; + } + + /** + * Setter for property times. + * + * @param times + * The times to set. + */ + public void setTimes(int times) + { + this.times = times; + } + + /* + * (non-Javadoc) + * + * @see javax.servlet.jsp.tagext.BodyTagSupport#doEndTag() + */ + @Override + public int doEndTag() throws JspException + { + String bodyText = bodyContent.getString(); + + for (int i = 0; i < times; i++) + { + try + { + pageContext.getOut().print(bodyText); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + return EVAL_PAGE; + } + +} |
