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.struts.taglib.bean.WriteTag;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.rice.core.api.config.property.ConfigurationService;
28
29 public class DebitCreditTotalRenderer extends TotalRendererBase {
30 private String debitTotalProperty;
31 private String creditTotalProperty;
32 private String representedProperty;
33
34 private String debitTotalLabelProperty = "accounting.line.group.debitTotal.label";
35 private String creditTotalLabelProperty = "accounting.line.group.creditTotal.label";
36
37 private String formName = "KualiForm";
38
39 private WriteTag debitWriteTag = new WriteTag();
40 private WriteTag creditWriteTag = new WriteTag();
41
42
43
44
45 public DebitCreditTotalRenderer() {
46 debitWriteTag.setName(formName);
47 creditWriteTag.setName(formName);
48 }
49
50
51
52
53
54 public void clear() {
55 super.clear();
56 debitTotalProperty = null;
57 creditTotalProperty = null;
58 representedProperty = null;
59
60 debitWriteTag.setPageContext(null);
61 debitWriteTag.setParent(null);
62 debitWriteTag.setProperty(null);
63
64 creditWriteTag.setPageContext(null);
65 creditWriteTag.setParent(null);
66 creditWriteTag.setProperty(null);
67 }
68
69
70
71
72
73 public void render(PageContext pageContext, Tag parentTag) throws JspException {
74 JspWriter out = pageContext.getOut();
75
76 try {
77 out.write("<tr>");
78
79 final int emptyCellSpanBefore = this.getColumnNumberOfRepresentedCell() - 1;
80 out.write("<td class=\"total-line\" colspan=\"");
81 out.write(Integer.toString(emptyCellSpanBefore));
82 out.write("\"> </td>");
83
84 out.write("<td class=\"total-line\" style=\"border-left: 0px; white-space:nowrap;\">");
85 out.write("<strong>");
86
87 out.write(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(debitTotalLabelProperty));
88 out.write(" ");
89
90 debitWriteTag.setPageContext(pageContext);
91 debitWriteTag.setParent(parentTag);
92 debitWriteTag.setProperty(debitTotalProperty);
93 debitWriteTag.doStartTag();
94 debitWriteTag.doEndTag();
95
96 out.write("</strong>");
97 out.write("</td>");
98
99 out.write("<td class=\"total-line\" style=\"border-left: 0px; white-space:nowrap;\">");
100 out.write("<strong>");
101
102 out.write(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(creditTotalLabelProperty));
103 out.write(" ");
104
105 creditWriteTag.setPageContext(pageContext);
106 creditWriteTag.setParent(parentTag);
107 creditWriteTag.setProperty(creditTotalProperty);
108 creditWriteTag.doStartTag();
109 creditWriteTag.doEndTag();
110
111 out.write("</strong>");
112 out.write("</td>");
113
114 final int emptyCellSpanAfter = this.getCellCount() - this.getColumnNumberOfRepresentedCell() - 1;
115 if(emptyCellSpanAfter > 0) {
116 out.write("<td class=\"total-line\" style=\"border-left: 0px;\" colspan=\"");
117 out.write(Integer.toString(emptyCellSpanAfter));
118 out.write("\"> </td>");
119 }
120
121 out.write("</tr>");
122 }
123 catch (IOException ioe) {
124 throw new JspException("Difficulty rendering debit credit totals", ioe);
125 }
126 }
127
128
129
130
131
132 public String getDebitTotalProperty() {
133 return debitTotalProperty;
134 }
135
136
137
138
139
140 public void setDebitTotalProperty(String debitTotalProperty) {
141 this.debitTotalProperty = debitTotalProperty;
142 }
143
144
145
146
147
148 public String getCreditTotalProperty() {
149 return creditTotalProperty;
150 }
151
152
153
154
155
156 public void setCreditTotalProperty(String creditTotalProperty) {
157 this.creditTotalProperty = creditTotalProperty;
158 }
159
160
161
162
163
164 public String getDebitTotalLabelProperty() {
165 return debitTotalLabelProperty;
166 }
167
168
169
170
171
172 public void setDebitTotalLabelProperty(String debitTotalLabelProperty) {
173 this.debitTotalLabelProperty = debitTotalLabelProperty;
174 }
175
176
177
178
179
180 public String getCreditTotalLabelProperty() {
181 return creditTotalLabelProperty;
182 }
183
184
185
186
187
188 public void setCreditTotalLabelProperty(String creditTotalLabelProperty) {
189 this.creditTotalLabelProperty = creditTotalLabelProperty;
190 }
191 }