1
2
3
4
5 package ecar.taglib.teste;
6
7 import java.io.IOException;
8 import java.util.Iterator;
9 import java.util.List;
10
11 import javax.servlet.jsp.JspException;
12 import javax.servlet.jsp.JspWriter;
13 import javax.servlet.jsp.PageContext;
14 import javax.servlet.jsp.tagext.Tag;
15
16
17
18
19
20 public class TagFilho implements Tag{
21
22 private List textos;
23
24 private PageContext page = null;
25
26 private Tag parent;
27
28
29
30
31
32
33
34
35
36
37 public int doStartTag() throws JspException {
38 JspWriter writer = this.page.getOut();
39 StringBuffer s = new StringBuffer();
40 Iterator it = textos.iterator();
41
42 TagPai tagPai = (TagPai) getParent();
43
44 while(it.hasNext())
45 s.append(it.next()).append("e o label da Tag Pai é ").append(tagPai.getLabel()).append(" <BR> " );
46 try {
47 writer.print(s.toString());
48 } catch (IOException e) {
49 org.apache.log4j.Logger.getLogger(this.getClass()).error(e);
50 }
51 return Tag.EVAL_BODY_INCLUDE;
52 }
53
54
55
56
57
58
59
60
61
62 public void setPageContext(PageContext arg0) {
63 this.page = arg0;
64 }
65
66
67
68
69
70
71
72
73
74 public void setParent(Tag arg0) {
75 parent = arg0;
76 }
77
78
79
80
81
82
83
84
85
86 public Tag getParent() {
87 return parent;
88 }
89
90
91
92
93
94
95
96
97
98
99 public int doEndTag() throws JspException {
100 return Tag.EVAL_PAGE;
101 }
102
103
104
105
106
107
108
109
110 public void release() {
111
112 }
113
114
115
116
117
118
119
120
121
122 public PageContext getPage() {
123 return page;
124 }
125
126
127
128
129
130
131
132
133
134 public void setPage(PageContext page) {
135 this.page = page;
136 }
137
138
139
140
141
142
143
144
145
146
147 public List getTextos() {
148 return textos;
149 }
150
151
152
153
154
155
156
157
158
159 public void setTextos(List textos) {
160 this.textos = textos;
161 }
162 }