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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 package com.ivata.mask.web.tag.html;
102 import java.util.List;
103
104 import javax.servlet.jsp.JspException;
105 /***
106 * <p>
107 * Overrides an HTML <code><input type=submit></code> tag, by overriding
108 * the class from <strong>Struts </strong>.
109 * </p>
110 *
111 * <p>
112 * <b>Tag attributes: </b> <br/><table cellpadding='2' cellspacing='5'
113 * border='0' align='center' width='85%'>
114 * <tr class='TableHeadingColor'>
115 * <th>attribute</th>
116 * <th>reqd.</th>
117 * <th>param. class</th>
118 * <th width='100%'>description</th>
119 * </tr>
120 * <tr>
121 * <td>fieldName</td>
122 * <td>true</td>
123 * <td><code>java.lang.String</code></td>
124 * <td>The field name is used to default the following attributes of the tag:
125 * <br/>
126 * <ul>
127 * <li><code>styleId</code></li>
128 * <li><code>titleKey</code></li>
129 * <li><code>valueKey</code></li>
130 * </ul>.</td>
131 * </tr>
132 * <tr>
133 * <td>readOnly</td>
134 * <td>false</td>
135 * <td><code>boolean</code></td>
136 * <td>Specifies whether or not this submit button should be shown. If
137 * <code>true</code>, the submit button is not shown.</td>
138 * </tr>
139 * <tr>
140 * <td>titleKey</td>
141 * <td>true</td>
142 * <td><code>java.lang.String</code></td>
143 * <td>Specifies the localized text to use for mouse-over events.</td>
144 * </tr>
145 * <tr>
146 * <td>valueKey</td>
147 * <td>true</td>
148 * <td><code>java.lang.String</code></td>
149 * <td>Specifies the localized text to use for the button text.</td>
150 * </tr>
151 * </table>
152 * </p>
153 *
154 * <p>
155 * <b>Note: </b> all the tag attributes from {@link
156 * org.apache.struts.taglib.SubmitTag Stuts} are included.
157 * </p>
158 *
159 * @since ivata masks 0.4 (2003-01-15)
160 * @author Colin MacLeod
161 * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
162 * @version $Revision: 1.5 $
163 */
164 public class SubmitTag extends org.apache.struts.taglib.html.SubmitTag {
165 /***
166 * <p>
167 * Stores and maintains <strong>ivata op </strong> specific mask properties.
168 * </p>
169 */
170 private MaskProperties maskProperties = new MaskProperties();
171 /***
172 * <p>
173 * Overridden to check whether or not the field is read only, and to apply
174 * mandatory field attributes.
175 * </p>
176 *
177 * @return <code>EVAL_PAGE</code> since we always want to evaluate the
178 * page after this tag.
179 *
180 * @throws JspException
181 * if there is an error wrting to <code>out.print()</code>
182 */
183 public int doEndTag() throws JspException {
184
185 if (maskProperties.getReadOnly()
186 || (pageContext.getRequest().getParameter("print") != null)) {
187 maskProperties.reset(this);
188 return EVAL_PAGE;
189 }
190 int returnValue = super.doEndTag();
191 maskProperties.reset(this);
192 return returnValue;
193 }
194 /***
195 * <p>
196 * Overridden to set the value and title strings to the values represented
197 * by the localized keys in this class.
198 * </p>
199 *
200 * @return value returned by superclass method.
201 *
202 * @throws JspException
203 * if either <code>valueKey</code> or <code>titleKey</code>
204 * have not been set, or as thrown by superclass method.
205 */
206 public int doStartTag() throws JspException {
207 maskProperties.doStartTag(this, pageContext);
208
209 if (maskProperties.getReadOnly()) {
210 return SKIP_BODY;
211 }
212 return super.doStartTag();
213 }
214 /***
215 * <p>
216 * Calls {@link MaskProperties#getBundleMaskProperites.getBundle}.
217 * </p>
218 *
219 * @return the current value of bundle.
220 */
221 public final String getBundle() {
222 return maskProperties.getBundle();
223 }
224 /***
225 * <p>
226 * Stores and maintains <strong>ivata op </strong> specific mask properties.
227 * </p>
228 *
229 * @return the current value of maskProperties.
230 */
231 public MaskProperties getMaskProperties() {
232 return maskProperties;
233 }
234 public final List getTitleArgs() {
235 return maskProperties.getTitleArgs();
236 }
237 public final List getValueArgs() {
238 return maskProperties.getValueArgs();
239 }
240 /***
241 * <p>
242 * >Name of the field to which this label refers. This is used in
243 * conjunction with the <code>resourceFieldPath</code> to retrieve the
244 * correct message resources path.
245 * </p>
246 *
247 * @param fieldName
248 * the new value of fieldName.
249 */
250 public void setFieldName(final String fieldName) {
251 maskProperties.setFieldName(fieldName);
252 }
253 /***
254 * <p>
255 * Stores and maintains <strong>ivata op </strong> specific mask properties.
256 * </p>
257 *
258 * @param maskPropertiesParam
259 * the new value of maskProperties.
260 */
261 public void setMaskProperties(final MaskProperties maskPropertiesParam) {
262 this.maskProperties = maskPropertiesParam;
263 }
264 /***
265 * <p>
266 * Specifies whether or not this button should be shown, If this attribute
267 * is unset, the button will decide whether or not to dispaly on the basis
268 * of the <code>readOnly</code> attribute of the surrounding form.
269 * </p>
270 *
271 * @param readOnly
272 * <code>true</code> if the button should always be shown,
273 * otherwise the button will only be shown if the surrounding
274 * form is not read-only.
275 */
276 public void setReadOnly(final boolean readOnly) {
277 maskProperties.setReadOnly(readOnly);
278 }
279 /***
280 * Refer to {@link MaskProperties#setTitleArgs}.
281 *
282 * @param args Refer to {@link MaskProperties#setTitleArgs}.
283 */
284 public final void setTitleArgs(final List args) {
285 maskProperties.setTitleArgs(args);
286 }
287 /***
288 * <p>
289 * Set the value of the key used to localize the title tag attribute.
290 * </p>
291 *
292 * @param titleKey
293 * the new value of titleKey.
294 */
295 public final void setTitleKey(final String titleKey) {
296 maskProperties.setTitleKey(titleKey);
297 }
298 /***
299 * Refer to {@link MaskProperties#setValueArgs}.
300 *
301 * @param args Refer to {@link MaskProperties#setValueArgs}.
302 */
303 public final void setValueArgs(final List args) {
304 maskProperties.setValueArgs(args);
305 }
306 /***
307 * <p>
308 * Set the value of the key used to localize the value tag attribute.
309 * </p>
310 *
311 * @param valueKey
312 * the new value of valueKey.
313 */
314 public void setValueKey(final String valueKey) {
315 maskProperties.setValueKey(valueKey);
316 }
317 }
318