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 org.apache.log4j.Logger;
16
17 import comum.util.Data;
18
19 import ecar.dao.PopUpDao;
20 import ecar.pojo.PopupPpp;
21 import ecar.pojo.UsuarioUsu;
22
23
24
25
26
27 public class PopUpsTag extends TagSupport {
28
29
30
31
32 private static final long serialVersionUID = 3920610661946783698L;
33
34 private Logger logger = Logger.getLogger(this.getClass());
35
36 private String pathEcar;
37
38
39
40
41
42
43
44
45
46
47 public int doStartTag() throws JspException {
48 JspWriter writer = this.pageContext.getOut();
49
50 try {
51
52 List popUps = new PopUpDao(null).getPopUpsApresentadasNoDia(Data.getDataAtual());
53
54 if("true".equals(this.pageContext.getRequest().getParameter("mostrarPopUps"))){
55 Iterator it = popUps.iterator();
56 while(it.hasNext()){
57 PopupPpp pp = (PopupPpp) it.next();
58 UsuarioUsu usuario = ((ecar.login.SegurancaECAR)this.pageContext.getSession().getAttribute("seguranca")).getUsuario();
59 StringBuffer nomeCookie = new StringBuffer("popUp_").append(usuario.getCodUsu()).append("_").append(pp.getCodPpp());
60 writer.println("<script>");
61 writer.println("if(getCookie('" + nomeCookie + "') == null){");
62 writer.println("abreJanela('" + getPathEcar() + "/popUp/popUpAvisoPadrao.jsp?codPpp=" + pp.getCodPpp() + "', " + pp.getJanelaLarguraPpp() + "," + pp.getJanelaAlturaPpp() + ",'" + pp.getCodPpp() + "');");
63 if(pp.getPopupComportamentoPppc().getCodPppc().intValue() == PopUpDao.POPUP_COMPORTAMENTO_ABRIR_SOMENTE_UMA_VEZ){
64 writer.println("setCookie('" + nomeCookie + "','1',null,'" + this.pathEcar + "',null,null);");
65 }
66 writer.println("}");
67 writer.println("</script>");
68 }
69 }
70
71 } catch (Exception e) {
72 logger.error(e);
73 }
74
75 return Tag.SKIP_BODY;
76 }
77
78
79
80
81
82
83
84
85
86
87 public int doEndTag() throws JspException {
88
89 return Tag.EVAL_PAGE;
90 }
91
92
93
94
95
96
97
98
99
100 public String getPathEcar() {
101 return pathEcar;
102 }
103
104
105
106
107
108
109
110
111
112 public void setPathEcar(String pathEcar) {
113 this.pathEcar = pathEcar;
114 }
115 }