1
2
3
4 package ecar.taglib.util;
5
6 import java.io.IOException;
7 import java.util.Iterator;
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 import ecar.exception.ECARException;
17 import ecar.pojo.DemAtributoDema;
18 import ecar.pojo.ObjetoDemanda;
19 import ecar.pojo.RegDemandaRegd;
20
21
22
23
24
25 public class FormConsultaRegDemandaTag implements Tag {
26
27 private ObjetoDemanda atributo;
28 private RegDemandaRegd regDemanda;
29
30 private PageContext page = null;
31
32
33
34
35
36
37
38
39
40
41 public int doStartTag() throws JspException {
42 try {
43 if(atributo.iGetGrupoAtributosLivres() != null){
44 geraHTMLAtributoLivre();
45 } else{
46 geraHTMLAtributosFixos();
47 }
48 } catch (Exception e) {
49
50 }
51 return Tag.EVAL_BODY_INCLUDE;
52 }
53
54
55
56
57
58
59
60
61
62 public void geraHTMLAtributosFixos() {
63 try {
64 if(atributo.iGetNome().equals("indAtivoRegd")){
65 String valorAtributoAtivo = "";
66 if(atributo.iGetValor(getRegDemanda()).equals("N")) {
67 valorAtributoAtivo = "Não";
68 } else if(atributo.iGetValor(getRegDemanda()).equals("S")){
69 valorAtributoAtivo = "Sim";
70 }
71 criaLabelText(atributo.iGetLabel(), valorAtributoAtivo);
72 } else{
73 criaLabelText(atributo.iGetLabel(), atributo.iGetValor(getRegDemanda()));
74 }
75 } catch (ECARException e) {
76 Logger logger = Logger.getLogger(this.getClass());
77 logger.error(e);
78 }
79 }
80
81
82
83
84
85
86
87
88
89
90 public void geraHTMLAtributoLivre() throws ECARException, JspException{
91 String informacaoAtbdem = "";
92 Iterator itRegDem = regDemanda.getDemAtributoDemas().iterator();
93
94
95
96 if(atributo.iGetGrupoAtributosLivres() != null
97 && (atributo.iGetGrupoAtributosLivres().getIndAtivoSga()!=null
98 && atributo.iGetGrupoAtributosLivres().getIndAtivoSga().equals("S")) ){
99
100 while (itRegDem.hasNext()) {
101 DemAtributoDema demAtributoDema = (DemAtributoDema) itRegDem.next();
102
103 if (demAtributoDema.getSisAtributoSatb().getSisGrupoAtributoSga().equals(atributo.iGetGrupoAtributosLivres())){
104
105 if (atributo.iGetGrupoAtributosLivres().getSisTipoExibicGrupoSteg().getCodSteg().equals(new Long(Input.TEXT)) ||
106 atributo.iGetGrupoAtributosLivres().getSisTipoExibicGrupoSteg().getCodSteg().equals(new Long(Input.TEXTAREA)) ||
107 atributo.iGetGrupoAtributosLivres().getSisTipoExibicGrupoSteg().getCodSteg().equals(new Long(Input.MULTITEXTO)) ||
108 atributo.iGetGrupoAtributosLivres().getSisTipoExibicGrupoSteg().getCodSteg().equals(new Long(Input.VALIDACAO)) ) {
109
110 informacaoAtbdem = informacaoAtbdem + demAtributoDema.getInformacao() + "; ";
111
112 } else if (!atributo.iGetGrupoAtributosLivres().getSisTipoExibicGrupoSteg().getCodSteg().equals(new Long(Input.IMAGEM))) {
113
114 informacaoAtbdem = informacaoAtbdem + demAtributoDema.getSisAtributoSatb().getDescricaoSatb() + ", ";
115 }
116 }
117 }
118
119 if (informacaoAtbdem.length() > 0){
120 informacaoAtbdem = informacaoAtbdem.substring(0, informacaoAtbdem.length() - 2);
121 }
122
123 criaLabelText(atributo.iGetLabel(), informacaoAtbdem);
124 }
125
126 }
127
128
129
130
131
132
133
134
135
136 public void criaLabelText(String label, String valor) {
137 JspWriter writer = this.page.getOut();
138 StringBuffer s = new StringBuffer();
139 try {
140 s.append("<TD align=\"right\"><b>");
141 s.append(label);
142 s.append("</b></TD>")
143 .append("<TD>")
144 .append(valor );
145 s.append("</TD>");
146
147 writer.print(s.toString());
148 } catch (IOException e) {
149 Logger logger = Logger.getLogger(this.getClass());
150 logger.error(e);
151 }
152 }
153
154 public int doEndTag() throws JspException {
155 return Tag.EVAL_PAGE;
156 }
157
158 public void release() {
159
160 }
161
162 public ObjetoDemanda getAtributo() {
163 return atributo;
164 }
165
166 public void setAtributo(ObjetoDemanda atributo) {
167 this.atributo = atributo;
168 }
169
170 public RegDemandaRegd getRegDemanda() {
171 return regDemanda;
172 }
173
174 public void setRegDemanda(RegDemandaRegd regDemanda) {
175 this.regDemanda = regDemanda;
176 }
177
178 public PageContext getPage() {
179 return page;
180 }
181
182 public void setPage(PageContext page) {
183 this.page = page;
184 }
185
186 public Tag getParent() {
187 return null;
188 }
189
190 public void setPageContext(PageContext arg0) {
191 this.page = arg0;
192 }
193
194 public void setParent(Tag arg0) {
195 }
196
197 }