1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.views.jsp;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26 import javax.servlet.jsp.JspException;
27
28 import org.apache.struts2.components.Component;
29 import org.apache.struts2.components.IteratorComponent;
30
31 import com.opensymphony.xwork2.util.ValueStack;
32
33 /***
34 * @see IteratorComponent
35 */
36 public class IteratorTag extends ContextBeanTag {
37
38 private static final long serialVersionUID = -1827978135193581901L;
39
40 protected String statusAttr;
41 protected String value;
42 protected String begin;
43 protected String end;
44 protected String step;
45
46 public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
47 return new IteratorComponent(stack);
48 }
49
50 protected void populateParams() {
51 super.populateParams();
52
53 IteratorComponent tag = (IteratorComponent) getComponent();
54 tag.setStatus(statusAttr);
55 tag.setValue(value);
56 tag.setBegin(begin);
57 tag.setEnd(end);
58 tag.setStep(step);
59 }
60
61 public void setStatus(String status) {
62 this.statusAttr = status;
63 }
64
65 public void setValue(String value) {
66 this.value = value;
67 }
68
69 public void setBegin(String begin) {
70 this.begin = begin;
71 }
72
73 public void setEnd(String end) {
74 this.end = end;
75 }
76
77 public void setStep(String step) {
78 this.step = step;
79 }
80
81 public int doEndTag() throws JspException {
82 component = null;
83 return EVAL_PAGE;
84 }
85
86 public int doAfterBody() throws JspException {
87 boolean again = component.end(pageContext.getOut(), getBody());
88
89 if (again) {
90 return EVAL_BODY_AGAIN;
91 } else {
92 if (bodyContent != null) {
93 try {
94 bodyContent.writeOut(bodyContent.getEnclosingWriter());
95 } catch (Exception e) {
96 throw new JspException(e.getMessage());
97 }
98 }
99 return SKIP_BODY;
100 }
101 }
102
103 }