KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > filemgr > EAFileMgrChangeBean


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

5
6 package com.raptus.owxv3.modules.filemgr;
7
8 import javax.servlet.http.HttpServletRequest 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%">EAFileMgrChangeBean.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%">25th of September 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>
38  * This class is the form bean of the <code>EAFileMgrChangeAction</code> action.
39  *
40  * </td>
41  * </tr>
42  * </table>
43  * <hr>
44  *
45  */

46 public class EAFileMgrChangeBean extends OmniaWebBean
47 {
48     /**
49      *Represents the value of the radio button "existing category" or "new category"
50      */

51     protected int categorytype=FileMgrConstants.EXISTING_CATEGORY;
52
53     /**
54      *Represents the value of the allready existing category list
55      */

56     protected String JavaDoc catname="";
57
58     /**
59      *Represents the value of a new category name
60      */

61     protected String JavaDoc newcatname="";
62
63
64     /**
65      *Represents the value of the selected files' id
66      */

67     protected int filelist=-1; //0 can't be used because we have 0 at the firts element of the dropdown menu
68

69     /**
70      *this object will provide the list of existing categories
71      */

72     protected AllFileSelector fileSelector=null;
73
74
75     /**
76      *
77      *the number of files changed during a session
78      *
79      */

80     protected int changedFileCount=0;
81
82
83
84
85
86
87     /**
88      *Method for getting the categorytype: existing category or new category
89      */

90
91     public int getCategorytype() { return categorytype; }
92
93     /**
94      *Method for setting the categorytype: existing category or new category
95      */

96     public void setCategorytype(int c) { this.categorytype = c; }
97
98
99     /**
100      *Method for getting the selected category name from the category names list
101      */

102     public String JavaDoc getCatname() { return catname; }
103
104     /**
105      *Method for setting the selected category name from the category names list
106      */

107     public void setCatname(String JavaDoc name) { this.catname = name; }
108
109
110     /**
111      *Method for getting the new category name
112      */

113     public String JavaDoc getNewcatname() { return newcatname; }
114
115
116     /**
117      *Method for setting the new category name
118      */

119     public void setNewcatname(String JavaDoc name) { this.newcatname = name; }
120
121     /**
122      *Method for getting the FileSelector object
123      */

124     public AllFileSelector getFileSelector() { return fileSelector; }
125
126     /**
127      *Method for setting the FileSelector object, this should be called from the corresponding Action class
128      */

129     public void setFileSelector(AllFileSelector fs) { this.fileSelector=fs; }
130
131     /**
132      *Method for getting the selected file id from the file name list
133      */

134     public int getFilelist() { return filelist; }
135
136     /**
137      *Method for setting the selected file id from the file name list
138      */

139     public void setFilelist(int f) { this.filelist = f; }
140
141
142
143     /**
144      *the reset method
145      */

146     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request)
147     {
148         super.reset(mapping, request);
149         categorytype=FileMgrConstants.EXISTING_CATEGORY;
150         catname="";
151         newcatname="";
152         filelist=-1;
153
154     }
155
156     public void reset()
157     {
158         categorytype=FileMgrConstants.EXISTING_CATEGORY;
159         catname="";
160         newcatname="";
161         filelist=-1;
162     }
163
164
165      /**
166      *Convenince method for determening the the newcatname or catname should be used
167      */

168     public String JavaDoc getCategoryName()
169     {
170         if(categorytype==FileMgrConstants.EXISTING_CATEGORY && ! catname.equals("0") ) return catname;
171
172         if(categorytype==FileMgrConstants.NEW_CATEGORY && ! newcatname.equals("")) return newcatname;
173
174         if(catname.equals("0") && ! newcatname.equals("")) return newcatname;
175
176         if(!catname.equals("0") && newcatname.equals("")) return newcatname;
177
178         return catname;
179     }
180
181
182     /**
183      *The validate method is called when the form is getting submitted.
184      *We should check for 3 errors:
185      *<p>If the user didn't selected a category
186      *<p>If the user didn't entered a new category
187      *<p>If the user didn't selected a file from ther file list
188      */

189     public ActionErrors validate(HttpServletRequest JavaDoc request)
190     {
191       ActionErrors ret=new ActionErrors();
192       if(catname.equals("0") && newcatname.equals(""))
193       {
194           if( categorytype==FileMgrConstants.EXISTING_CATEGORY && catname.equals("0") )
195           {
196               ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.change.error.catnotselected"));
197
198           }
199           if(categorytype==FileMgrConstants.NEW_CATEGORY && newcatname.equals(""))
200           {
201               ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.change.error.emptynewcatname"));
202
203           }
204       }//end if
205

206       if(filelist==0){
207           ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.change.error.emptyfile"));
208       }
209
210
211       return ret;
212
213     }
214
215
216     public void incChangedFileCount(){
217         changedFileCount++;
218     }
219
220     public int getChangedFileCount(){
221         return changedFileCount;
222     }
223 }
224
225 // eof
226
Popular Tags