KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
27  * @author Thomas Spiegl (latest modification by $Author: matzew $)
28  * @author Manfred Geiler
29  * @version $Revision: 1.6 $ $Date: 2005/01/16 20:09:53 $
30  */

31 public class HtmlCommandLink
32         extends javax.faces.component.html.HtmlCommandLink
33         implements UserRoleAware
34 {
35         
36     public String JavaDoc getClientId(FacesContext context)
37     {
38         String JavaDoc clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
39         if (clientId == null)
40         {
41             clientId = super.getClientId(context);
42         }
43
44         return clientId;
45     }
46     
47     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
48

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