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: MaskForm.java,v $
31   * Revision 1.7  2005/04/11 14:50:28  colinmacleod
32   * Renamed MaskRequestProcessorConstants
33   * to FieldValueConvertorConstants.
34   *
35   * Revision 1.6  2005/04/09 18:04:19  colinmacleod
36   * Changed copyright text to GPL v2 explicitly.
37   *
38   * Revision 1.5  2005/03/10 10:44:35  colinmacleod
39   * Fixed validation conversion of Struts classes to
40   * ivata masks validation errors.
41   *
42   * Revision 1.4  2005/01/19 13:14:02  colinmacleod
43   * Renamed CausedByException to SystemException.
44   *
45   * Revision 1.3  2005/01/07 08:08:24  colinmacleod
46   * Moved up a version number.
47   * Changed copyright notices to 2005.
48   * Updated the documentation:
49   *   - started working on multiproject:site docu.
50   *   - changed the logo.
51   * Added checkstyle and fixed LOADS of style issues.
52   * Added separate thirdparty subproject.
53   * Added struts (in web), util and webgui (in webtheme) from ivata op.
54   *
55   * Revision 1.2  2004/12/23 21:28:32  colinmacleod
56   * Modifications to add ivata op compatibility.
57   *
58   * Revision 1.1.1.1  2004/05/16 20:40:32  colinmacleod
59   * Ready for 0.1 release
60   * -----------------------------------------------------------------------------
61   */
62  package com.ivata.mask.web.struts;
63  import javax.naming.OperationNotSupportedException;
64  import javax.servlet.http.HttpServletRequest;
65  import javax.servlet.http.HttpSession;
66  
67  import com.ivata.mask.Mask;
68  import com.ivata.mask.field.FieldValueConvertorConstants;
69  import com.ivata.mask.validation.ValidationErrors;
70  /***
71   * <p>
72   * This form is the base class of all forms containing mask information.
73   * </p>
74   *
75   * @since ivata masks 0.1.1 (2005-05-16)
76   * @author Colin MacLeod
77   * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
78   * @version $Revision: 1.7 $
79   */
80  public abstract class MaskForm extends DialogForm {
81      /***
82       * <p>
83       * Defines the base class of all objects in the value object list.
84       * </p>
85       */
86      private Class baseClass;
87      /***
88       * <p>
89       * Mask containing all the field definitions for this list.
90       * </p>
91       */
92      private Mask mask;
93      /***
94       * <p>
95       * Construct an instance of this class.
96       * </p>
97       *
98       * @param maskParam
99       *            mask associated with this form.
100      * @param baseClassParam
101      *            base class of all value objects in this form.
102      */
103     protected MaskForm(final Mask maskParam, final Class baseClassParam) {
104         this.mask = maskParam;
105         this.baseClass = baseClassParam;
106     }
107     /***
108      * Refer to {@link }.
109      *
110      * @throws OperationNotSupportedException
111      * @see com.ivata.mask.web.struts.DialogForm#clear()
112      */
113     protected void clear() throws OperationNotSupportedException {
114         // TODO Auto-generated method stub
115 
116     }
117     /***
118      * <p>
119      * Defines the base class of all objects in the value object list.
120      * </p>
121      *
122      * @return base class of all objects in the value object list.
123      */
124     public final Class getBaseClass() {
125         return baseClass;
126     }
127     /***
128      * <p>
129      * Mask containing all the field definitions for this list.
130      * </p>
131      *
132      * @return mask containing all the field definitions for this list.
133      */
134     public final Mask getMask() {
135         return mask;
136     }
137     /***
138      * This method overridden to retrieve errors from the request processor.
139      * This will allocate any errors which occurred as the form was set.
140      *
141      * @param requestParam Refer to {@link DialogForm#validate}.
142      * @param sessionParam Refer to {@link DialogForm#validate}.
143      * @return errors from the super class, with errors from the request
144      * (if any). Never returns <code>null</code>.
145      */
146     public ValidationErrors validate(final HttpServletRequest requestParam,
147             final HttpSession sessionParam) {
148         ValidationErrors superErrors
149             =  super.validate(requestParam, sessionParam);
150 
151         // first get any validation errors from the request - these are set
152         // by the request processor for masks.
153         ValidationErrors requestErrors = (ValidationErrors) requestParam
154                 .getAttribute(FieldValueConvertorConstants
155                         .ERROR_REQUEST_ATTRIBUTE);
156         if (requestErrors != null) {
157             superErrors.addAll(requestErrors);
158         }
159         return superErrors;
160     }
161 }
162