KickJava   Java API By Example, From Geeks To Geeks.

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


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.6 $ $Date: 2005/01/16 20:09:53 $
28  * $Log: HtmlPanelGroup.java,v $
29  * Revision 1.6 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.5 2004/10/13 11:50:57 matze
33  * renamed packages to org.apache
34  *
35  * Revision 1.4 2004/07/01 21:53:05 mwessendorf
36  * ASF switch
37  *
38  * Revision 1.3 2004/05/18 14:31:36 manolito
39  * user role support completely moved to components source tree
40  *
41  * Revision 1.2 2004/04/01 09:23:12 manolito
42  * more extended components
43  *
44  * Revision 1.1 2004/03/31 11:58:33 manolito
45  * custom component refactoring
46  *
47  */

48 public class HtmlPanelGroup
49         extends javax.faces.component.html.HtmlPanelGroup
50         implements UserRoleAware
51 {
52     public String JavaDoc getClientId(FacesContext context)
53     {
54         String JavaDoc clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
55         if (clientId == null)
56         {
57             clientId = super.getClientId(context);
58         }
59
60         return clientId;
61     }
62     
63     //private static final Log log = LogFactory.getLog(HtmlPanelGroup.class);
64

65     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
66

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