KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > usermanager > struts > UserManagerForm


1 package com.dotmarketing.portlets.usermanager.struts;
2
3 import java.util.List JavaDoc;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6
7 import org.apache.struts.action.ActionErrors;
8 import org.apache.struts.action.ActionForm;
9 import org.apache.struts.action.ActionMapping;
10 import org.apache.struts.action.ActionMessage;
11
12 import com.dotmarketing.portlets.organization.model.Organization;
13 import com.dotmarketing.util.UtilMethods;
14
15 /**
16  *
17  * @author Oswaldo Gallango
18  *
19  */

20 public class UserManagerForm extends ActionForm {
21     
22     
23
24     private static final long serialVersionUID = 1L;
25     
26     //Liferay User fields
27
private String JavaDoc userID;
28     private String JavaDoc emailAddress;
29     private String JavaDoc password;
30     private String JavaDoc passChanged;
31     private String JavaDoc newPassword;
32     private String JavaDoc verifyPassword;
33     private String JavaDoc firstName;
34     private String JavaDoc lastName;
35     
36
37     //Address fields
38
private String JavaDoc description;
39     private String JavaDoc addressID;
40     private String JavaDoc typeAddress;
41     private String JavaDoc street1;
42     private String JavaDoc street2;
43     private String JavaDoc city;
44     private String JavaDoc state;
45     private String JavaDoc zip;
46     private String JavaDoc phone;
47     private String JavaDoc fax;
48     
49     private String JavaDoc school;
50     private int graduation_year;
51     private String JavaDoc country;
52     
53     //UserProxy
54
private long userProxyInode;
55     private String JavaDoc referrer;
56     private String JavaDoc longLivedCookie;
57     private String JavaDoc website;
58     private String JavaDoc company;
59     private String JavaDoc howHeard;
60     private String JavaDoc prefix;
61     private String JavaDoc otherPrefix;
62     private String JavaDoc suffix;
63     private String JavaDoc title;
64     //Categories
65
private String JavaDoc[] category;
66     
67     
68     public String JavaDoc getCompany() {
69         return company;
70     }
71
72     public void setCompany(String JavaDoc company) {
73         this.company = company;
74     }
75
76     public String JavaDoc getHowHeard() {
77         return howHeard;
78     }
79
80     public void setHowHeard(String JavaDoc howHeard) {
81         this.howHeard = howHeard;
82     }
83
84     public String JavaDoc getLongLivedCookie() {
85         return longLivedCookie;
86     }
87
88     public void setLongLivedCookie(String JavaDoc longLivedCookie) {
89         this.longLivedCookie = longLivedCookie;
90     }
91
92     public String JavaDoc getWebsite() {
93         return website;
94     }
95
96     public void setWebsite(String JavaDoc website) {
97         this.website = website;
98     }
99
100     public UserManagerForm() {
101         this.city = "";
102         this.description = "";
103         this.emailAddress = "";
104         this.fax = "";
105         this.firstName = "";
106         this.lastName = "";
107         this.passChanged = "false";
108         this.otherPrefix = "";
109         this.password = "";
110         this.phone = "";
111         this.prefix = "";
112         this.state = "";
113         this.street1 = "";
114         this.street2 = "";
115         this.suffix = "";
116         this.title = "";
117         this.typeAddress = "";
118         this.verifyPassword = "";
119         this.zip = "";
120         this.school="";
121     }
122
123     @Override JavaDoc
124     public ActionErrors validate(ActionMapping arg0, HttpServletRequest JavaDoc arg1) {
125         ActionErrors errors = new ActionErrors ();
126         
127         if (!UtilMethods.isSet(firstName))
128             errors.add("firstName", new ActionMessage ("error.usermanager.form.mandatory", "First Name"));
129         if (!UtilMethods.isSet(lastName))
130             errors.add("lastName", new ActionMessage ("error.usermanager.form.mandatory", "Last Name"));
131         if (!UtilMethods.isSet(emailAddress))
132             errors.add("emailAddress", new ActionMessage ("error.usermanager.form.mandatory", "Email Address"));
133         if (!emailAddress.matches("[^@]+@[^@]+"))
134             errors.add("emailAddress", new ActionMessage ("error.usermanager.form.format", "Email Address"));
135         if (!UtilMethods.isSet(password))
136             errors.add("password", new ActionMessage ("error.usermanager.form.mandatory", "Password"));
137         if (!UtilMethods.isSet(verifyPassword))
138             errors.add("verifyPassword", new ActionMessage ("error.usermanager.form.mandatory", "verifyPassword"));
139         if (passChanged.equals("true")) {
140             if (UtilMethods.isSet(password) && !password.equals(verifyPassword)) {
141                 errors.add("newPassword", new ActionMessage ("error.usermanager.form.verifyPassword"));
142             }
143         }
144         if (!UtilMethods.isSet(street1))
145             errors.add("street1", new ActionMessage ("error.usermanager.form.mandatory", "Street 1"));
146         if (!UtilMethods.isSet(city))
147             errors.add("city", new ActionMessage ("error.usermanager.form.mandatory", "City"));
148         if (!UtilMethods.isSet(state))
149             errors.add("street1", new ActionMessage ("error.usermanager.form.mandatory", "State"));
150         if (!UtilMethods.isSet(zip))
151             errors.add("zip", new ActionMessage ("error.usermanager.form.mandatory", "Zip"));
152         if (!UtilMethods.isSet(phone))
153             errors.add("phone", new ActionMessage ("error.usermanager.form.mandatory", "Phone"));
154         if (!UtilMethods.isSet(country))
155             errors.add("country", new ActionMessage ("error.usermanager.form.mandatory", "Country"));
156
157         return errors;
158     }
159     
160     public String JavaDoc getCity() {
161         return city;
162     }
163     public void setCity(String JavaDoc city) {
164         this.city = city;
165     }
166     public String JavaDoc getEmailAddress() {
167         return emailAddress;
168     }
169     public void setEmailAddress(String JavaDoc emailAddress) {
170         this.emailAddress = emailAddress;
171     }
172     public String JavaDoc getFax() {
173         return fax;
174     }
175     public void setFax(String JavaDoc fax) {
176         if (fax!=null && !fax.equals("null"))
177             this.fax = fax;
178     }
179     public String JavaDoc getFirstName() {
180         return firstName;
181     }
182     public void setFirstName(String JavaDoc firstName) {
183         this.firstName = firstName;
184     }
185     public String JavaDoc getLastName() {
186         return lastName;
187     }
188     public void setLastName(String JavaDoc lastName) {
189         this.lastName = lastName;
190     }
191     public String JavaDoc getPassword() {
192         return password;
193     }
194     public void setPassword(String JavaDoc password) {
195         this.password = password;
196     }
197     public String JavaDoc getVerifyPassword() {
198         return verifyPassword;
199     }
200     public void setVerifyPassword(String JavaDoc verifyPassword) {
201         this.verifyPassword = verifyPassword;
202     }
203     public String JavaDoc getPhone() {
204         return phone;
205     }
206     public void setPhone(String JavaDoc phone) {
207         if (phone!=null && !phone.equals("null"))
208             this.phone = phone;
209     }
210     public String JavaDoc getPrefix() {
211         return prefix;
212     }
213     public void setPrefix(String JavaDoc prefix) {
214         if (prefix!=null && !prefix.equals("null"))
215             this.prefix = prefix;
216     }
217     public String JavaDoc getState() {
218         return state;
219     }
220     public void setState(String JavaDoc state) {
221         this.state = state;
222     }
223     public String JavaDoc getStreet1() {
224         return street1;
225     }
226     public void setStreet1(String JavaDoc street1) {
227         this.street1 = street1;
228     }
229     public String JavaDoc getStreet2() {
230         return street2;
231     }
232     public void setStreet2(String JavaDoc street2) {
233         this.street2 = street2;
234     }
235     public String JavaDoc getSuffix() {
236         return suffix;
237     }
238     public void setSuffix(String JavaDoc suffix) {
239         if (suffix!=null && !suffix.equals("null"))
240             this.suffix = suffix;
241     }
242     public String JavaDoc getTitle() {
243         return title;
244     }
245     public void setTitle(String JavaDoc title) {
246         if (title!=null && !title.equals("null"))
247             this.title = title;
248     }
249     public String JavaDoc getTypeAddress() {
250         return typeAddress;
251     }
252     public void setTypeAddress(String JavaDoc typeAddress) {
253         this.typeAddress = typeAddress;
254     }
255     public String JavaDoc getZip() {
256         return zip;
257     }
258     public void setZip(String JavaDoc zip) {
259         this.zip = zip;
260     }
261     public String JavaDoc[] getCategory() {
262         return category;
263     }
264     public void setCategory(String JavaDoc[] category) {
265         this.category = category;
266     }
267     public String JavaDoc getAddressID() {
268         return addressID;
269     }
270     public void setAddressIS(String JavaDoc addressID) {
271         this.addressID = addressID;
272     }
273
274     public String JavaDoc getUserID() {
275         return userID;
276     }
277     public void setUserID(String JavaDoc userID) {
278         this.userID = userID;
279     }
280     public long getUserProxyInode() {
281         return userProxyInode;
282     }
283     public void setUserProxyInode(long userProxyInode) {
284         this.userProxyInode = userProxyInode;
285     }
286     public void setAddressID(String JavaDoc addressID) {
287         this.addressID = addressID;
288     }
289     public String JavaDoc getDescription() {
290         return description;
291     }
292     public void setDescription(String JavaDoc description) {
293         this.description = description;
294     }
295     
296     public String JavaDoc getReferrer() {
297         return referrer;
298     }
299     public void setReferrer(String JavaDoc referrer) {
300         this.referrer = referrer;
301     }
302     public String JavaDoc getPassChanged() {
303         return passChanged;
304     }
305     public void setPassChanged(String JavaDoc newValue) {
306         this.passChanged = newValue;
307     }
308     public String JavaDoc getOtherPrefix() {
309         return otherPrefix;
310     }
311     public void setOtherPrefix(String JavaDoc otherPrefix) {
312         this.otherPrefix = otherPrefix;
313     }
314
315     public String JavaDoc getNewPassword() {
316         return newPassword;
317     }
318
319     public void setNewPassword(String JavaDoc newPassword) {
320         this.newPassword = newPassword;
321     }
322     
323     public boolean isCategorySelected(String JavaDoc strCategory){
324         if(this.category != null){
325             for(int i = 0; i < this.category.length;++i){
326                 if(this.category[i].equals(strCategory))
327                     return true;
328             }
329         }
330         return false;
331     }
332
333     public int getGraduation_year() {
334         return graduation_year;
335     }
336
337     public void setGraduation_year(int graduation_year) {
338         this.graduation_year = graduation_year;
339     }
340
341     public String JavaDoc getSchool() {
342         return school;
343     }
344
345     public void setSchool(String JavaDoc school) {
346         this.school = school;
347     }
348
349     public String JavaDoc getCountry() {
350         return country;
351     }
352
353     public void setCountry(String JavaDoc country) {
354         this.country = country;
355     }
356     
357 }
358
359
360
Popular Tags