01: /*
02: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
03: *
04: * This file is part of TransferCM.
05: *
06: * TransferCM is free software; you can redistribute it and/or modify it under the
07: * terms of the GNU General Public License as published by the Free Software
08: * Foundation; either version 2 of the License, or (at your option) any later
09: * version.
10: *
11: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18: * Fifth Floor, Boston, MA 02110-1301 USA
19: */
20:
21: package com.methodhead.aikp;
22:
23: import javax.servlet.http.HttpServletRequest;
24:
25: import org.apache.struts.action.ActionErrors;
26: import org.apache.struts.action.ActionMapping;
27:
28: import org.apache.struts.validator.DynaValidatorForm;
29: import org.apache.commons.lang.StringUtils;
30:
31: public class AikpForm extends DynaValidatorForm {
32:
33: // constructors /////////////////////////////////////////////////////////////
34:
35: // constants ////////////////////////////////////////////////////////////////
36:
37: // classes //////////////////////////////////////////////////////////////////
38:
39: // methods //////////////////////////////////////////////////////////////////
40:
41: /**
42: * Calls {@link #doValidate doValidate()} for <tt>save</tt> and
43: * <tt>saveNew</tt> action if the delete or cancel button was not clicked.
44: * <tt>DynaValidatorForm.validate()</tt> is called and the resulting errors
45: * are passed to {@link #doValidate doValidate()}.
46: */
47: public ActionErrors validate(ActionMapping mapping,
48: HttpServletRequest request) {
49:
50: if (("save".equals(get("action")) || "saveNew"
51: .equals(get("action")))
52: && (StringUtils.isBlank((String) get("delete")) && StringUtils
53: .isBlank((String) get("cancel"))))
54: return doValidate(mapping, request, super .validate(mapping,
55: request));
56:
57: return new ActionErrors();
58: }
59:
60: /**
61: * Returns <tt>errors</tt>; subclasses should override this method and
62: * perform their own validation. <tt>errors</tt> contains any errors
63: * resulting from the default validation.
64: */
65: public ActionErrors doValidate(ActionMapping mapping,
66: HttpServletRequest request, ActionErrors errors) {
67:
68: return errors;
69: }
70:
71: // properties ///////////////////////////////////////////////////////////////
72:
73: // attributes ///////////////////////////////////////////////////////////////
74: }
|