1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package examples.multibox;
20
21 import javax.servlet.http.HttpServletRequest;
22
23 import org.apache.struts.action.ActionErrors;
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionMapping;
26
27 /***
28 * An ActionForm for the Multibox examples
29 *
30 * @version $Rev: 421486 $ $Date: 2006-07-12 20:37:08 -0700 (Wed, 12 Jul 2006) $
31 */
32 public class MultiboxActionForm extends ActionForm {
33
34
35
36 /*** Fruits */
37 private String[] fruits = {};
38
39 /*** Colors */
40 private String[] colors = {};
41
42
43
44 /***
45 * Constructor for MultiboxActionForm.
46 */
47 public MultiboxActionForm() {
48 super();
49 }
50
51
52
53 /***
54 * Clear all checkboxes
55 *
56 * @param mapping The mapping used to select this instance
57 * @param request The servlet request we are processing
58 */
59 public void reset(ActionMapping mapping, HttpServletRequest request) {
60
61
62
63
64
65
66 String[] empty = {};
67 this.fruits = empty;
68 this.colors = empty;
69
70 }
71
72 /***
73 * Validate the properties that have been set from this HTTP request,
74 * and return an <code>ActionMessages</code> object that encapsulates any
75 * validation errors that have been found. If no errors are found, return
76 * <code>null</code> or an <code>ActionMessages</code> object with no
77 * recorded error messages.
78 *
79 * @param mapping The mapping used to select this instance
80 * @param request The servlet request we are processing
81 *
82 * @return ActionMessages if any validation errors occurred
83 */
84 public ActionErrors validate(
85 ActionMapping mapping,
86 HttpServletRequest request) {
87
88
89
90
91
92
93
94 return null;
95 }
96
97
98
99 /***
100 * Returns the colors.
101 * @return String[]
102 */
103 public String[] getColors() {
104 return colors;
105 }
106
107 /***
108 * Returns the fruits.
109 * @return String[]
110 */
111 public String[] getFruits() {
112 return fruits;
113 }
114
115 /***
116 * Sets the colors.
117 * @param colors The colors to set
118 */
119 public void setColors(String[] colors) {
120 this.colors = colors;
121 }
122
123 /***
124 * Sets the fruits.
125 * @param fruits The fruits to set
126 */
127 public void setFruits(String[] fruits) {
128 this.fruits = fruits;
129 }
130
131 }