blob: 2702f795301046795b6943cd33dd2da9a3de8322 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/**
*
*/
package de.fhswf.in.inf.fit.aufgabe4;
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;
}
/*
* Make sure that the input body will be printed.
*
* @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag()
*/
@Override
public int doStartTag() throws JspException
{
if (times <= 0)
{
return SKIP_BODY;
}
else
{
return EVAL_BODY_INCLUDE;
}
}
/*
* 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;
}
}
}
|