KickJava   Java API By Example, From Geeks To Geeks.

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


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.7 $ $Date: 2005/01/16 20:09:53 $
28  * $Log: HtmlInputText.java,v $
29  * Revision 1.7 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.6 2005/01/13 09:24:53 matzew
33  * added patch form Sean Schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
34  *
35  * Revision 1.5 2005/01/10 08:08:14 matzew
36  * added patch form sean schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
37  *
38  * Revision 1.4 2004/10/13 11:50:56 matze
39  * renamed packages to org.apache
40  *
41  * Revision 1.3 2004/07/01 21:53:05 mwessendorf
42  * ASF switch
43  *
44  * Revision 1.2 2004/05/18 14:31:36 manolito
45  * user role support completely moved to components source tree
46  *
47  * Revision 1.1 2004/04/01 09:23:12 manolito
48  * more extended components
49  *
50  */

51 public class HtmlInputText
52         extends javax.faces.component.html.HtmlInputText
53         implements UserRoleAware
54 {
55         
56     public String JavaDoc getClientId(FacesContext context)
57     {
58         String JavaDoc clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
59         if (clientId == null)
60         {
61             clientId = super.getClientId(context);
62         }
63         
64         return clientId;
65     }
66     
67     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
68

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