KickJava   Java API By Example, From Geeks To Geeks.

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


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.3 $ $Date: 2005/01/16 20:09:53 $
28  * $Log: HtmlInputTextarea.java,v $
29  * Revision 1.3 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.2 2004/10/13 11:50:56 matze
33  * renamed packages to org.apache
34  *
35  * Revision 1.1 2004/08/12 14:24:02 manolito
36  * Extended HtmlInputTextarea component
37  *
38  */

39 public class HtmlInputTextarea
40         extends javax.faces.component.html.HtmlInputTextarea
41         implements UserRoleAware
42 {
43         
44     public String JavaDoc getClientId(FacesContext context)
45     {
46         String JavaDoc clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
47         if (clientId == null)
48         {
49             clientId = super.getClientId(context);
50         }
51
52         return clientId;
53     }
54     
55     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
56

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