1
2
3
4
5
6
7
8
9
10
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
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
59
60 public String[] getCheckboxes() {
61 return checkboxes;
62 }
63
64
65
66
67 public void setCheckboxes(String[] strings) {
68 checkboxes = strings;
69 }
70 }