KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > web > forms > UserForm


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.web.forms;
20
21 import java.util.*;
22 import javax.servlet.http.*;
23 import org.apache.struts.action.*;
24 import org.apache.struts.validator.*;
25
26 import cowsultants.itracker.ejb.client.models.*;
27 import cowsultants.itracker.ejb.client.util.*;
28 import cowsultants.itracker.web.util.*;
29
30 public class UserForm extends ValidatorForm {
31     private String JavaDoc action = null;
32     private Integer JavaDoc id = new Integer JavaDoc(-1);
33     private String JavaDoc login = null;
34     private String JavaDoc currPassword = null;
35     private String JavaDoc password = null;
36     private String JavaDoc confPassword = null;
37     private String JavaDoc firstName = null;
38     private String JavaDoc lastName = null;
39     private String JavaDoc email = null;
40
41     private boolean superUser = false;
42
43     private HashMap permissions = new HashMap();
44
45     private String JavaDoc userLocale = null;
46     private String JavaDoc saveLogin = null;
47     private String JavaDoc numItemsOnIndex = null;
48     private String JavaDoc numItemsOnIssueList = null;
49     private String JavaDoc showClosedOnIssueList = null;
50     private String JavaDoc sortColumnOnIssueList = null;
51     private Integer JavaDoc[] hiddenIndexSections = null;
52     private String JavaDoc rememberLastSearch = null;
53
54     public String JavaDoc getAction() {
55         return action;
56     }
57
58     public void setAction(String JavaDoc value) {
59         action = value;
60     }
61
62     public Integer JavaDoc getId() {
63         return id;
64     }
65
66     public void setId(Integer JavaDoc value) {
67         id = value;
68     }
69
70     public String JavaDoc getLogin() {
71         return login;
72     }
73
74     public void setLogin(String JavaDoc value) {
75         login = value;
76     }
77
78     public String JavaDoc getCurrPassword() {
79         return currPassword;
80     }
81
82     public void setCurrPassword(String JavaDoc value) {
83         currPassword = value;
84     }
85
86       public String JavaDoc getPassword() {
87         return password;
88     }
89
90     public void setPassword(String JavaDoc value) {
91         password = value;
92     }
93
94     public String JavaDoc getConfPassword() {
95         return confPassword;
96     }
97
98     public void setConfPassword(String JavaDoc value) {
99         confPassword = value;
100     }
101
102     public String JavaDoc getFirstName() {
103         return firstName;
104     }
105
106     public void setFirstName(String JavaDoc value) {
107         firstName = value;
108     }
109
110     public String JavaDoc getLastName() {
111         return lastName;
112     }
113
114     public void setLastName(String JavaDoc value) {
115         lastName = value;
116     }
117
118     public String JavaDoc getEmail() {
119         return email;
120     }
121
122     public void setEmail(String JavaDoc value) {
123         email = value;
124     }
125
126     public boolean isSuperUser() {
127         return superUser;
128     }
129
130     public void setSuperUser(boolean value) {
131         superUser = value;
132     }
133
134     public HashMap getPermissions() {
135         return permissions;
136     }
137
138     public void setPermissions(HashMap value) {
139         permissions = value;
140     }
141
142     public String JavaDoc getUserLocale() {
143         return userLocale;
144     }
145
146     public void setUserLocale(String JavaDoc value) {
147         userLocale = value;
148     }
149
150     public String JavaDoc getSaveLogin() {
151         return saveLogin;
152     }
153
154     public void setSaveLogin(String JavaDoc value) {
155         saveLogin = value;
156     }
157
158     public String JavaDoc getNumItemsOnIndex() {
159         return numItemsOnIndex;
160     }
161
162     public void setNumItemsOnIndex(String JavaDoc value) {
163         numItemsOnIndex = value;
164     }
165
166     public String JavaDoc getNumItemsOnIssueList() {
167         return numItemsOnIssueList;
168     }
169
170     public void setNumItemsOnIssueList(String JavaDoc value) {
171         numItemsOnIssueList = value;
172     }
173
174     public String JavaDoc getShowClosedOnIssueList() {
175         return showClosedOnIssueList;
176     }
177
178     public void setShowClosedOnIssueList(String JavaDoc value) {
179         showClosedOnIssueList = value;
180     }
181
182     public String JavaDoc getSortColumnOnIssueList() {
183         return sortColumnOnIssueList;
184     }
185
186     public void setSortColumnOnIssueList(String JavaDoc value) {
187         sortColumnOnIssueList = value;
188     }
189
190     public Integer JavaDoc[] getHiddenIndexSections() {
191         return hiddenIndexSections;
192     }
193
194     public void setHiddenIndexSections(Integer JavaDoc[] value) {
195         hiddenIndexSections = value;
196     }
197
198     public String JavaDoc getRememberLastSearch() {
199         return rememberLastSearch;
200     }
201
202     public void setRememberLastSearch(String JavaDoc value) {
203         rememberLastSearch = value;
204     }
205
206     public void reset(ActionMapping mapping, HttpServletRequest request) {
207         action = null;
208         id = new Integer JavaDoc(-1);
209         login = null;
210         currPassword = null;
211         password = null;
212         confPassword = null;
213         firstName = null;
214         lastName = null;
215         email = null;
216         superUser = false;
217
218         permissions = new HashMap();
219
220         userLocale = null;
221         saveLogin = null;
222         numItemsOnIndex = null;
223         numItemsOnIssueList = null;
224         showClosedOnIssueList = null;
225         sortColumnOnIssueList = null;
226         hiddenIndexSections = null;
227         rememberLastSearch = null;
228     }
229
230     public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
231         ActionErrors errors = super.validate(mapping, request);
232
233         if(password != null && ! "".equals(password)) {
234             if(! ("register".equalsIgnoreCase(action) || "create".equalsIgnoreCase(action) || "update".equalsIgnoreCase(action)) &&
235               (currPassword == null || "".equals(currPassword))) {
236                 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.missingpassword"));
237             } else if(! password.equals(confPassword)) {
238                 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.matchingpass"));
239             }
240         }
241         return errors;
242     }
243
244
245 }
246
Popular Tags