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: ClearTag.java,v $
31 * Revision 1.2 2005/04/09 18:04:20 colinmacleod
32 * Changed copyright text to GPL v2 explicitly.
33 *
34 * Revision 1.1 2005/01/06 23:10:05 colinmacleod
35 * Moved up a version number.
36 * Changed copyright notices to 2005.
37 * Updated the documentation:
38 * - started working on multiproject:site docu.
39 * - changed the logo.
40 * Added checkstyle and fixed LOADS of style issues.
41 * Added separate thirdparty subproject.
42 * Added struts (in web), util and webgui (in webtheme) from ivata op.
43 *
44 * Revision 1.3 2004/12/31 19:30:58 colinmacleod
45 * Changed isNew attribute on clear button to asNewButton, to make the meaning
46 * clearer.
47 *
48 * Revision 1.2 2004/03/21 21:16:35 colinmacleod
49 * Shortened name to ivata op.
50 *
51 * Revision 1.1.1.1 2004/01/27 20:59:38 colinmacleod
52 * Moved ivata op to SourceForge.
53 *
54 * Revision 1.2 2003/10/16 15:43:03 jano
55 * Fixes problems with building and some problems with splitting to subprojects
56 *
57 * Revision 1.1.1.1 2003/10/13 20:49:23 colin
58 * Restructured portal into subprojects
59 *
60 * Revision 1.2 2003/03/04 18:27:06 colin
61 * set property always to clear (even if it is a new button)
62 *
63 * Revision 1.1 2003/03/03 16:57:12 colin
64 * converted localization to automatic paths
65 * added labels
66 * added mandatory fieldName attribute
67 * -----------------------------------------------------------------------------
68 */
69 package com.ivata.mask.web.tag.html;
70 import javax.servlet.jsp.JspException;
71 /***
72 * <p>
73 * Overridden from <code>SubmitTag</code> for convenience, this tag creates a
74 * submit button with the name <code>new</code> or <code>Clear</code>. If
75 * you set the parameter <code>asNewButton</code> to <code>true</code> then
76 * it will be a <code>new</code> submit.
77 * </p>
78 *
79 * <p>
80 * <b>Tag attributes: </b> <br/><table cellpadding='2' cellspacing='5'
81 * border='0' align='center' width='85%'>
82 * <tr class='TableHeadingColor'>
83 * <th>attribute</th>
84 * <th>reqd.</th>
85 * <th>param. class</th>
86 * <th width='100%'>description</th>
87 * </tr>
88 * <tr>
89 * <td>asNewButton</td>
90 * <td>true</td>
91 * <td><code>boolean</code></td>
92 * <td>If <code>true</code>, then this is a New button. Otherwise a Clear
93 * button is created.</td>
94 * </tr>
95 * </table>
96 * </p>
97 *
98 * <p>
99 * <b>Note: </b> all the tag attributes from {@linkSubmitTag SubmitTag} are
100 * included.
101 * </p>
102 *
103 * @since ivata masks 0.4 (2003-03-01)
104 * @author Colin MacLeod
105 * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
106 * @version $Revision: 1.2 $
107 */
108 public class ClearTag extends SubmitTag {
109 /***
110 * <p>
111 * If <code>true</code>, then this is a New button. Otherwise a Clear
112 * button is created.
113 * </p>
114 */
115 private boolean asNewButton = false;
116 /***
117 * <p>
118 * Overridden to set the value and title strings to the values represented
119 * by the localized keys in this class.
120 * </p>
121 *
122 * @return value returned by superclass method.
123 *
124 * @throws JspException
125 * if either <code>valueKey</code> or <code>titleKey</code>
126 * have not been set, or as thrown by superclass method.
127 */
128 public int doStartTag() throws JspException {
129 if (asNewButton) {
130 setFieldName("new");
131 } else {
132 setFieldName("clear");
133 }
134 setProperty("clear");
135 return super.doStartTag();
136 }
137 /***
138 * <p>
139 * If <code>true</code>, then this is a New button. Otherwise a Clear
140 * button is created.
141 * </p>
142 *
143 * @return the current value of asNewButton.
144 */
145 public boolean getAsNewButton() {
146 return asNewButton;
147 }
148 /***
149 * <p>
150 * If <code>true</code>, then this is a New button. Otherwise a Clear
151 * button is created.
152 * </p>
153 *
154 * @param asNewButtonParam
155 * the new value of asNewButton.
156 */
157 public void setAsNewButton(final boolean asNewButtonParam) {
158 this.asNewButton = asNewButtonParam;
159 }
160 }
161