1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 package com.ivata.mask.web.tag.html;
83 import java.util.List;
84
85 import javax.servlet.jsp.JspException;
86 import org.apache.struts.taglib.TagUtils;
87 import com.ivata.mask.util.StringHandling;
88 /***
89 * <p>
90 * Overrides an HTML <code><input type=checkbox></code> tag, by
91 * overriding the <code>multibox</code> class from <strong>Struts </strong>.
92 * </p>
93 *
94 * <p>
95 * <b>Tag attributes: </b> <br/><table cellpadding='2' cellspacing='5'
96 * border='0' align='center' width='85%'>
97 * <tr class='TableHeadingColor'>
98 * <th>attribute</th>
99 * <th>reqd.</th>
100 * <th>param. class</th>
101 * <th width='100%'>description</th>
102 * </tr>
103 * <tr>
104 * <td>fieldName</td>
105 * <td>true</td>
106 * <td><code>java.lang.String</code></td>
107 * <td>The field name is used to default the following attributes of the tag:
108 * <br/>
109 * <ul>
110 * <li><code>styleId</code></li>
111 * <li><code>titleKey</code></li>
112 * <li><code>valueKey</code></li>
113 * </ul>.</td>
114 * </tr>
115 * <tr>
116 * <td>mandatory</td>
117 * <td>false</td>
118 * <td><code>boolean</code></td>
119 * <td>Specifies data for this tag must be entered when the form is submitted.
120 * </td>
121 * </tr>
122 * <tr>
123 * <td>readOnly</td>
124 * <td>false</td>
125 * <td><code>boolean</code></td>
126 * <td>Specifies the form elements should be displayed only and cannot be
127 * altered.</td>
128 * </tr>
129 * </table>
130 * </p>
131 *
132 * <p>
133 * <b>Note: </b> all the tag attributes from {@link
134 * org.apache.struts.taglib.CheckboxTag Stuts} are also included.
135 * </p>
136 *
137 * @since ivata masks 0.4 (2003-05-22)
138 * @author Colin MacLeod
139 * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
140 * @version $Revision: 1.4 $
141 */
142 public class MultiboxTag extends org.apache.struts.taglib.html.MultiboxTag {
143 /***
144 * <p>
145 * Stores the label which is displayed to the right of the checkbox.
146 * </p>
147 */
148 private String label;
149 /***
150 * <p>
151 * Stores and maintains <strong>ivata op </strong> specific mask properties.
152 * </p>
153 */
154 private MaskProperties maskProperties = new MaskProperties();
155 /***
156 * <p>
157 * Overridden to check whether or not the field is read only, and to apply
158 * mandatory field attributes.
159 * </p>
160 *
161 * @return <code>EVAL_PAGE</code> since we always want to evaluate the
162 * page after this tag.
163 *
164 * @throws JspException
165 * if there is an error wrting to <code>out.print()</code>
166 *
167 */
168 public int doEndTag() throws JspException {
169
170 int returnValue = super.doEndTag();
171 if (!StringHandling.isNullOrEmpty(label)) {
172 TagUtils.getInstance().write(pageContext, " " + label);
173 }
174 maskProperties.reset(this);
175 return returnValue;
176 }
177 /***
178 * <p>
179 * Overridden to call <code>MaskProperties</code> initialization.
180 * </p>
181 *
182 * @return value returned by superclass method, or <code>SKIP_BODY</code>
183 * if this tag is read-only.
184 *
185 * @throws JspException
186 * if either <code>valueKey</code> or <code>titleKey</code>
187 * have not been set, or as thrown by superclass method.
188 */
189 public int doStartTag() throws JspException {
190 maskProperties.doStartTag(this, pageContext);
191 if (this.value == null) {
192 this.value = "true";
193 }
194 return super.doStartTag();
195 }
196 public final List getLabelArgs() {
197 return maskProperties.getLabelArgs();
198 }
199 /***
200 * <p>
201 * Stores and maintains <strong>ivata op </strong> specific mask properties.
202 * </p>
203 *
204 * @return the current value of maskProperties.
205 */
206 public MaskProperties getMaskProperties() {
207 return maskProperties;
208 }
209 public final List getTitleArgs() {
210 return maskProperties.getTitleArgs();
211 }
212 /***
213 * <p>
214 * >Name of the field to which this label refers. This is used in
215 * conjunction with the <code>resourceFieldPath</code> to retrieve the
216 * correct message resources path.
217 * </p>
218 *
219 * @param fieldName
220 * the new value of fieldName.
221 */
222 public void setFieldName(final String fieldName) {
223 maskProperties.setFieldName(fieldName);
224 }
225 /***
226 * <p>
227 * Called by <code>MaskProperties</code> to set the label.
228 * </p>
229 *
230 * @param labelParam new text to be displayed as the label.
231 */
232 public void setLabel(final String labelParam) {
233 this.label = labelParam;
234 }
235 /***
236 * Refer to {@link MaskProperties#setLabelArgs}.
237 *
238 * @param args Refer to {@link MaskProperties#setLabelArgs}.
239 */
240 public final void setLabelArgs(final List args) {
241 maskProperties.setLabelArgs(args);
242 }
243 /***
244 * <p>
245 * Localization key of a string which will appear to the right of the check
246 * box.
247 * </p>
248 *
249 * @param labelKey
250 * the new value of labelKey.
251 */
252 public void setLabelKey(final String labelKey) {
253 maskProperties.setLabelKey(labelKey);
254 }
255 /***
256 * <p>
257 * Set whether or not the value this control must be entered.
258 * </p>
259 *
260 * @param mandatory
261 * <code>true</code> if this field must be entered, otherwise
262 * <code>false</code> if the field is optional.
263 */
264 public void setMandatory(final boolean mandatory) {
265 maskProperties.setMandatory(mandatory);
266 }
267 /***
268 * <p>
269 * Stores and maintains <strong>ivata op </strong> specific mask properties.
270 * </p>
271 *
272 * @param maskPropertiesParam
273 * the new value of maskProperties.
274 */
275 public void setMaskProperties(final MaskProperties maskPropertiesParam) {
276 this.maskProperties = maskPropertiesParam;
277 }
278 /***
279 * <p>
280 * Specifies whether or not the input values can be altered.
281 * </p>
282 *
283 * @param readOnly
284 * <code>true</code> if the input of this field can be changed,
285 * otherwise <code>false</code> to only display the current
286 * value.
287 */
288 public void setReadOnly(final boolean readOnly) {
289 maskProperties.setReadOnly(readOnly);
290 }
291 /***
292 * Refer to {@link MaskProperties#setTitleArgs}.
293 *
294 * @param args Refer to {@link MaskProperties#setTitleArgs}.
295 */
296 public final void setTitleArgs(final List args) {
297 maskProperties.setTitleArgs(args);
298 }
299 /***
300 * <p>
301 * Set the value of the key used to localize the title tag attribute.
302 * </p>
303 *
304 * @param titleKey
305 * the new value of titleKey.
306 */
307 public final void setTitleKey(final String titleKey) {
308 maskProperties.setTitleKey(titleKey);
309 }
310 }
311