View Javadoc

1   /*
2    * Copyright (c) 2001 - 2005 ivata limited.
3    * All rights reserved.
4    * -----------------------------------------------------------------------------
5    * ivata masks may be redistributed under the GNU General Public
6    * License as published by the Free Software Foundation;
7    * version 2 of the License.
8    *
9    * These programs are free software; you can redistribute them and/or
10   * modify them under the terms of the GNU General Public License
11   * as published by the Free Software Foundation; version 2 of the License.
12   *
13   * These programs are distributed in the hope that they will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16   *
17   * See the GNU General Public License in the file LICENSE.txt for more
18   * details.
19   *
20   * If you would like a copy of the GNU General Public License write to
21   *
22   * Free Software Foundation, Inc.
23   * 59 Temple Place - Suite 330
24   * Boston, MA 02111-1307, USA.
25   *
26   *
27   * To arrange commercial support and licensing, contact ivata at
28   *                  http://www.ivata.com/contact.jsp
29   * -----------------------------------------------------------------------------
30   * $Log: ResetTag.java,v $
31   * Revision 1.4  2005/04/09 18:04:20  colinmacleod
32   * Changed copyright text to GPL v2 explicitly.
33   *
34   * Revision 1.3  2005/03/10 10:45:38  colinmacleod
35   * Fixes for tomcat4. Changed setters and getters
36   * to both use the same types.
37   *
38   * Revision 1.2  2005/01/19 13:14:04  colinmacleod
39   * Renamed CausedByException to SystemException.
40   *
41   * Revision 1.1  2005/01/06 23:10:07  colinmacleod
42   * Moved up a version number.
43   * Changed copyright notices to 2005.
44   * Updated the documentation:
45   *   - started working on multiproject:site docu.
46   *   - changed the logo.
47   * Added checkstyle and fixed LOADS of style issues.
48   * Added separate thirdparty subproject.
49   * Added struts (in web), util and webgui (in webtheme) from ivata op.
50   *
51   * Revision 1.4  2004/11/03 16:12:09  colinmacleod
52   * Changed fieldPath to resourceFieldPath.
53   *
54   * Revision 1.3  2004/07/13 19:48:10  colinmacleod
55   * Moved project to POJOs from EJBs.
56   * Applied PicoContainer to services layer (replacing session EJBs).
57   * Applied Hibernate to persistence layer (replacing entity EJBs).
58   *
59   * Revision 1.2  2004/03/21 21:16:35  colinmacleod
60   * Shortened name to ivata op.
61   *
62   * Revision 1.1.1.1  2004/01/27 20:59:40  colinmacleod
63   * Moved ivata op to SourceForge.
64   *
65   * Revision 1.2  2003/10/16 15:43:03  jano
66   * Fixes problems with building and some problems with splitting to subprojects
67   *
68   * Revision 1.1.1.1  2003/10/13 20:49:26  colin
69   * Restructured portal into subprojects
70   *
71   * Revision 1.2  2003/03/03 16:57:12  colin
72   * converted localization to automatic paths
73   * added labels
74   * added mandatory fieldName attribute
75   *
76   * Revision 1.1  2003/02/24 19:33:33  colin
77   * Moved to new subproject.
78   *
79   * Revision 1.2  2003/02/24 09:49:26  colin
80   * added args for i18n keys
81   *
82   * Revision 1.1  2003/01/30 07:53:13  colin
83   * first version
84   * -----------------------------------------------------------------------------
85   */
86  package com.ivata.mask.web.tag.html;
87  import java.util.List;
88  
89  import javax.servlet.jsp.JspException;
90  /***
91   * <p>
92   * Overrides an HTML <code>&lt;input type=submit&gt;</code> tag for reseting
93   * the current form, by overriding the class from <strong>Struts </strong>.
94   * </p>
95   *
96   * <p>
97   * <b>Tag attributes: </b> <br/><table cellpadding='2' cellspacing='5'
98   * border='0' align='center' width='85%'>
99   * <tr class='TableHeadingColor'>
100  * <th>attribute</th>
101  * <th>reqd.</th>
102  * <th>param. class</th>
103  * <th width='100%'>description</th>
104  * </tr>
105  * <tr>
106  * <td>fieldName</td>
107  * <td>true</td>
108  * <td><code>java.lang.String</code></td>
109  * <td>The field name is used to default the following attributes of the tag:
110  * <br/>
111  * <ul>
112  * <li><code>styleId</code></li>
113  * <li><code>titleKey</code></li>
114  * <li><code>valueKey</code></li>
115  * </ul>.</td>
116  * </tr>
117  * <tr>
118  * <td>titleKey</td>
119  * <td>true</td>
120  * <td><code>java.lang.String</code></td>
121  * <td>Specifies the localized text to use for mouse-over events.</td>
122  * </tr>
123  * <tr>
124  * <td>valueKey</td>
125  * <td>true</td>
126  * <td><code>java.lang.String</code></td>
127  * <td>Specifies the localized text to use for the button text.</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.ResetTag Stuts} are included.
135  * </p>
136  *
137  * @since ivata masks 0.4 (2003-01-15)
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 ResetTag extends org.apache.struts.taglib.html.ResetTag {
143     /***
144      * <p>
145      * Stores and maintains <strong>ivata op </strong> specific mask properties.
146      * </p>
147      */
148     private MaskProperties maskProperties = new MaskProperties();
149     /***
150      * <p>
151      * Overridden to reset mask properties.
152      * </p>
153      *
154      * @return <code>EVAL_PAGE</code> since we always want to evaluate the
155      *         page after this tag.
156      *
157      * @throws JspException
158      *             if there is an error in the mask properties.
159      *
160      */
161     public int doEndTag() throws JspException {
162         int returnValue = super.doEndTag();
163         maskProperties.reset(this);
164         return returnValue;
165     }
166     /***
167      * <p>
168      * Overridden to set the value and title strings to the values represented
169      * by the localized keys in this class.
170      * </p>
171      *
172      * @return value returned by superclass method.
173      *
174      * @throws JspException
175      *             if either <code>valueKey</code> or <code>titleKey</code>
176      *             have not been set, or as thrown by superclass method.
177      */
178     public int doStartTag() throws JspException {
179         maskProperties.doStartTag(this, pageContext);
180         return super.doStartTag();
181     }
182     /***
183      * <p>
184      * Calls {@link MaskProperties#getBundleMaskProperites.getBundle}.
185      * </p>
186      *
187      * @return the current value of bundle.
188      */
189     public final String getBundle() {
190         return maskProperties.getBundle();
191     }
192     /***
193      * <p>
194      * Stores and maintains <strong>ivata op </strong> specific mask properties.
195      * </p>
196      *
197      * @return the current value of maskProperties.
198      */
199     public MaskProperties getMaskProperties() {
200         return maskProperties;
201     }
202     public final List getTitleArgs() {
203         return maskProperties.getTitleArgs();
204     }
205     /***
206      * <p>
207      * Get the value of the key used to localize the title tag attribute.
208      * </p>
209      *
210      * @return the current value of titleKey.
211      */
212     public String getTitleKey() {
213         return maskProperties.getValueKey();
214     }
215     public final List getValueArgs() {
216         return maskProperties.getValueArgs();
217     }
218     /***
219      * <p>
220      * Get the value of the key used to localize the value tag attribute.
221      * </p>
222      *
223      * @return the current value of valueKey.
224      */
225     public String getValueKey() {
226         return maskProperties.getValueKey();
227     }
228     /***
229      * <p>
230      * >Name of the field to which this label refers. This is used in
231      * conjunction with the <code>resourceFieldPath</code> to retrieve the
232      * correct message resources path.
233      * </p>
234      *
235      * @param fieldName
236      *            the new value of fieldName.
237      */
238     public void setFieldName(final String fieldName) {
239         maskProperties.setFieldName(fieldName);
240     }
241     /***
242      * <p>
243      * Stores and maintains <strong>ivata op </strong> specific mask properties.
244      * </p>
245      *
246      * @param maskPropertiesParam
247      *            the new value of maskProperties.
248      */
249     public void setMaskProperties(final MaskProperties maskPropertiesParam) {
250         this.maskProperties = maskPropertiesParam;
251     }
252     /***
253      * Refer to {@link MaskProperties#setTitleArgs}.
254      *
255      * @param args Refer to {@link MaskProperties#setTitleArgs}.
256      */
257     public final void setTitleArgs(final List args) {
258         maskProperties.setTitleArgs(args);
259     }
260     /***
261      * <p>
262      * Set the value of the key used to localize the title tag attribute.
263      * </p>
264      *
265      * @param titleKey
266      *            the new value of titleKey.
267      */
268     public final void setTitleKey(final String titleKey) {
269         maskProperties.setTitleKey(titleKey);
270     }
271     /***
272      * Refer to {@link MaskProperties#setValueArgs}.
273      *
274      * @param args Refer to {@link MaskProperties#setValueArgs}.
275      */
276     public final void setValueArgs(final List args) {
277         maskProperties.setValueArgs(args);
278     }
279     /***
280      * <p>
281      * Set the value of the key used to localize the value tag attribute.
282      * </p>
283      *
284      * @param valueKey
285      *            the new value of valueKey.
286      */
287     public void setValueKey(final String valueKey) {
288         maskProperties.setValueKey(valueKey);
289     }
290 }
291