1
2
3
4
5 package ecar.taglib.util;
6
7 import java.util.Iterator;
8 import java.util.List;
9 import javax.servlet.jsp.JspException;
10 import javax.servlet.jsp.JspWriter;
11 import javax.servlet.jsp.tagext.Tag;
12 import javax.servlet.jsp.tagext.TagSupport;
13 import comum.util.Pagina;
14 import ecar.dao.LinkDao;
15 import ecar.exception.ECARException;
16 import ecar.pojo.Link;
17
18
19
20
21
22 public class BarraLinksTag extends TagSupport{
23
24
25
26
27 private static final long serialVersionUID = -4043310305013938101L;
28
29
30
31
32 private Boolean verificaMonitoramento;
33 private String _pathEcar;
34 private String pathRaizUpload;
35
36
37
38
39
40
41
42
43
44
45 public int doStartTag() throws JspException {
46
47 JspWriter writer = this.pageContext.getOut();
48 try {
49
50 StringBuffer s = new StringBuffer();
51
52 pathRaizUpload = new ecar.dao.ConfiguracaoDao(null).getConfiguracao().getRaizUpload();
53 LinkDao linkDao = new LinkDao(null);
54 List links = linkDao.listar(Link.class, new String[]{"ordemLink", "asc"});
55 Iterator itLinks = links.iterator();
56 Link link = new Link();
57
58 if(verificaMonitoramento){
59 while(itLinks.hasNext()){
60 link = (Link) itLinks.next();
61 if(link.getExibeMonitoramentoLink()!=null && link.getExibeMonitoramentoLink().equals(Pagina.SIM)){
62 criaLink(link,s);
63 }
64 }
65 } else{
66 while(itLinks.hasNext()){
67 link = (Link) itLinks.next();
68 criaLink(link,s);
69 }
70 }
71
72 writer.print(s.toString());
73 } catch (Exception e) {
74 org.apache.log4j.Logger.getLogger(this.getClass()).error(e);
75 e.printStackTrace();
76 }
77 return Tag.SKIP_BODY;
78 }
79
80
81
82
83
84
85
86
87
88
89 private void criaLink(Link link, StringBuffer s) throws ECARException{
90
91 s.append("<a href=\""+link.getUrlLink()+"\"");
92 s.append("title=\""+link.getLabelLink()+"\"><img ");
93 s.append("src=\""+_pathEcar+"/DownloadFile?tipo=open&RemoteFile=" + pathRaizUpload + link.getIconeLink()+"\" border=\"0\" alt=\"\"> " +
94 link.getLabelLink()+"</a>   ");
95 }
96
97
98
99
100
101
102
103
104
105
106 public int doEndTag() throws JspException {
107
108 return Tag.EVAL_PAGE;
109 }
110
111 public Boolean getVerificaMonitoramento() {
112 return verificaMonitoramento;
113 }
114
115 public void setVerificaMonitoramento(Boolean verificaMonitoramento) {
116 this.verificaMonitoramento = verificaMonitoramento;
117 }
118
119 public String get_pathEcar() {
120 return _pathEcar;
121 }
122
123 public void set_pathEcar(String ecar) {
124 _pathEcar = ecar;
125 }
126
127
128
129
130
131 }