KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > categories > EACategoryEditBean


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.modules.categories;
7
8 import java.util.Locale JavaDoc;
9
10 import org.apache.struts.action.*;
11
12 import com.raptus.owxv3.api.*;
13
14 /**
15  *
16  * <hr>
17  * <table width="100%" border="0">
18  * <tr>
19  * <td width="24%"><b>Filename</b></td><td width="76%">EACategoryEditBean.java</td>
20  * </tr>
21  * <tr>
22  * <td width="24%"><b>Author</b></td><td width="76%">REEA</td>
23  * </tr>
24  * <tr>
25  * <td width="24%"><b>Date</b></td><td width="76%">10th of December 2001</td>
26  * </tr>
27  * </table>
28  * <hr>
29  * <table width="100%" border="0">
30  * <tr>
31  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
32  * </tr>
33  * </table>
34  * <hr>
35  * <table width="100%" border="0">
36  * <tr>
37  * <td>This class is the form bean of the <code>EACategoryEditAction</code> action.</td>
38  * </tr>
39  * </table>
40  * <hr>
41  *
42  */

43 public class EACategoryEditBean extends OmniaWebBean
44 {
45
46     /**
47      *value the parent category select box
48      */

49     protected int parentCategory=0;
50
51     /**
52      *The identifier name of category
53      */

54     protected String JavaDoc catId=null;
55
56     /**
57      *The database id of this category
58      */

59     protected int row_id=0;
60
61     /**
62      *The value of the owner select box
63      */

64     protected String JavaDoc owner=null;
65
66     /**
67      *The list of vmodules used to fill the owner select box
68      */

69     protected String JavaDoc[] vmodules=null;
70
71
72     /**
73      *The name of this category, order is assured by the locales array
74      */

75     protected String JavaDoc[] name=null;
76
77
78     /**
79      *Locales that are displayed before a name textfield
80      */

81     protected Locale JavaDoc[] locales=null;
82
83     /**
84      *The current locale of the logged user
85      */

86     protected Locale JavaDoc currLocale;
87
88     /**
89      *Integer used getCatName() method
90      */

91     protected int name_index=0;
92
93
94     /**
95      *A category selector used to prefill the parent select box
96      */

97     protected CategorySelector categorySelector=null;
98
99     /**
100      *Getter method of parentCategory
101      */

102     public int getParentCategory()
103     {
104         return parentCategory;
105     }
106
107     /**
108      *Setter method of parentCategory
109      */

110     public void setParentCategory(int cat)
111     {
112         parentCategory=cat;
113     }
114
115     /**
116      *Getter method of owner
117      */

118     public String JavaDoc getOwner()
119     {
120         return owner;
121     }
122
123     /**
124      *Setter method of owner
125      */

126     public void setOwner(String JavaDoc o)
127     {
128         owner=o;
129     }
130
131     /**
132      *Getter method of name
133      */

134     public String JavaDoc[] getName()
135     {
136         return name;
137     }
138
139
140
141     /**
142      *Getter method of name, this will be used actually to fill
143      *the name textfields
144      */

145     public String JavaDoc getCatName()
146     {
147         if(name==null) return "";
148         if(name_index>=name.length) name_index=0;
149
150         String JavaDoc s=name[name_index];
151         name_index++;
152         return s;
153
154     }
155
156
157     /**
158      *Setter method of name
159      */

160     public void setName(String JavaDoc n[])
161     {
162         name=n;
163         name_index=0;
164     }
165
166
167     /**
168      *Setter method of vmodules
169      */

170     public void setVmodules(String JavaDoc v[])
171     {
172         vmodules=v;
173     }
174
175     /**
176      *Getter method of vmodules
177      */

178     public String JavaDoc[] getVmodules()
179     {
180        return vmodules;
181     }
182
183     /**
184      *Setter method of locales
185      */

186     public void setLocales(Locale JavaDoc l[])
187     {
188         locales=l;
189     }
190
191     /**
192      *Getter method of locales
193      */

194     public Locale JavaDoc[] getLocales()
195     {
196        return locales;
197     }
198
199
200     /**
201      *Setter method of current locale
202      */

203     public void setCurrLocale(Locale JavaDoc l)
204     {
205         currLocale=l;
206     }
207
208     /**
209      *Getter method of current locale
210      */

211     public Locale JavaDoc getCurrLocale()
212     {
213         return currLocale;
214     }
215
216     /**
217      *Method to decide that this bean has all the necessary data initialized
218      * @return true if the bean is properly initialized
219      * else returns false
220      */

221     public boolean isInitialized()
222     {
223         return (locales!=null && currLocale!=null && vmodules!=null && categorySelector!=null);
224     }
225
226
227     /**
228      *Getter method of category identifier
229      */

230     public String JavaDoc getCatId()
231     {
232         return catId;
233     }
234
235
236     /**
237      *Setter method of category identifier
238      */

239     public void setCatId(String JavaDoc id)
240     {
241         catId=id;
242     }
243
244     /**
245      *Getter method of row id
246      */

247     public int getRowId()
248     {
249         return row_id;
250     }
251
252     /**
253      *Setter method of row id
254      */

255
256     public void setRowId(int id)
257     {
258         row_id=id;
259     }
260
261
262     /**
263      *Setter method of Category Selector
264      */

265     public void setCategorySelector(CategorySelector catsel)
266     {
267         categorySelector=catsel;
268     }
269
270     /**
271      *Getter method of Category Selector
272      */

273     public CategorySelector getCategorySelector()
274     {
275         return categorySelector;
276     }
277
278
279
280     /**
281      *Method that will reset the beans form field values to default
282      */

283     public void reset()
284     {
285         parentCategory=0;
286         catId=null;
287         row_id=0;
288         owner=null;
289         name=null;
290     }
291
292
293     /**
294      *Method for validating save
295      */

296     public ActionErrors validateSave()
297     {
298         ActionErrors ret=new ActionErrors();
299
300         if(owner==null) ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.categories.error.noowner"));
301         if(name==null) ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.categories.error.catname"));
302         else
303             if(locales!=null)
304             {
305                 if(locales.length!=name.length) ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.categories.error.catname"));
306                 else
307                 {
308                     for(int i=0;i<name.length;i++)
309                         if(name[i]==null || name[i].equals(""))
310                         {
311                             ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.categories.error.catname"));
312                             break;
313                         }
314                 }//end else
315
}//end if
316

317        return ret;
318     }
319
320
321 }
322
323 // eof
324
Popular Tags