1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.web.renderers;
17
18 import java.io.IOException;
19
20 import javax.servlet.jsp.JspException;
21 import javax.servlet.jsp.JspWriter;
22 import javax.servlet.jsp.PageContext;
23 import javax.servlet.jsp.tagext.Tag;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.apache.struts.taglib.html.HiddenTag;
27 import org.kuali.ole.sys.context.SpringContext;
28 import org.kuali.rice.core.api.config.property.ConfigurationService;
29 import org.kuali.rice.kns.web.taglib.html.KNSImageTag;
30
31
32
33
34 public class AccountingLineTableHeaderRenderer implements Renderer {
35 private int cellCount;
36 private boolean hideDetails;
37 private String accountingLineImportInstructionsUrl;
38 private KNSImageTag showHideTag = new KNSImageTag();
39 private HiddenTag hideStateTag = new HiddenTag();
40
41
42
43
44 public AccountingLineTableHeaderRenderer() {
45 hideStateTag.setName("KualiForm");
46 hideStateTag.setProperty("hideDetails");
47
48 showHideTag.setStyleClass("tinybutton");
49 }
50
51
52
53
54 public void clear() {
55 cellCount = 0;
56 hideDetails = false;
57 accountingLineImportInstructionsUrl = null;
58
59 showHideTag.setPageContext(null);
60 showHideTag.setParent(null);
61 showHideTag.setProperty(null);
62 showHideTag.setAlt(null);
63 showHideTag.setTitle(null);
64 showHideTag.setSrc(null);
65
66 hideStateTag.setPageContext(null);
67 hideStateTag.setParent(null);
68 }
69
70
71
72
73
74 public void render(PageContext pageContext, Tag parentTag) throws JspException {
75 JspWriter out = pageContext.getOut();
76
77 try {
78 out.write(buildDivStart());
79 out.write(buildTableStart());
80 out.write(buildSubheadingWithDetailToggleRowBeginning());
81 renderHideDetails(pageContext, parentTag);
82 out.write(buildSubheadingWithDetailToggleRowEnding());
83 }
84 catch (IOException ioe) {
85 throw new JspException("Difficulty rendering AccountingLineTableHeader", ioe);
86 }
87 }
88
89
90
91
92
93 protected String buildDivStart() {
94 return "<div class=\"tab-container\" align=\"center\">\n";
95 }
96
97
98
99
100
101 protected String buildTableStart() {
102 return "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"datatable\">\n";
103 }
104
105
106
107
108
109 protected String buildSubheadingWithDetailToggleRowBeginning() {
110 StringBuilder row = new StringBuilder();
111 row.append("\t<tr>\n");
112 row.append("\t\t<td colspan=\"");
113 row.append(cellCount);
114 row.append("\" class=\"subhead\">\n");
115 row.append("\t\t\t<span class=\"subhead-left\">");
116 row.append(buildSubHeading());
117 row.append("</span>\n");
118 row.append("\t\t\t<span class=\"subhead-right\">\n");
119
120 return row.toString();
121 }
122
123
124
125
126
127 protected String buildSubHeading() {
128 if (StringUtils.isBlank(accountingLineImportInstructionsUrl)) return " ";
129
130 StringBuilder subheading = new StringBuilder();
131
132 subheading.append("Accounting Lines <a href=\"");
133 subheading.append(accountingLineImportInstructionsUrl);
134 subheading.append("\" target=\"helpWindow\">");
135 subheading.append("<img src=\"");
136 subheading.append(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString("kr.externalizable.images.url"));
137 subheading.append("my_cp_inf.gif\" title=\"Accounting Lines Help\" alt=\"Accounting Lines Help\" hspace=\"5\" border=\"0\" align=\"middle\" />");
138 subheading.append("</a>");
139
140 return subheading.toString();
141 }
142
143
144
145
146
147
148
149 protected void renderHideDetails(PageContext pageContext, Tag parentTag) throws JspException {
150 hideStateTag.setPageContext(pageContext);
151 hideStateTag.setParent(parentTag);
152
153 hideStateTag.doStartTag();
154 hideStateTag.doEndTag();
155
156 String toggle = hideDetails ? "show" : "hide";
157
158 showHideTag.setPageContext(pageContext);
159 showHideTag.setParent(parentTag);
160 showHideTag.setProperty("methodToCall."+toggle+"Details");
161 showHideTag.setSrc(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString("kr.externalizable.images.url")+"det-"+toggle+".gif");
162 showHideTag.setAlt(toggle+" transaction details");
163 showHideTag.setTitle(toggle+" transaction details");
164
165 showHideTag.doStartTag();
166 showHideTag.doEndTag();
167 }
168
169
170
171
172
173 protected String buildSubheadingWithDetailToggleRowEnding() {
174 StringBuilder row = new StringBuilder();
175 row.append("\t\t\t</span>\n");
176 row.append("\t\t</td>\n");
177 row.append("\t</tr>\n");
178 return row.toString();
179 }
180
181
182
183
184
185 public String getAccountingLineImportInstructionsUrl() {
186 return accountingLineImportInstructionsUrl;
187 }
188
189
190
191
192
193 public void setAccountingLineImportInstructionsUrl(String accountingLineImportInstructionsUrl) {
194 this.accountingLineImportInstructionsUrl = accountingLineImportInstructionsUrl;
195 }
196
197
198
199
200
201 public int getCellCount() {
202 return cellCount;
203 }
204
205
206
207
208
209 public void setCellCount(int cellCount) {
210 this.cellCount = cellCount;
211 }
212
213
214
215
216
217 public boolean getHideDetails() {
218 return hideDetails;
219 }
220
221
222
223
224
225 public void setHideDetails(boolean hideDetails) {
226 this.hideDetails = hideDetails;
227 }
228 }