KickJava   Java API By Example, From Geeks To Geeks.

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


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.UserRoleAware;
19 import org.apache.myfaces.taglib.core.SelectItemTagBase;
20
21 import javax.faces.component.UIComponent;
22
23 /**
24  * @author Thomas Spiegl (latest modification by $Author: matzew $)
25  * @version $Revision: 1.5 $ $Date: 2005/02/18 17:19:31 $
26  * $Log: HtmlNavigationMenuItemTag.java,v $
27  * Revision 1.5 2005/02/18 17:19:31 matzew
28  * added release() to tag clazzes.
29  *
30  * Revision 1.4 2004/10/13 11:50:57 matze
31  * renamed packages to org.apache
32  *
33  * Revision 1.3 2004/07/05 08:28:24 royalts
34  * added example for <x:navigationMenuItems>
35  *
36  * Revision 1.2 2004/07/01 21:53:07 mwessendorf
37  * ASF switch
38  *
39  * Revision 1.1 2004/06/23 13:44:31 royalts
40  * no message
41  *
42  */

43 public class HtmlNavigationMenuItemTag
44     extends SelectItemTagBase
45 {
46
47     private static final String JavaDoc ICON_ATTR = "icon";
48     private static final String JavaDoc ACTION_ATTR = "action";
49     private static final String JavaDoc SPLIT_ATTR = "split";
50
51     private String JavaDoc _icon = null;
52     private String JavaDoc _action = null;
53     private String JavaDoc _split;
54
55     // User Role support
56
private String JavaDoc _enabledOnUserRole;
57     private String JavaDoc _visibleOnUserRole;
58     
59     public void release() {
60         super.release();
61
62         _icon = null;
63         _action = null;
64         _split= null;
65         _enabledOnUserRole= null;
66         _visibleOnUserRole= null;
67     }
68
69     public String JavaDoc getComponentType()
70     {
71         return UINavigationMenuItem.COMPONENT_TYPE;
72     }
73
74     public String JavaDoc getRendererType()
75     {
76         return null;
77     }
78
79     protected void setProperties(UIComponent component)
80     {
81         setItemValue("0"); // itemValue not used
82
super.setProperties(component);
83         setStringProperty(component, ICON_ATTR, _icon);
84         // set action attribute as String!
85
component.getAttributes().put(ACTION_ATTR, _action);
86         setBooleanProperty(component, SPLIT_ATTR, _split);
87
88         setStringProperty(component, UserRoleAware.ENABLED_ON_USER_ROLE_ATTR, _enabledOnUserRole);
89         setStringProperty(component, UserRoleAware.VISIBLE_ON_USER_ROLE_ATTR, _visibleOnUserRole);
90     }
91
92
93     public void setAction(String JavaDoc action)
94     {
95         _action = action;
96     }
97
98     public void setIcon(String JavaDoc icon)
99     {
100         _icon = icon;
101     }
102
103     public void setSplit(String JavaDoc split)
104     {
105         _split = split;
106     }
107
108     public void setVisibleOnUserRole(String JavaDoc visibleOnUserRole)
109     {
110         _visibleOnUserRole = visibleOnUserRole;
111     }
112
113     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole)
114     {
115         _enabledOnUserRole = enabledOnUserRole;
116     }
117 }
118
Popular Tags