KickJava   Java API By Example, From Geeks To Geeks.

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


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 Thomas Spiegl (latest modification by $Author: mmarinschek $)
27  * @author Manfred Geiler
28  * @version $Revision: 1.10 $ $Date: 2005/01/22 19:47:44 $
29  */

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

47     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.HtmlMessages";
48     private static final String JavaDoc DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Messages";
49
50     private String JavaDoc _summaryFormat = null;
51     private String JavaDoc _globalSummaryFormat = null;
52     private String JavaDoc _detailFormat = null;
53     private String JavaDoc _enabledOnUserRole = null;
54     private String JavaDoc _visibleOnUserRole = null;
55     private Boolean JavaDoc _replaceIdWithLabel = null;
56
57     public HtmlMessages()
58     {
59         setRendererType(DEFAULT_RENDERER_TYPE);
60     }
61
62
63     public void setSummaryFormat(String JavaDoc summaryFormat)
64     {
65         _summaryFormat = summaryFormat;
66     }
67
68     public String JavaDoc getSummaryFormat()
69     {
70         if (_summaryFormat != null) return _summaryFormat;
71         ValueBinding vb = getValueBinding("summaryFormat");
72         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
73     }
74
75     public void setGlobalSummaryFormat(String JavaDoc globalSummaryFormat)
76     {
77         _globalSummaryFormat = globalSummaryFormat;
78     }
79
80     public String JavaDoc getGlobalSummaryFormat()
81     {
82         if (_globalSummaryFormat != null) return _globalSummaryFormat;
83         ValueBinding vb = getValueBinding("globalSummaryFormat");
84         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
85     }
86
87     public void setDetailFormat(String JavaDoc detailFormat)
88     {
89         _detailFormat = detailFormat;
90     }
91
92     public String JavaDoc getDetailFormat()
93     {
94         if (_detailFormat != null) return _detailFormat;
95         ValueBinding vb = getValueBinding("detailFormat");
96         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
97     }
98
99     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole)
100     {
101         _enabledOnUserRole = enabledOnUserRole;
102     }
103
104     public String JavaDoc getEnabledOnUserRole()
105     {
106         if (_enabledOnUserRole != null) return _enabledOnUserRole;
107         ValueBinding vb = getValueBinding("enabledOnUserRole");
108         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
109     }
110
111     public void setVisibleOnUserRole(String JavaDoc visibleOnUserRole)
112     {
113         _visibleOnUserRole = visibleOnUserRole;
114     }
115
116     public String JavaDoc getVisibleOnUserRole()
117     {
118         if (_visibleOnUserRole != null) return _visibleOnUserRole;
119         ValueBinding vb = getValueBinding("visibleOnUserRole");
120         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
121     }
122
123     public void setReplaceIdWithLabel(boolean replaceIdWithLabel)
124     {
125         _replaceIdWithLabel = Boolean.valueOf(replaceIdWithLabel);
126     }
127
128     public boolean isReplaceIdWithLabel()
129     {
130         if (_replaceIdWithLabel != null) return _replaceIdWithLabel.booleanValue();
131         ValueBinding vb = getValueBinding("replaceIdWithLabel");
132         Boolean JavaDoc v = vb != null ? (Boolean JavaDoc)vb.getValue(getFacesContext()) : null;
133         return v != null ? v.booleanValue() : false;
134     }
135
136
137     public boolean isRendered()
138     {
139         if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
140         return super.isRendered();
141     }
142
143     public Object JavaDoc saveState(FacesContext context)
144     {
145         Object JavaDoc values[] = new Object JavaDoc[7];
146         values[0] = super.saveState(context);
147         values[1] = _summaryFormat;
148         values[2] = _globalSummaryFormat;
149         values[3] = _detailFormat;
150         values[4] = _enabledOnUserRole;
151         values[5] = _visibleOnUserRole;
152         values[6] = _replaceIdWithLabel;
153         return ((Object JavaDoc) (values));
154     }
155
156     public void restoreState(FacesContext context, Object JavaDoc state)
157     {
158         Object JavaDoc values[] = (Object JavaDoc[])state;
159         super.restoreState(context, values[0]);
160         _summaryFormat = (String JavaDoc)values[1];
161         _globalSummaryFormat = (String JavaDoc)values[2];
162         _detailFormat = (String JavaDoc)values[3];
163         _enabledOnUserRole = (String JavaDoc)values[4];
164         _visibleOnUserRole = (String JavaDoc)values[5];
165         _replaceIdWithLabel = (Boolean JavaDoc)values[6];
166     }
167     //------------------ GENERATED CODE END ---------------------------------------
168
}
169
Popular Tags