1
2
3
4
5 package ecar.taglib.util;
6
7 import java.util.Iterator;
8 import java.util.List;
9
10 import javax.servlet.jsp.JspException;
11 import javax.servlet.jsp.JspWriter;
12 import javax.servlet.jsp.tagext.Tag;
13 import javax.servlet.jsp.tagext.TagSupport;
14
15 import ecar.exception.ECARException;
16
17
18
19
20
21 public class BarraLinksRelatorioItens extends TagSupport{
22
23 private static final long serialVersionUID = 2869225621544161026L;
24
25 private String chamarPagina;
26 private String complementoRequest;
27 private List itensBarra;
28 private int indexAtivo;
29 private String semLinks;
30
31 private static final String ABA_HABILITADA = "abarelatoriohabilitada";
32 private static final String ABA_DESABILITADA = "abarelatoriodesabilitada";
33
34
35
36
37
38
39
40
41
42
43 public int doStartTag() throws JspException {
44 JspWriter writer = this.pageContext.getOut();
45 try {
46 StringBuffer s = new StringBuffer();
47
48 if(itensBarra != null && itensBarra.size() > 0){
49
50 s.append("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" id=\"abastipoacompanhamento\">")
51 .append("<tr>")
52 .append("<td class=\"texto_negrito\">");
53
54 Iterator itItens = itensBarra.iterator();
55
56 int index = 0;
57 while (itItens.hasNext()) {
58 String item = (String) itItens.next();
59
60 String situacaoAba = ABA_DESABILITADA;
61 if(index == indexAtivo) {
62 situacaoAba = ABA_HABILITADA;
63 }
64
65 String comp = "";
66 if(complementoRequest != null)
67 comp = complementoRequest;
68
69 criaAba(item, getChamarPagina() + "?proximaAba=" + index + comp, situacaoAba, s);
70 index++;
71 }
72
73 s.append("</td>")
74 .append("</tr>")
75 .append("</table>");
76 }
77
78 writer.print(s.toString());
79 } catch (Exception e) {
80 ;
81 }
82 return Tag.SKIP_BODY;
83
84 }
85
86
87
88
89
90
91
92
93
94
95
96
97
98 private void criaAba(String label, String pagina, String situacaoAba, StringBuffer s) throws ECARException{
99 s.append("<table class=\"").append(situacaoAba).append("\">")
100 .append("<tr>")
101 .append("<td nowrap>");
102
103 if(!"S".equals(getSemLinks())){
104 s.append("<a href=\"").append(pagina).append("\">");
105 }
106
107 s.append(label);
108
109 if(!"S".equals(getSemLinks())){
110 s.append("</a>");
111 }
112
113 s.append("</td>")
114 .append("</tr>")
115 .append("</table>");
116 }
117
118
119
120
121
122
123
124
125
126
127 public int doEndTag() throws JspException {
128
129 return Tag.EVAL_PAGE;
130 }
131
132
133
134
135
136
137
138
139
140 public String getChamarPagina() {
141 return chamarPagina;
142 }
143
144
145
146
147
148
149
150
151
152 public void setChamarPagina(String chamarPagina) {
153 this.chamarPagina = chamarPagina;
154 }
155
156
157
158
159
160
161
162
163
164 public int getIndexAtivo() {
165 return indexAtivo;
166 }
167
168
169
170
171
172
173
174
175
176 public void setIndexAtivo(int indexAtivo) {
177 this.indexAtivo = indexAtivo;
178 }
179
180
181
182
183
184
185
186
187
188 public List getItensBarra() {
189 return itensBarra;
190 }
191
192
193
194
195
196
197
198
199
200 public void setItensBarra(List itensBarra) {
201 this.itensBarra = itensBarra;
202 }
203
204
205
206
207
208
209
210
211
212 public String getComplementoRequest() {
213 return complementoRequest;
214 }
215
216
217
218
219
220
221
222
223
224 public void setComplementoRequest(String complementoRequest) {
225 this.complementoRequest = complementoRequest;
226 }
227
228
229
230
231
232
233
234
235
236 public String getSemLinks() {
237 return semLinks;
238 }
239
240
241
242
243
244
245
246
247
248 public void setSemLinks(String semLinks) {
249 this.semLinks = semLinks;
250 }
251 }