KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > usermgr > EAUserMgrEditRoleBean


1 /*
2  * EAUserMgrEditBean.java
3  *
4  * Created on May 28, 2003, 11:44 AM
5  */

6
7 package com.raptus.owxv3.modules.usermgr;
8
9
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11
12 import org.apache.struts.action.*;
13
14 import com.raptus.owxv3.api.OmniaWebBean;
15
16
17 /**
18  * bean used to store data on the add user/edit user form
19  * @author root
20  */

21 public class EAUserMgrEditRoleBean extends OmniaWebBean
22 {
23     /**
24      * The role's name
25      */

26     protected String JavaDoc name = null;
27     
28     /**
29      * The role's description
30      */

31     protected String JavaDoc description = null;
32     
33     /**
34      * is this a new role?
35      */

36     protected boolean newrole = false;
37     
38     /**
39      * Creates a new instance of EAUserMgrEditRoleBean
40      */

41     public EAUserMgrEditRoleBean()
42     {
43         this.newrole = false;
44     }
45     
46     
47     /**
48      * return true if the data stored for this role is a new role
49      *
50      * @return true if data stored is for a new role, not an existing one
51      */

52     public boolean isNewRole()
53     {
54         return newrole;
55     }
56     
57     public String JavaDoc getNewRole()
58     {
59         return ""+newrole;
60     }
61     
62     public void setNewRole(boolean newrole)
63     {
64         this.newrole = newrole;
65     }
66     
67     public void setNewRole(String JavaDoc newrole)
68     {
69         this.newrole = Boolean.valueOf(newrole).booleanValue();
70     }
71     
72     /**
73      * Set the description for this role
74      *
75      * @param description the description of the new role
76      */

77     public void setDescription(String JavaDoc description)
78     {
79         this.description = description;
80     }
81     
82     /**
83      * return the description for this role
84      *
85      * @return the description for this role
86      */

87     public String JavaDoc getDescription() { return description; }
88     
89     /**
90      * return the dsplay name for this user
91      *
92      * @return the display name for this user
93      */

94     public String JavaDoc getName() { return name; }
95     
96     /**
97      * set the display name for this user
98      *
99      * @param name the display name for this user
100      */

101     public void setName(String JavaDoc name) { this.name = name; }
102     
103     /**
104      * Validate the form.
105      *
106      * @param request the http request
107      *
108      * @return Action errors on error
109      */

110     public ActionErrors validate(HttpServletRequest JavaDoc request)
111     {
112       ActionErrors ret=new ActionErrors();
113
114       // validate user name
115
if(name==null||name.length()<1)
116       {
117           ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.usermgr.error.NoRoleName"));
118       }
119
120       // validate login name
121
if(description==null||description.length()<1)
122       {
123           ret.add(ActionErrors.GLOBAL_ERROR,new ActionError("module.usermgr.error.NoDescriptionName"));
124       }
125
126       return ret;
127     }
128     
129     /**
130      * reset the state of the bean to initial state (no data)
131      */

132     public void reset()
133     {
134         this.name = null;
135         this.description = null;
136     }
137 }
138
Popular Tags