1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.web;
17
18 import java.util.List;
19
20 import javax.servlet.jsp.JspException;
21 import javax.servlet.jsp.PageContext;
22 import javax.servlet.jsp.tagext.Tag;
23
24 import org.kuali.ole.sys.OLEConstants;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.ole.sys.document.web.renderers.PersistingTagRenderer;
27 import org.kuali.ole.sys.document.web.renderers.StringRenderer;
28 import org.kuali.rice.core.api.config.property.ConfigurationService;
29 import org.kuali.rice.kns.web.ui.Field;
30
31
32
33
34 public class AccountingLineViewSequenceNumberField extends FieldTableJoiningWithHeader {
35 private String name = OLEConstants.AccountingLineViewStandardBlockNames.SEQUENCE_NUMBER_BLOCK;
36 private String newLineLabelProperty = "accounting.line.new.line.sequence.number";
37
38
39
40
41
42 public boolean isReadOnly() {
43 return true;
44 }
45
46
47
48
49
50 public String getName() {
51 return name;
52 }
53
54
55
56
57
58 public void setName(String name) {
59 this.name = name;
60 }
61
62
63
64
65 public String getHeaderLabelProperty() {
66 return this.name;
67 }
68
69
70
71
72 @Override
73 protected AccountingLineTableCell createTableCell() {
74 AccountingLineTableCell cell = super.createTableCell();
75 cell.setRendersAsHeader(true);
76 return cell;
77 }
78
79
80
81
82 public void renderElement(PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext) throws JspException {
83 if (renderingContext.isNewLine()) {
84 StringRenderer renderer = new StringRenderer();
85 renderer.setStringToRender(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(newLineLabelProperty));
86 renderer.render(pageContext, parentTag);
87 renderer.clear();
88 } else {
89 PersistingTagRenderer renderer = new PersistingTagRenderer();
90 renderer.setStringToRender(getDisplaySequenceNumber(renderingContext));
91 renderer.setValueToPersist(renderingContext.getAccountingLine().getSequenceNumber().toString());
92 renderer.setPersistingProperty(renderingContext.getAccountingLinePropertyPath()+".sequenceNumber");
93 renderer.render(pageContext, parentTag);
94 renderer.clear();
95 }
96 }
97
98
99
100
101
102
103 protected String getDisplaySequenceNumber(AccountingLineRenderingContext renderingContext) {
104 return renderingContext.getAccountingLine().getSequenceNumber().toString();
105 }
106
107
108
109
110 public HeaderLabel createHeaderLabel() {
111 return new LiteralHeaderLabel(" ");
112 }
113
114
115
116
117
118
119
120 public void appendFields(List<Field> fields) {
121
122 }
123
124
125
126
127
128 public void populateWithTabIndexIfRequested(int reallyHighIndex) { }
129 }