KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > component > html > ext > HtmlSelectOneMenu


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.component.html.ext;
17
18 import org.apache.myfaces.component.UserRoleAware;
19 import org.apache.myfaces.component.UserRoleUtils;
20 import org.apache.myfaces.component.html.util.HtmlComponentUtils;
21
22 import javax.faces.context.FacesContext;
23 import javax.faces.el.ValueBinding;
24
25 /**
26  * @author Manfred Geiler (latest modification by $Author: matzew $)
27  * @version $Revision: 1.5 $ $Date: 2005/01/16 20:09:53 $
28  * $Log: HtmlSelectOneMenu.java,v $
29  * Revision 1.5 2005/01/16 20:09:53 matzew
30  * added patch form Sean Schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
31  *
32  * Revision 1.4 2004/10/13 11:50:57 matze
33  * renamed packages to org.apache
34  *
35  * Revision 1.3 2004/07/01 21:53:05 mwessendorf
36  * ASF switch
37  *
38  * Revision 1.2 2004/05/18 14:31:36 manolito
39  * user role support completely moved to components source tree
40  *
41  * Revision 1.1 2004/04/01 09:23:12 manolito
42  * more extended components
43  *
44  */

45 public class HtmlSelectOneMenu
46         extends javax.faces.component.html.HtmlSelectOneMenu
47         implements UserRoleAware
48 {
49     public String JavaDoc getClientId(FacesContext context)
50     {
51         String JavaDoc clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
52         if (clientId == null)
53         {
54             clientId = super.getClientId(context);
55         }
56
57         return clientId;
58     }
59     
60     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
61

62     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.HtmlSelectOneMenu";
63
64     private String JavaDoc _enabledOnUserRole = null;
65     private String JavaDoc _visibleOnUserRole = null;
66
67     public HtmlSelectOneMenu()
68     {
69     }
70
71
72     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole)
73     {
74         _enabledOnUserRole = enabledOnUserRole;
75     }
76
77     public String JavaDoc getEnabledOnUserRole()
78     {
79         if (_enabledOnUserRole != null) return _enabledOnUserRole;
80         ValueBinding vb = getValueBinding("enabledOnUserRole");
81         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
82     }
83
84     public void setVisibleOnUserRole(String JavaDoc visibleOnUserRole)
85     {
86         _visibleOnUserRole = visibleOnUserRole;
87     }
88
89     public String JavaDoc getVisibleOnUserRole()
90     {
91         if (_visibleOnUserRole != null) return _visibleOnUserRole;
92         ValueBinding vb = getValueBinding("visibleOnUserRole");
93         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
94     }
95
96
97     public boolean isRendered()
98     {
99         if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
100         return super.isRendered();
101     }
102
103     public Object JavaDoc saveState(FacesContext context)
104     {
105         Object JavaDoc values[] = new Object JavaDoc[3];
106         values[0] = super.saveState(context);
107         values[1] = _enabledOnUserRole;
108         values[2] = _visibleOnUserRole;
109         return ((Object JavaDoc) (values));
110     }
111
112     public void restoreState(FacesContext context, Object JavaDoc state)
113     {
114         Object JavaDoc values[] = (Object JavaDoc[])state;
115         super.restoreState(context, values[0]);
116         _enabledOnUserRole = (String JavaDoc)values[1];
117         _visibleOnUserRole = (String JavaDoc)values[2];
118     }
119     //------------------ GENERATED CODE END ---------------------------------------
120
}
121
Popular Tags