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