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
19
20 public class LinkStopTag extends TagSupport {
21
22
23
24
25 private static final long serialVersionUID = 7350219627754223836L;
26
27 private Logger logger = Logger.getLogger(this.getClass());
28
29
30
31 private final String DIVISAO = " | ";
32
33
34 private String incluir;
35 private String alterar;
36 private String excluir;
37 private String pesquisar;
38
39
40
41
42
43
44
45
46
47
48 public int doStartTag() throws JspException {
49 JspWriter writer = this.pageContext.getOut();
50 boolean imprimiu = false;
51
52 try {
53 writer.println("<div id=\"linkstop\">");
54 if (this.getIncluir() != null) {
55 writer.println(imprimiu ? DIVISAO : "");
56 writer.println("<a href=\"" + this.getIncluir() + "\">Incluir</a>");
57 imprimiu = true;
58 }
59
60 if (this.getAlterar() != null){
61 writer.println(imprimiu ? DIVISAO : "");
62 writer.println("<a href=\"" + this.getAlterar() + "\">Alterar</a>");
63 imprimiu = true;
64 }
65
66 if (this.getExcluir() != null){
67 writer.println(imprimiu ? DIVISAO : "");
68 writer.println("<a href=\"" + this.getExcluir() + "\">Excluir</a>");
69 imprimiu = true;
70 }
71
72 if (this.getPesquisar() != null){
73 writer.println(imprimiu ? DIVISAO : "");
74 writer.println("<a href=\"" + this.getPesquisar() + "\">Pesquisar</a>");
75 imprimiu = true;
76 }
77 writer.println("</div>");
78 } catch (Exception e) {
79 logger.error(e);
80 }
81 return Tag.SKIP_BODY;
82 }
83
84
85
86
87
88
89
90
91
92
93 public int doEndTag() throws JspException {
94 return Tag.EVAL_PAGE;
95 }
96
97
98
99
100
101
102
103
104
105 public String getAlterar() {
106 return alterar;
107 }
108
109
110
111
112
113
114
115
116
117 public void setAlterar(String alterar) {
118 this.alterar = alterar;
119 }
120
121
122
123
124
125
126
127
128
129 public String getExcluir() {
130 return excluir;
131 }
132
133
134
135
136
137
138
139
140
141 public void setExcluir(String excluir) {
142 this.excluir = excluir;
143 }
144
145
146
147
148
149
150
151
152
153 public String getIncluir() {
154 return incluir;
155 }
156
157
158
159
160
161
162
163
164
165 public void setIncluir(String incluir) {
166 this.incluir = incluir;
167 }
168
169
170
171
172
173
174
175
176
177 public String getPesquisar() {
178 return pesquisar;
179 }
180
181
182
183
184
185
186
187
188
189 public void setPesquisar(String pesquisar) {
190 this.pesquisar = pesquisar;
191 }
192 }