1
2
3
4
5 package ecar.taglib.util;
6
7 import javax.servlet.jsp.JspException;
8 import javax.servlet.jsp.JspWriter;
9 import javax.servlet.jsp.tagext.Tag;
10 import javax.servlet.jsp.tagext.TagSupport;
11
12 import org.apache.log4j.Logger;
13
14
15
16
17
18 public class BarraBotoesTag extends TagSupport {
19
20
21
22
23 private static final long serialVersionUID = 7126604742141401956L;
24
25 private Logger logger = Logger.getLogger(this.getClass());
26
27
28
29 private final String DIVISAO = "";
30
31
32 private String navegacao;
33 private String btn1;
34 private Boolean exibirBtn1;
35 private String btn2;
36 private Boolean exibirBtn2;
37 private String btn3;
38 private Boolean exibirBtn3;
39 private String incluir;
40 private Boolean exibirIncluir;
41 private String alterar;
42 private Boolean exibirAlterar;
43 private String excluir;
44 private Boolean exibirExcluir;
45 private String pesquisar;
46 private String cancelar;
47 private Boolean esconderCancelar;
48 private String voltar;
49 private int atual;
50 private int total;
51 private Boolean desabilitarBtn3;
52
53 private String textoDireita;
54
55 public String getTextoDireita() {
56 return textoDireita;
57 }
58
59 public void setTextoDireita(String textoDireita) {
60 this.textoDireita = textoDireita;
61 }
62
63
64
65
66
67
68
69
70
71 public Boolean getDesabilitarBtn3() {
72 return desabilitarBtn3;
73 }
74
75
76
77
78
79
80
81
82
83 public void setDesabilitarBtn3(Boolean desabilitarBtn3) {
84 this.desabilitarBtn3 = desabilitarBtn3;
85 }
86
87
88
89
90
91
92
93
94
95
96 public int doStartTag() throws JspException {
97 JspWriter writer = this.pageContext.getOut();
98
99 boolean imprimiu = false;
100
101 try {
102 writer.println("<table class=\"barrabotoes\" cellpadding=\"0\" cellspacing=\"0\">");
103 writer.println("<tr>");
104
105 writer.println("<td class=\"label\">");
106
107
108 if (this.getAtual() != 0)
109 writer.println(this.getAtual());
110
111 if (this.getTotal() != 0) {
112 if (this.getAtual() != 0)
113 writer.println(" de ");
114 writer.println(this.getTotal());
115 }
116
117 writer.println(" </td>");
118 writer.println("<td>");
119
120 if (this.getNavegacao() != null) {
121 writer.println(imprimiu ? DIVISAO : "");
122 writer.println("<input name=\"btnPrimeiro\" type=\"button\" value=\"<<\" class=\"botao\" onclick=\"aoClicarPrimeiro(form);\">");
123 writer.println(imprimiu ? DIVISAO : "");
124 writer.println("<input name=\"btnAnterior\" type=\"button\" value=\"<\" class=\"botao\" onclick=\"aoClicarAnterior(form);\">");
125 writer.println(imprimiu ? DIVISAO : "");
126 writer.println("<input name=\"btnProximo\" type=\"button\" value=\">\" class=\"botao\" onclick=\"aoClicarProximo(form);\">");
127 writer.println(imprimiu ? DIVISAO : "");
128 writer.println("<input name=\"btnUltimo\" type=\"button\" value=\">>\" class=\"botao\" onclick=\"aoClicarUltimo(form);\">");
129 imprimiu = true;
130 }
131
132 if (this.getBtn1() != null && (this.getExibirBtn1() == null || this.getExibirBtn1().booleanValue()) ) {
133 writer.println(imprimiu ? DIVISAO : "");
134 writer.println("<input name=\"btn1\" type=\"button\" value=\"" + this.getBtn1() + "\" class=\"botao\" onclick=\"aoClicarBtn1(form);\">");
135 imprimiu = true;
136 }
137
138 if (this.getBtn2() != null && (this.getExibirBtn2() == null || this.getExibirBtn2().booleanValue()) ) {
139 writer.println(imprimiu ? DIVISAO : "");
140 writer.println("<input name=\"btn2\" type=\"button\" value=\"" + this.getBtn2() + "\" class=\"botao\" onclick=\"aoClicarBtn2(form);\">");
141 imprimiu = true;
142 }
143
144 if (this.getBtn3() != null && (this.getExibirBtn3() == null || this.getExibirBtn3().booleanValue()) ) {
145 writer.println(imprimiu ? DIVISAO : "");
146 String disabled = "";
147
148 if(this.getDesabilitarBtn3() != null && this.getDesabilitarBtn3().booleanValue()) {
149 disabled = "disabled";
150 }
151
152 writer.println("<input name=\"btn3\" type=\"button\" value=\"" + this.getBtn3() + "\" " + disabled + " class=\"botao\" onclick=\"aoClicarBtn3(form);\">");
153 imprimiu = true;
154 }
155
156 if (this.getIncluir() != null && (this.getExibirIncluir() == null || this.getExibirIncluir().booleanValue()) ) {
157 writer.println(imprimiu ? DIVISAO : "");
158 writer.println("<input name=\"btnGravar\" type=\"button\" value=\"" + this.getIncluir() + "\" class=\"botao\" onclick=\"aoClicarGravar(form);\">");
159 imprimiu = true;
160 }
161
162 if (this.getAlterar() != null && (this.getExibirAlterar() == null || this.getExibirAlterar().booleanValue()) ){
163 writer.println(imprimiu ? DIVISAO : "");
164 writer.println("<input name=\"btnAlterar\" type=\"button\" value=\"" + this.getAlterar() + "\" class=\"botao\" onclick=\"aoClicarAlterar(form);\">");
165 imprimiu = true;
166 }
167
168 if (this.getExcluir() != null && (this.getExibirExcluir() == null || this.getExibirExcluir().booleanValue()) ){
169 writer.println(imprimiu ? DIVISAO : "");
170 writer.println("<input name=\"btnExcluir\" type=\"button\" value=\"" + this.getExcluir() + "\" class=\"botao\" onclick=\"aoClicarExcluir(form);\">");
171 imprimiu = true;
172 }
173
174 if (this.getPesquisar() != null){
175 writer.println(imprimiu ? DIVISAO : "");
176 writer.println("<input name=\"btnPesquisar\" type=\"button\" value=\"" + this.getPesquisar() + "\" class=\"botao\" onclick=\"aoClicarPesquisar(form);\">");
177 imprimiu = true;
178 }
179
180 if (this.getCancelar() != null){
181 writer.println(imprimiu ? DIVISAO : "");
182 if(this.getEsconderCancelar() != null && this.getEsconderCancelar().booleanValue()){
183 writer.println("<input style=\"display:none;\" name=\"btnCancelar\" type=\"button\" value=\"" + this.getCancelar() + "\" class=\"botao\" onclick=\"aoClicarCancelar(form);\">");
184 }else{
185 writer.println("<input name=\"btnCancelar\" type=\"button\" value=\"" + this.getCancelar() + "\" class=\"botao\" onclick=\"aoClicarCancelar(form);\">");
186 }
187 imprimiu = true;
188 }
189
190 if (this.getVoltar() != null){
191 writer.println(imprimiu ? DIVISAO : "");
192 writer.println("<input name=\"btnVoltar\" type=\"button\" value=\"" + this.getVoltar() + "\" class=\"botao\" onclick=\"aoClicarVoltar(form);\">");
193 imprimiu = true;
194 }
195
196 writer.println("</td>");
197 if(this.getTextoDireita() != null && !"".equals(this.getTextoDireita())) {
198 writer.println("<td class=\"texto\" align=\"right\">");
199 writer.println(this.getTextoDireita());
200 writer.println("<td>");
201 }
202 writer.println("</tr>");
203 writer.println("</table>");
204 } catch (Exception e) {
205 logger.error(e);
206 }
207
208 return Tag.SKIP_BODY;
209 }
210
211
212
213
214
215
216
217
218
219
220 public int doEndTag() throws JspException {
221
222 return Tag.EVAL_PAGE;
223 }
224
225
226
227
228
229
230
231
232
233 public String getAlterar() {
234 return alterar;
235 }
236
237
238
239
240
241
242
243
244
245 public void setAlterar(String alterar) {
246 this.alterar = alterar;
247 }
248
249
250
251
252
253
254
255
256
257 public String getExcluir() {
258 return excluir;
259 }
260
261
262
263
264
265
266
267
268
269 public void setExcluir(String excluir) {
270 this.excluir = excluir;
271 }
272
273
274
275
276
277
278
279
280
281 public String getIncluir() {
282 return incluir;
283 }
284
285
286
287
288
289
290
291
292
293 public void setIncluir(String incluir) {
294 this.incluir = incluir;
295 }
296
297
298
299
300
301
302
303
304
305 public String getPesquisar() {
306 return pesquisar;
307 }
308
309
310
311
312
313
314
315
316
317 public void setPesquisar(String pesquisar) {
318 this.pesquisar = pesquisar;
319 }
320
321
322
323
324
325
326
327
328
329 public String getCancelar() {
330 return cancelar;
331 }
332
333
334
335
336
337
338
339
340
341 public void setCancelar(String cancelar) {
342 this.cancelar = cancelar;
343 }
344
345
346
347
348
349
350
351
352
353 public String getVoltar() {
354 return voltar;
355 }
356
357
358
359
360
361
362
363
364
365 public void setVoltar(String voltar) {
366 this.voltar = voltar;
367 }
368
369
370
371
372
373
374
375
376
377 public String getNavegacao() {
378 return navegacao;
379 }
380
381
382
383
384
385
386
387
388
389 public void setNavegacao(String navegacao) {
390 this.navegacao = navegacao;
391 }
392
393
394
395
396
397
398
399
400
401 public String getBtn1() {
402 return btn1;
403 }
404
405
406
407
408
409
410
411
412
413 public void setBtn1(String btn1) {
414 this.btn1 = btn1;
415 }
416
417
418
419
420
421
422
423
424
425 public String getBtn2() {
426 return btn2;
427 }
428
429
430
431
432
433
434
435
436
437 public void setBtn2(String btn2) {
438 this.btn2 = btn2;
439 }
440
441
442
443
444
445
446
447
448
449 public String getBtn3() {
450 return btn3;
451 }
452
453
454
455
456
457
458
459
460
461 public void setBtn3(String btn3) {
462 this.btn3 = btn3;
463 }
464
465
466
467
468
469
470
471
472
473 public int getAtual() {
474 return atual;
475 }
476
477
478
479
480
481
482
483
484
485 public void setAtual(int atual) {
486 this.atual = atual;
487 }
488
489
490
491
492
493
494
495
496
497 public int getTotal() {
498 return total;
499 }
500
501
502
503
504
505
506
507
508
509 public void setTotal(int total) {
510 this.total = total;
511 }
512
513
514
515
516
517
518
519
520
521 public Boolean getExibirAlterar() {
522 return exibirAlterar;
523 }
524
525
526
527
528
529
530
531
532
533 public void setExibirAlterar(Boolean exibirAlterar) {
534 this.exibirAlterar = exibirAlterar;
535 }
536
537
538
539
540
541
542
543
544
545 public Boolean getExibirBtn1() {
546 return exibirBtn1;
547 }
548
549
550
551
552
553
554
555
556
557 public void setExibirBtn1(Boolean exibirBtn1) {
558 this.exibirBtn1 = exibirBtn1;
559 }
560
561
562
563
564
565
566
567
568
569 public Boolean getExibirBtn2() {
570 return exibirBtn2;
571 }
572
573
574
575
576
577
578
579
580
581 public void setExibirBtn2(Boolean exibirBtn2) {
582 this.exibirBtn2 = exibirBtn2;
583 }
584
585
586
587
588
589
590
591
592
593
594 public Boolean getExibirBtn3() {
595 return exibirBtn3;
596 }
597
598
599
600
601
602
603
604
605
606 public void setExibirBtn3(Boolean exibirBtn3) {
607 this.exibirBtn3 = exibirBtn3;
608 }
609
610
611
612
613
614
615
616
617
618
619 public Boolean getExibirExcluir() {
620 return exibirExcluir;
621 }
622
623
624
625
626
627
628
629
630
631 public void setExibirExcluir(Boolean exibirExcluir) {
632 this.exibirExcluir = exibirExcluir;
633 }
634
635
636
637
638
639
640
641
642
643 public Boolean getExibirIncluir() {
644 return exibirIncluir;
645 }
646
647
648
649
650
651
652
653
654
655 public void setExibirIncluir(Boolean exibirIncluir) {
656 this.exibirIncluir = exibirIncluir;
657 }
658
659
660
661
662
663
664
665
666
667 public Boolean getEsconderCancelar() {
668 return esconderCancelar;
669 }
670
671
672
673
674
675
676
677
678
679 public void setEsconderCancelar(Boolean esconderCancelar) {
680 this.esconderCancelar = esconderCancelar;
681 }
682 }