KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > navmenu > UINavigationMenuItem


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.custom.navmenu;
17
18 import org.apache.myfaces.component.UserRoleUtils;
19 import org.apache.myfaces.component.UserRoleAware;
20
21 import javax.faces.component.UISelectItem;
22 import javax.faces.el.ValueBinding;
23 import javax.faces.context.FacesContext;
24
25 /**
26  * @author Thomas Spiegl (latest modification by $Author: matze $)
27  * @version $Revision: 1.3 $ $Date: 2004/10/13 11:50:57 $
28  * $Log: UINavigationMenuItem.java,v $
29  * Revision 1.3 2004/10/13 11:50:57 matze
30  * renamed packages to org.apache
31  *
32  * Revision 1.2 2004/07/01 21:53:07 mwessendorf
33  * ASF switch
34  *
35  * Revision 1.1 2004/06/23 13:44:31 royalts
36  * no message
37  *
38  */

39 public class UINavigationMenuItem
40     extends UISelectItem
41     implements UserRoleAware
42 {
43
44
45     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
46

47     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.NavigationMenuItem";
48     public static final String JavaDoc COMPONENT_FAMILY = "javax.faces.SelectItem";
49
50     private String JavaDoc _icon = null;
51     private Boolean JavaDoc _split = null;
52     private String JavaDoc _action = null;
53     private String JavaDoc _enabledOnUserRole = null;
54     private String JavaDoc _visibleOnUserRole = null;
55
56     public UINavigationMenuItem()
57     {
58     }
59
60     public String JavaDoc getFamily()
61     {
62         return COMPONENT_FAMILY;
63     }
64
65     public void setIcon(String JavaDoc icon)
66     {
67         _icon = icon;
68     }
69
70     public String JavaDoc getIcon()
71     {
72         if (_icon != null) return _icon;
73         ValueBinding vb = getValueBinding("icon");
74         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
75     }
76
77     public void setSplit(boolean split)
78     {
79         _split = Boolean.valueOf(split);
80     }
81
82     public boolean isSplit()
83     {
84         if (_split != null) return _split.booleanValue();
85         ValueBinding vb = getValueBinding("split");
86         Boolean JavaDoc v = vb != null ? (Boolean JavaDoc)vb.getValue(getFacesContext()) : null;
87         return v != null ? v.booleanValue() : false;
88     }
89
90     public void setAction(String JavaDoc action)
91     {
92         _action = action;
93     }
94
95     public String JavaDoc getAction()
96     {
97         if (_action != null) return _action;
98         ValueBinding vb = getValueBinding("action");
99         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
100     }
101
102     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole)
103     {
104         _enabledOnUserRole = enabledOnUserRole;
105     }
106
107     public String JavaDoc getEnabledOnUserRole()
108     {
109         if (_enabledOnUserRole != null) return _enabledOnUserRole;
110         ValueBinding vb = getValueBinding("enabledOnUserRole");
111         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
112     }
113
114     public void setVisibleOnUserRole(String JavaDoc visibleOnUserRole)
115     {
116         _visibleOnUserRole = visibleOnUserRole;
117     }
118
119     public String JavaDoc getVisibleOnUserRole()
120     {
121         if (_visibleOnUserRole != null) return _visibleOnUserRole;
122         ValueBinding vb = getValueBinding("visibleOnUserRole");
123         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
124     }
125
126
127     public boolean isRendered()
128     {
129         if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
130         return super.isRendered();
131     }
132
133     public Object JavaDoc saveState(FacesContext context)
134     {
135         Object JavaDoc values[] = new Object JavaDoc[6];
136         values[0] = super.saveState(context);
137         values[1] = _icon;
138         values[2] = _split;
139         values[3] = _action;
140         values[4] = _enabledOnUserRole;
141         values[5] = _visibleOnUserRole;
142         return ((Object JavaDoc) (values));
143     }
144
145     public void restoreState(FacesContext context, Object JavaDoc state)
146     {
147         Object JavaDoc values[] = (Object JavaDoc[])state;
148         super.restoreState(context, values[0]);
149         _icon = (String JavaDoc)values[1];
150         _split = (Boolean JavaDoc)values[2];
151         _action = (String JavaDoc)values[3];
152         _enabledOnUserRole = (String JavaDoc)values[4];
153         _visibleOnUserRole = (String JavaDoc)values[5];
154     }
155     //------------------ GENERATED CODE END ---------------------------------------
156
}
157
Popular Tags