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
30
31
32 public class GroupTotalRenderer extends TotalRendererBase {
33 private String totalProperty;
34 private WriteTag writeTag = new WriteTag();
35
36 private String totalLabelProperty = "accounting.line.group.total.label";
37 private String formName = "KualiForm";
38
39
40
41
42 public GroupTotalRenderer() {
43 writeTag.setName(formName);
44 }
45
46
47
48
49
50 public String getTotalProperty() {
51 return totalProperty;
52 }
53
54
55
56
57
58 public void setTotalProperty(String totalProperty) {
59 this.totalProperty = totalProperty;
60 }
61
62
63
64
65
66 public String getTotalLabelProperty() {
67 return totalLabelProperty;
68 }
69
70
71
72
73
74 public void setTotalLabelProperty(String totalLabelProperty) {
75 this.totalLabelProperty = totalLabelProperty;
76 }
77
78
79
80
81
82 public void clear() {
83 super.clear();
84 totalProperty = null;
85
86 writeTag.setPageContext(null);
87 writeTag.setParent(null);
88 writeTag.setProperty(null);
89 }
90
91
92
93
94
95 public void render(PageContext pageContext, Tag parentTag) throws JspException {
96 JspWriter out = pageContext.getOut();
97
98 try {
99 out.write("<tr>");
100
101 final int emptyCellSpanBefore = this.getColumnNumberOfRepresentedCell() - 1;
102 out.write("<td class=\"total-line\" colspan=\"");
103 out.write(Integer.toString(emptyCellSpanBefore));
104 out.write("\"> </td>");
105
106 out.write("<td class=\"total-line\" style=\"border-left: 0px;\">");
107
108 out.write("<strong>");
109
110 out.write(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(totalLabelProperty));
111 out.write(" ");
112
113 writeTag.setPageContext(pageContext);
114 writeTag.setParent(parentTag);
115 writeTag.setProperty(getTotalProperty());
116 writeTag.doStartTag();
117 writeTag.doEndTag();
118
119 out.write("</strong>");
120
121 out.write("</td>");
122
123 final int emptyCellSpanAfter = this.getCellCount() - this.getColumnNumberOfRepresentedCell();
124 if(emptyCellSpanAfter > 0) {
125 out.write("<td class=\"total-line\" style=\"border-left: 0px;\" colspan=\"");
126 out.write(Integer.toString(emptyCellSpanAfter));
127 out.write("\"> </td>");
128 }
129
130 out.write("</tr>");
131 }
132 catch (IOException ioe) {
133 throw new JspException("Difficulty rendering group total", ioe);
134 }
135 }
136 }