View Javadoc

1   /*Copyright (C) 2004-... Stephane Gauchet for Hyphonem
2   
3    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
4   
5    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6   
7    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8    
9    Written by St�phane Gauchet
10   mail me at : sgauchet@free.fr
11   */
12  package fr.hyphonem.conges.forms;
13  
14  import javax.servlet.http.HttpServletRequest;
15  
16  import org.apache.struts.action.ActionError;
17  import org.apache.struts.action.ActionErrors;
18  import org.apache.struts.action.ActionForm;
19  import org.apache.struts.action.ActionMapping;
20  
21  /**
22   * @author Stephane Gauchet pour Hyphonem
23   * 
24   */
25  public class ValidatingForm extends ActionForm {
26  
27  	/**
28  	 * 
29  	 */
30  	private static final long serialVersionUID = 1L;
31  
32  	private String[] checkboxes;
33  
34  	/**
35  	 * 
36  	 */
37  	public ValidatingForm() {
38  		super();
39  		resetFields();
40  	}
41  
42  	private void resetFields() {
43  		checkboxes = null;
44  	}
45  
46  	public ActionErrors validate(ActionMapping mapping,
47  			HttpServletRequest request) {
48  		ActionErrors errors = new ActionErrors();
49  		if (getCheckboxes() == null) {
50  			errors.add("error.at.least.one.checkbox", new ActionError(
51  					"error.at.least.one.checkbox"));
52  		}
53  
54  		return errors;
55  	}
56  
57  	/**
58  	 * @return String[]
59  	 */
60  	public String[] getCheckboxes() {
61  		return checkboxes;
62  	}
63  
64  	/**
65  	 * @param strings
66  	 */
67  	public void setCheckboxes(String[] strings) {
68  		checkboxes = strings;
69  	}
70  }