KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > webapp > tiles > portal > PortalSettingsForm


1 /*
2  * $Id: PortalSettingsForm.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.struts.webapp.tiles.portal;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23
24 import org.apache.struts.action.ActionForm;
25
26
27 /**
28  * Action form used to read data from web page form.
29  */

30 public final class PortalSettingsForm extends ActionForm {
31
32     /** Validate value */
33   protected String JavaDoc validate;
34     /** empty list used by reset */
35   protected String JavaDoc[] empty = {};
36     /** list of "remaining" choices */
37   protected String JavaDoc[] remaining = empty;
38     /** list of user columns */
39   protected List JavaDoc columns = new ArrayList JavaDoc();
40     /** list of user columns labels */
41   protected List JavaDoc columnLabels = new ArrayList JavaDoc();
42     /** list of columns selected by user */
43   protected List JavaDoc newCols = new ArrayList JavaDoc();
44
45     /** Choice list */
46   protected List JavaDoc choice;
47     /** Choice list labels */
48   protected List JavaDoc choiceLabels;
49     /** Is initialized ? */
50   protected boolean initialized = false;
51
52
53     /**
54      * Set col
55      */

56   public void setCol( int index, List JavaDoc col )
57     {
58     columns.set( index, col);
59     }
60
61     /**
62      * Add col
63      */

64   public void addCol( List JavaDoc col )
65     {
66     columns.add( col);
67     }
68
69     /**
70      * Get col Labels
71      */

72   public List JavaDoc getColLabels(int index)
73     {
74     return (List JavaDoc)columnLabels.get(index);
75     }
76
77     /**
78      * Set col Labels
79      */

80   public void setColLabels( int index, List JavaDoc col )
81     {
82     columnLabels.set( index, col);
83     }
84
85     /**
86      * Add col Labels
87      */

88   public void addColLabels( List JavaDoc col )
89     {
90     columnLabels.add( col);
91     }
92
93     /**
94      * Get col
95      */

96   public List JavaDoc getCol(int index)
97     {
98     return (List JavaDoc)columns.get(index);
99     }
100
101     /**
102      * Set col Labels
103      */

104   public void setNewCol( int index, String JavaDoc list[] )
105     {
106       // ensure capacity
107
while( index>=newCols.size())newCols.add(null);
108     newCols.set( index, list);
109     }
110
111     /**
112      * Get col
113      */

114   public String JavaDoc[] getNewCol(int index)
115     {
116     if(newCols==null || index>=newCols.size())
117       return null;
118     return (String JavaDoc[])newCols.get(index);
119     }
120
121     /**
122      * Get number of columns
123      */

124   public int getNumCol()
125     {
126     return newCols.size();
127     }
128
129     /**
130      * Set list1
131      */

132   public void setL1( String JavaDoc array[] )
133     {
134     setNewCol(1, array);
135     }
136     /**
137      * Set list1
138      */

139   public String JavaDoc[] getL1()
140     {
141     return getNewCol(1);
142     }
143
144     /**
145      * Set list1
146      */

147   public void setL0( String JavaDoc array[] )
148     {
149     setNewCol(0, array);
150     }
151     /**
152      * Set list1
153      */

154   public String JavaDoc[] getL0()
155     {
156     return getNewCol(0);
157     }
158     /**
159      * Set list1
160      */

161   public void setRemaining( String JavaDoc array[] )
162     {
163     remaining = array;
164     }
165     /**
166      * Set list1
167      */

168   public String JavaDoc[] getRemaining()
169     {
170     return remaining;
171     }
172
173
174     /**
175      * Set list1
176      */

177   public void setChoices( List JavaDoc list )
178     {
179     choice = list;
180     }
181     /**
182      * Set list1
183      */

184   public void setChoiceLabels( List JavaDoc list )
185     {
186     choiceLabels = list;
187     }
188     /**
189      * Set list1
190      */

191   public List JavaDoc getChoices()
192     {
193     return choice;
194     }
195     /**
196      * Set list1
197      */

198   public List JavaDoc getChoiceLabels()
199     {
200     return choiceLabels;
201     }
202
203    /**
204     * Is this form submitted ?
205     */

206   public boolean isSubmitted()
207     {
208     return validate != null;
209     }
210
211    /**
212     * Is this form submitted ?
213     */

214   public void setValidate( String JavaDoc value)
215     {
216     this.validate = value;
217     }
218
219     /**
220      * Reset properties
221      */

222   public void reset()
223     {
224     remaining = empty;
225     validate = null;
226     columns.clear();
227     columnLabels.clear();
228     newCols.clear();
229     }
230     /**
231      * Initialized flag
232      */

233   public boolean isInitialized()
234     {
235     return initialized;
236     }
237     /**
238      * Initialized flag
239      */

240   public void setInitialized( boolean isInitialized)
241     {
242     initialized = isInitialized;
243     }
244 }
245
246
Popular Tags