KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > website > formbeans > UserAdminForm


1
2 package org.roller.presentation.website.formbeans;
3
4 import java.util.Locale JavaDoc;
5
6 import org.apache.struts.action.ActionMapping;
7 import org.roller.RollerException;
8 import org.roller.pojos.UserData;
9 import org.roller.presentation.forms.UserForm;
10
11 import javax.servlet.http.HttpServletRequest JavaDoc;
12
13 /**
14  * These properties are not persistent and are only needed for the UI.
15  *
16  * @struts.form name="userAdminForm"
17  * @author dmj
18  */

19 public class UserAdminForm extends UserFormEx
20 {
21     private boolean mDelete = false;
22     private Boolean JavaDoc mUserEnabled = Boolean.FALSE;
23     private Boolean JavaDoc mUserAdmin = Boolean.FALSE;
24
25     public UserAdminForm()
26     {
27         super();
28     }
29
30     public UserAdminForm(UserData userData, java.util.Locale JavaDoc locale ) throws RollerException
31     {
32         super(userData, locale);
33     }
34
35     /**
36      * Returns true if delete requested.
37      * @return boolean
38     **/

39     public boolean getDelete()
40     {
41         return mDelete;
42     }
43
44     /**
45      * Sets the Delete member.
46      */

47     public void setDelete(boolean delete)
48     {
49         mDelete = delete;
50     }
51     
52     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request)
53     {
54         super.reset(mapping, request);
55         mDelete = false;
56     }
57
58     /**
59      * @return Returns the mEnabled.
60      */

61     public Boolean JavaDoc getUserEnabled()
62     {
63         return this.mUserEnabled;
64     }
65     
66     /**
67      * @param enabled The mEnabled to set.
68      */

69     public void setUserEnabled(Boolean JavaDoc enabled)
70     {
71         this.mUserEnabled = enabled;
72     }
73     
74     /**
75      * @return Returns the mUserAdmin.
76      */

77     public Boolean JavaDoc getUserAdmin() {
78         return mUserAdmin;
79     }
80     
81     /**
82      * @param userAdmin The mUserAdmin to set.
83      */

84     public void setUserAdmin(Boolean JavaDoc userAdmin) {
85         mUserAdmin = userAdmin;
86     }
87
88     /** Override to grant/revoke admin role depending on form */
89     public void copyTo(UserData user, Locale JavaDoc locale)
90             throws RollerException
91     {
92         super.copyTo(user, locale);
93         if (mUserAdmin.booleanValue())
94         {
95             user.grantRole("admin");
96         }
97         else
98         {
99             user.revokeRole("admin");
100         }
101     }
102
103     /** Override to set "administration" checkbox depending on user's roles */
104     public void copyFrom(UserData user, Locale JavaDoc locale)
105             throws RollerException
106     {
107         super.copyFrom(user, locale);
108         mUserAdmin = user.hasRole("admin") ? Boolean.TRUE : Boolean.FALSE;
109     }
110 }
111
Popular Tags