001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata masks may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: MaskForm.java,v $
031: * Revision 1.12 2005/10/12 18:36:58 colinmacleod
032: * Standardized format of Logger declaration - to make it easier to find instances
033: * which are not both static and final.
034: *
035: * Revision 1.11 2005/10/11 18:54:06 colinmacleod
036: * Fixed some checkstyle and javadoc issues.
037: *
038: * Revision 1.10 2005/10/03 10:17:25 colinmacleod
039: * Fixed some style and javadoc issues.
040: *
041: * Revision 1.9 2005/10/02 14:06:34 colinmacleod
042: * Added/improved log4j logging.
043: *
044: * Revision 1.8 2005/09/29 12:17:35 colinmacleod
045: * Moved resourceFieldPath from InputMaskForm to MaskForm.
046: *
047: * Revision 1.7 2005/04/11 14:50:28 colinmacleod
048: * Renamed MaskRequestProcessorConstants
049: * to FieldValueConvertorConstants.
050: *
051: * Revision 1.6 2005/04/09 18:04:19 colinmacleod
052: * Changed copyright text to GPL v2 explicitly.
053: *
054: * Revision 1.5 2005/03/10 10:44:35 colinmacleod
055: * Fixed validation conversion of Struts classes to
056: * ivata masks validation errors.
057: *
058: * Revision 1.4 2005/01/19 13:14:02 colinmacleod
059: * Renamed CausedByException to SystemException.
060: *
061: * Revision 1.3 2005/01/07 08:08:24 colinmacleod
062: * Moved up a version number.
063: * Changed copyright notices to 2005.
064: * Updated the documentation:
065: * - started working on multiproject:site docu.
066: * - changed the logo.
067: * Added checkstyle and fixed LOADS of style issues.
068: * Added separate thirdparty subproject.
069: * Added struts (in web), util and webgui (in webtheme) from ivata op.
070: *
071: * Revision 1.2 2004/12/23 21:28:32 colinmacleod
072: * Modifications to add ivata op compatibility.
073: *
074: * Revision 1.1.1.1 2004/05/16 20:40:32 colinmacleod
075: * Ready for 0.1 release
076: * -----------------------------------------------------------------------------
077: */
078: package com.ivata.mask.web.struts;
079:
080: import org.apache.log4j.Logger;
081:
082: import javax.naming.OperationNotSupportedException;
083: import javax.servlet.http.HttpServletRequest;
084: import javax.servlet.http.HttpSession;
085:
086: import com.ivata.mask.Mask;
087: import com.ivata.mask.field.FieldValueConvertorConstants;
088: import com.ivata.mask.validation.ValidationErrors;
089:
090: /**
091: * <p>
092: * This form is the base class of all forms containing mask information.
093: * </p>
094: *
095: * @since ivata masks 0.1.1 (2005-05-16)
096: * @author Colin MacLeod
097: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
098: * @version $Revision: 1.12 $
099: */
100: public abstract class MaskForm extends DialogForm {
101: /**
102: * Logger for this class.
103: */
104: private static final Logger logger = Logger
105: .getLogger(MaskForm.class);
106:
107: /**
108: * <p>
109: * Defines the base class of all objects in the value object list.
110: * </p>
111: */
112: private Class baseClass;
113: /**
114: * <p>
115: * Mask containing all the field definitions for this list.
116: * </p>
117: */
118: private Mask mask;
119: /**
120: * <copyDoc>Refer to {@link #getResourceFieldPath}.</copyDoc>
121: */
122: private String resourceFieldPath;
123:
124: /**
125: * <p>
126: * Construct an instance of this class.
127: * </p>
128: *
129: * @param maskParam
130: * mask associated with this form.
131: * @param baseClassParam
132: * base class of all value objects in this form.
133: */
134: protected MaskForm(final Mask maskParam, final Class baseClassParam) {
135: this .mask = maskParam;
136: this .baseClass = baseClassParam;
137: }
138:
139: /**
140: * <copyDoc>Refer to {@link }.</copyDoc>
141: *
142: * @throws OperationNotSupportedException
143: * @see com.ivata.mask.web.struts.DialogForm#clear()
144: */
145: protected void clear() throws OperationNotSupportedException {
146: if (logger.isDebugEnabled()) {
147: logger.debug("clear() - start");
148: }
149:
150: // TODO Auto-generated method stub
151:
152: if (logger.isDebugEnabled()) {
153: logger.debug("clear() - end");
154: }
155: }
156:
157: /**
158: * <p>
159: * Defines the base class of all objects in the value object list.
160: * </p>
161: *
162: * @return base class of all objects in the value object list.
163: */
164: public final Class getBaseClass() {
165: if (logger.isDebugEnabled()) {
166: logger.debug("getBaseClass() - start");
167: }
168:
169: if (logger.isDebugEnabled()) {
170: logger.debug("getBaseClass() - end - return value = "
171: + baseClass);
172: }
173: return baseClass;
174: }
175:
176: /**
177: * <p>
178: * Mask containing all the field definitions for this list.
179: * </p>
180: *
181: * @return mask containing all the field definitions for this list.
182: */
183: public final Mask getMask() {
184: if (logger.isDebugEnabled()) {
185: logger.debug("getMask() - start");
186: }
187:
188: if (logger.isDebugEnabled()) {
189: logger.debug("getMask() - end - return value = " + mask);
190: }
191: return mask;
192: }
193:
194: /**
195: * This method overridden to retrieve errors from the request processor.
196: * This will allocate any errors which occurred as the form was set.
197: *
198: * @param requestParam {@inheritDoc}
199: * @param sessionParam {@inheritDoc}
200: * @return errors from the super class, with errors from the request
201: * (if any). Never returns <code>null</code>.
202: */
203: public ValidationErrors validate(
204: final HttpServletRequest requestParam,
205: final HttpSession sessionParam) {
206: if (logger.isDebugEnabled()) {
207: logger.debug("validate(HttpServletRequest requestParam = "
208: + requestParam + ", HttpSession sessionParam = "
209: + sessionParam + ") - start");
210: }
211:
212: ValidationErrors super Errors = super .validate(requestParam,
213: sessionParam);
214:
215: // first get any validation errors from the request - these are set
216: // by the request processor for masks.
217: ValidationErrors requestErrors = (ValidationErrors) requestParam
218: .getAttribute(FieldValueConvertorConstants.ERROR_REQUEST_ATTRIBUTE);
219: if (requestErrors != null) {
220: super Errors.addAll(requestErrors);
221: }
222:
223: if (logger.isDebugEnabled()) {
224: logger.debug("validate - end - return value = "
225: + super Errors);
226: }
227: return super Errors;
228: }
229:
230: /**
231: * <p>
232: * The resource field path is the "stem" - the first string before
233: * the dot separator (.) - in the application resources for the fields in
234: * this form.
235: * </p>
236: * <p>
237: * For example, in a form for editing group information this might be simply
238: * <b>"group"</b>, and the message resource key for the group
239: * parent field would then be specified in the
240: * <code>ApplicationResources.properties</code> file as
241: * <b>"group.field.parent"</b> (without the quotes).
242: * </p>
243: * @return Returns the path to application resources for this form.
244: */
245: public String getResourceFieldPath() {
246: if (logger.isDebugEnabled()) {
247: logger.debug("getResourceFieldPath() - start");
248: }
249:
250: if (logger.isDebugEnabled()) {
251: logger
252: .debug("getResourceFieldPath() - end - return value = "
253: + resourceFieldPath);
254: }
255: return resourceFieldPath;
256: }
257:
258: /**
259: * <copyDoc>Refer to {@link #getResourceFieldPath}.</copyDoc>
260: * @param resourceFieldPathParam
261: * <copyDoc>Refer to {@link #getResourceFieldPath}.</copyDoc>
262: */
263: public void setResourceFieldPath(final String resourceFieldPathParam) {
264: if (logger.isDebugEnabled()) {
265: logger.debug("setResourceFieldPath before: '"
266: + resourceFieldPath + "', after: '"
267: + resourceFieldPathParam + "'");
268: }
269:
270: resourceFieldPath = resourceFieldPathParam;
271:
272: if (logger.isDebugEnabled()) {
273: logger.debug("setResourceFieldPath(String) - end");
274: }
275: }
276: }
|