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