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: CancelTag.java,v $
31   * Revision 1.5  2005/04/26 14:47:19  colinmacleod
32   * No longer displays when printing.
33   *
34   * Revision 1.4  2005/04/09 18:04:20  colinmacleod
35   * Changed copyright text to GPL v2 explicitly.
36   *
37   * Revision 1.3  2005/03/10 10:45:38  colinmacleod
38   * Fixes for tomcat4. Changed setters and getters
39   * to both use the same types.
40   *
41   * Revision 1.2  2005/01/19 13:14:03  colinmacleod
42   * Renamed CausedByException to SystemException.
43   *
44   * Revision 1.1  2005/01/06 23:10:05  colinmacleod
45   * Moved up a version number.
46   * Changed copyright notices to 2005.
47   * Updated the documentation:
48   *   - started working on multiproject:site docu.
49   *   - changed the logo.
50   * Added checkstyle and fixed LOADS of style issues.
51   * Added separate thirdparty subproject.
52   * Added struts (in web), util and webgui (in webtheme) from ivata op.
53   *
54   * Revision 1.4  2004/11/03 16:12:09  colinmacleod
55   * Changed fieldPath to resourceFieldPath.
56   *
57   * Revision 1.3  2004/07/13 19:48:10  colinmacleod
58   * Moved project to POJOs from EJBs.
59   * Applied PicoContainer to services layer (replacing session EJBs).
60   * Applied Hibernate to persistence layer (replacing entity EJBs).
61   *
62   * Revision 1.2  2004/03/21 21:16:35  colinmacleod
63   * Shortened name to ivata op.
64   *
65   * Revision 1.1.1.1  2004/01/27 20:59:38  colinmacleod
66   * Moved ivata op to SourceForge.
67   *
68   * Revision 1.2  2003/10/16 15:43:03  jano
69   * Fixes problems with building and some problems with splitting to subprojects
70   *
71   * Revision 1.1.1.1  2003/10/13 20:49:23  colin
72   * Restructured portal into subprojects
73   *
74   * Revision 1.3  2003/03/03 20:53:14  colin
75   * reset fieldName to cancel in doEndTag
76   *
77   * Revision 1.2  2003/03/03 16:57:12  colin
78   * converted localization to automatic paths
79   * added labels
80   * added mandatory fieldName attribute
81   *
82   * Revision 1.1  2003/02/24 19:33:33  colin
83   * Moved to new subproject.
84   *
85   * Revision 1.4  2003/02/24 09:49:26  colin
86   * added args for i18n keys
87   *
88   * Revision 1.3  2003/01/30 07:52:44  colin
89   * bugfixes in mandatory handling
90   *
91   * Revision 1.2  2003/01/27 08:26:21  colin
92   * SSLEXT & i18n changes
93   *
94   * Revision 1.1  2003/01/18 20:32:08  colin
95   * added html struts override tags and help
96   * -----------------------------------------------------------------------------
97   */
98  package com.ivata.mask.web.tag.html;
99  import java.util.List;
100 
101 import javax.servlet.jsp.JspException;
102 /***
103  * <p>
104  * Overrides an HTML <code>&lt;input type=submit&gt;</code> tag, by overriding
105  * the class from <strong>Struts </strong>.
106  * </p>
107  *
108  * <p>
109  * <b>Tag attributes: </b> <br/><table cellpadding='2' cellspacing='5'
110  * border='0' align='center' width='85%'>
111  * <tr class='TableHeadingColor'>
112  * <th>attribute</th>
113  * <th>reqd.</th>
114  * <th>param. class</th>
115  * <th width='100%'>description</th>
116  * </tr>
117  * <tr>
118  * <td>fieldName</td>
119  * <td>true</td>
120  * <td><code>java.lang.String</code></td>
121  * <td>The field name is used to default the following attributes of the tag:
122  * <br/>
123  * <ul>
124  * <li><code>styleId</code></li>
125  * <li><code>titleKey</code></li>
126  * <li><code>valueKey</code></li>
127  * </ul>.</td>
128  * </tr>
129  * <tr>
130  * <td>titleKey</td>
131  * <td>true</td>
132  * <td><code>java.lang.String</code></td>
133  * <td>Specifies the localized text to use for mouse-over events.</td>
134  * </tr>
135  * <tr>
136  * <td>valueKey</td>
137  * <td>true</td>
138  * <td><code>java.lang.String</code></td>
139  * <td>Specifies the localized text to use for the button text.</td>
140  * </tr>
141  * </table>
142  * </p>
143  *
144  * <p>
145  * <b>Note: </b> all the tag attributes from {@link
146  * org.apache.struts.taglib.html.CancelTag Stuts} are included.
147  * </p>
148  *
149  * @since ivata masks 0.4 (2003-01-15)
150  * @author Colin MacLeod
151  * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
152  * @version $Revision: 1.5 $
153  */
154 public class CancelTag extends org.apache.struts.taglib.html.CancelTag {
155     /***
156      * <p>
157      * >Name of the field to which this label refers. This is used in
158      * conjunction with the <code>resourceFieldPath</code> to retrieve the
159      * correct message resources path.
160      * </p>
161      */
162     private String fieldName = "cancel";
163     /***
164      * <p>
165      * Stores and maintains <strong>ivata op </strong> specific mask properties.
166      * </p>
167      */
168     private MaskProperties maskProperties = new MaskProperties();
169     /***
170      * <p>
171      * Overridden to reset mask properties.
172      * </p>
173      *
174      * @return <code>EVAL_PAGE</code> since we always want to evaluate the
175      *         page after this tag.
176      *
177      * @throws JspException
178      *             if there is an error in the mask properties.
179      */
180     public int doEndTag() throws JspException {
181         // if this is read only, do nothing
182         if (maskProperties.getReadOnly()
183                 || (pageContext.getRequest().getParameter("print") != null)) {
184             maskProperties.reset(this);
185             return EVAL_PAGE;
186         }
187         int returnValue = super.doEndTag();
188         maskProperties.reset(this);
189         this.fieldName = "cancel";
190         return returnValue;
191     }
192     /***
193      * <p>
194      * Overridden to set the value and title strings to the values represented
195      * by the localized keys in this class.
196      * </p>
197      *
198      * @return value returned by superclass method.
199      *
200      * @throws JspException
201      *             if either <code>valueKey</code> or <code>titleKey</code>
202      *             have not been set, or as thrown by superclass method.
203      */
204     public int doStartTag() throws JspException {
205         maskProperties.setFieldName(fieldName);
206         maskProperties.doStartTag(this, pageContext);
207         return super.doStartTag();
208     }
209     /***
210      * Refer to {@link MaskProperties#getBundle}.
211      *
212      * @return Refer to {@link MaskProperties#getBundle}.
213      */
214     public final String getBundle() {
215         return maskProperties.getBundle();
216     }
217     /***
218      * <p>
219      * Stores and maintains <strong>ivata op </strong> specific mask properties.
220      * </p>
221      *
222      * @return the current value of maskProperties.
223      */
224     public MaskProperties getMaskProperties() {
225         return maskProperties;
226     }
227     public final List getTitleArgs() {
228         return maskProperties.getTitleArgs();
229     }
230     /***
231      * <p>
232      * Get the value of the key used to localize the title tag attribute.
233      * </p>
234      *
235      * @return the current value of titleKey.
236      */
237     public String getTitleKey() {
238         return maskProperties.getTitleKey();
239     }
240     public final List getValueArgs() {
241         return maskProperties.getValueArgs();
242     }
243     /***
244      * <p>
245      * Get the value of the key used to localize the value tag attribute.
246      * </p>
247      *
248      * @return the current value of valueKey.
249      */
250     public String getValueKey() {
251         return maskProperties.getValueKey();
252     }
253     /***
254      * <p>
255      * >Name of the field to which this label refers. This is used in
256      * conjunction with the <code>resourceFieldPath</code> to retrieve the
257      * correct message resources path.
258      * </p>
259      *
260      * @param fieldNameParam
261      *            the new value of fieldName.
262      */
263     public void setFieldName(final String fieldNameParam) {
264         this.fieldName = fieldNameParam;
265     }
266     /***
267      * <p>
268      * Stores and maintains <strong>ivata op </strong> specific mask properties.
269      * </p>
270      *
271      * @param maskPropertiesParam
272      *            the new value of maskProperties.
273      */
274     public void setMaskProperties(final MaskProperties maskPropertiesParam) {
275         this.maskProperties = maskPropertiesParam;
276     }
277     /***
278      * Refer to {@link MaskProperties#setTitleArgs}.
279      *
280      * @param args Refer to {@link MaskProperties#setTitleArgs}.
281      */
282     public final void setTitleArgs(final List args) {
283         maskProperties.setTitleArgs(args);
284     }
285     /***
286      * Refer to {@link MaskProperties#setTitleKey}.
287      *
288      * @param titleKeyParam Refer to {@link MaskProperties#setTitleKey}.
289      */
290     public final void setTitleKey(final String titleKeyParam) {
291         maskProperties.setTitleKey(titleKeyParam);
292     }
293     /***
294      * Refer to {@link MaskProperties#setValueArgs}.
295      *
296      * @param args Refer to {@link MaskProperties#setValueArgs}.
297      */
298     public final void setValueArgs(final List args) {
299         maskProperties.setValueArgs(args);
300     }
301     /***
302      * <p>
303      * Set the value of the key used to localize the value tag attribute.
304      * </p>
305      *
306      * @param valueKey
307      *            the new value of valueKey.
308      */
309     public final void setValueKey(final String valueKey) {
310         maskProperties.setValueKey(valueKey);
311     }
312 }
313