1 /*
2 * Copyright 2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.sys.document.web;
17
18 import javax.servlet.jsp.JspException;
19 import javax.servlet.jsp.PageContext;
20 import javax.servlet.jsp.tagext.Tag;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.ole.sys.document.web.renderers.LabelRenderer;
24
25 /**
26 * A class which represents a renderable header label for an input
27 */
28 public class FieldHeaderLabel extends HeaderLabel {
29 private HeaderLabelPopulating headerLabelPopulator;
30 private String label;
31 private boolean readOnly = false;
32 private boolean required = false;
33 private String labelFor;
34 private String fullClassNameForHelp;
35 private String attributeEntryForHelp;
36
37 /**
38 * Constructs a FieldHeaderLabel, forcing an implementation of HeaderLabelPopulating to be passed in
39 * @param headerLabelPopulator the populator who will populate this label when the time has come
40 */
41 public FieldHeaderLabel(HeaderLabelPopulating headerLabelPopulator) {
42 this.headerLabelPopulator = headerLabelPopulator;
43 }
44
45 /**
46 * Gets the attributeEntryForHelp attribute.
47 * @return Returns the attributeEntryForHelp.
48 */
49 public String getAttributeEntryForHelp() {
50 return attributeEntryForHelp;
51 }
52
53 /**
54 * Sets the attributeEntryForHelp attribute value.
55 * @param attributeEntryForHelp The attributeEntryForHelp to set.
56 */
57 public void setAttributeEntryForHelp(String attributeEntryForHelp) {
58 this.attributeEntryForHelp = attributeEntryForHelp;
59 }
60
61 /**
62 * Gets the fullClassNameForHelp attribute.
63 * @return Returns the fullClassNameForHelp.
64 */
65 public String getFullClassNameForHelp() {
66 return fullClassNameForHelp;
67 }
68
69 /**
70 * Sets the fullClassNameForHelp attribute value.
71 * @param fullClassNameForHelp The fullClassNameForHelp to set.
72 */
73 public void setFullClassNameForHelp(String fullClassNameForHelp) {
74 this.fullClassNameForHelp = fullClassNameForHelp;
75 }
76
77 /**
78 * Gets the label attribute.
79 * @return Returns the label.
80 */
81 public String getLabel() {
82 return label;
83 }
84
85 /**
86 * Sets the label attribute value.
87 * @param label The label to set.
88 */
89 public void setLabel(String label) {
90 this.label = label;
91 }
92
93 /**
94 * Gets the labelFor attribute.
95 * @return Returns the labelFor.
96 */
97 public String getLabelFor() {
98 return labelFor;
99 }
100
101 /**
102 * Sets the labelFor attribute value.
103 * @param labelFor The labelFor to set.
104 */
105 public void setLabelFor(String labelFor) {
106 this.labelFor = labelFor;
107 }
108
109 /**
110 * Gets the readOnly attribute.
111 * @return Returns the readOnly.
112 */
113 public boolean isReadOnly() {
114 return readOnly;
115 }
116
117 /**
118 * Sets the readOnly attribute value.
119 * @param readOnly The readOnly to set.
120 */
121 public void setReadOnly(boolean readOnly) {
122 this.readOnly = readOnly;
123 }
124
125 /**
126 * Gets the required attribute.
127 * @return Returns the required.
128 */
129 public boolean isRequired() {
130 return required;
131 }
132
133 /**
134 * Sets the required attribute value.
135 * @param required The required to set.
136 */
137 public void setRequired(boolean required) {
138 this.required = required;
139 }
140
141 /**
142 * @see org.kuali.ole.sys.document.web.RenderableElement#renderElement(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag, org.kuali.ole.sys.document.web.AccountingLineRenderingContext)
143 */
144 public void renderElement(PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext) throws JspException {
145 headerLabelPopulator.populateHeaderLabel(this, renderingContext);
146 LabelRenderer renderer = new LabelRenderer();
147 renderer.setLabel(label);
148 renderer.setRequired(required);
149 renderer.setReadOnly(readOnly);
150 renderer.setLabelFor(labelFor);
151 if (!StringUtils.isBlank(fullClassNameForHelp)) {
152 renderer.setFullClassNameForHelp(fullClassNameForHelp);
153 }
154 if (!StringUtils.isBlank(attributeEntryForHelp)) {
155 renderer.setAttributeEntryForHelp(attributeEntryForHelp);
156 }
157 renderer.render(pageContext, parentTag);
158 renderer.clear();
159 }
160
161 }