KickJava   Java API By Example, From Geeks To Geeks.

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


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: mmarinschek $)
27  * @version $Revision: 1.10 $ $Date: 2005/01/22 19:47:44 $
28  * $Log: HtmlMessage.java,v $
29  * Revision 1.10 2005/01/22 19:47:44 mmarinschek
30  * Message rendering updated - if a validation exception needs to be rendered, the id of the component is replaced with a label.
31  *
32  * Revision 1.9 2005/01/16 20:09:53 matzew
33  * added patch form Sean Schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
34  *
35  * Revision 1.8 2004/10/13 11:50:56 matze
36  * renamed packages to org.apache
37  *
38  * Revision 1.7 2004/07/01 21:53:05 mwessendorf
39  * ASF switch
40  *
41  * Revision 1.6 2004/05/18 14:31:36 manolito
42  * user role support completely moved to components source tree
43  *
44  * Revision 1.5 2004/04/01 09:23:12 manolito
45  * more extended components
46  *
47  * Revision 1.4 2004/03/31 14:51:45 manolito
48  * summaryFormat and detailFormat support
49  *
50  * Revision 1.3 2004/03/31 11:58:33 manolito
51  * custom component refactoring
52  *
53  * Revision 1.2 2004/03/30 17:47:32 manolito
54  * Message and Messages refactored
55  *
56  * Revision 1.1 2004/03/30 13:27:04 manolito
57  * extended Message component
58  *
59  */

60 public class HtmlMessage
61         extends javax.faces.component.html.HtmlMessage
62         implements UserRoleAware
63 {
64     public String JavaDoc getClientId(FacesContext context)
65     {
66         String JavaDoc clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
67         if (clientId == null)
68         {
69             clientId = super.getClientId(context);
70         }
71
72         return clientId;
73     }
74     
75     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
76

77     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.HtmlMessage";
78     private static final String JavaDoc DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Message";
79
80     private String JavaDoc _summaryFormat = null;
81     private String JavaDoc _detailFormat = null;
82     private String JavaDoc _enabledOnUserRole = null;
83     private String JavaDoc _visibleOnUserRole = null;
84     private Boolean JavaDoc _replaceIdWithLabel = null;
85
86     public HtmlMessage()
87     {
88         setRendererType(DEFAULT_RENDERER_TYPE);
89     }
90
91
92     public void setSummaryFormat(String JavaDoc summaryFormat)
93     {
94         _summaryFormat = summaryFormat;
95     }
96
97     public String JavaDoc getSummaryFormat()
98     {
99         if (_summaryFormat != null) return _summaryFormat;
100         ValueBinding vb = getValueBinding("summaryFormat");
101         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
102     }
103
104     public void setDetailFormat(String JavaDoc detailFormat)
105     {
106         _detailFormat = detailFormat;
107     }
108
109     public String JavaDoc getDetailFormat()
110     {
111         if (_detailFormat != null) return _detailFormat;
112         ValueBinding vb = getValueBinding("detailFormat");
113         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
114     }
115
116     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole)
117     {
118         _enabledOnUserRole = enabledOnUserRole;
119     }
120
121     public String JavaDoc getEnabledOnUserRole()
122     {
123         if (_enabledOnUserRole != null) return _enabledOnUserRole;
124         ValueBinding vb = getValueBinding("enabledOnUserRole");
125         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
126     }
127
128     public void setVisibleOnUserRole(String JavaDoc visibleOnUserRole)
129     {
130         _visibleOnUserRole = visibleOnUserRole;
131     }
132
133     public String JavaDoc getVisibleOnUserRole()
134     {
135         if (_visibleOnUserRole != null) return _visibleOnUserRole;
136         ValueBinding vb = getValueBinding("visibleOnUserRole");
137         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
138     }
139
140     public void setReplaceIdWithLabel(boolean replaceIdWithLabel)
141     {
142         _replaceIdWithLabel = Boolean.valueOf(replaceIdWithLabel);
143     }
144
145     public boolean isReplaceIdWithLabel()
146     {
147         if (_replaceIdWithLabel != null) return _replaceIdWithLabel.booleanValue();
148         ValueBinding vb = getValueBinding("replaceIdWithLabel");
149         Boolean JavaDoc v = vb != null ? (Boolean JavaDoc)vb.getValue(getFacesContext()) : null;
150         return v != null ? v.booleanValue() : false;
151     }
152
153
154     public boolean isRendered()
155     {
156         if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
157         return super.isRendered();
158     }
159
160     public Object JavaDoc saveState(FacesContext context)
161     {
162         Object JavaDoc values[] = new Object JavaDoc[6];
163         values[0] = super.saveState(context);
164         values[1] = _summaryFormat;
165         values[2] = _detailFormat;
166         values[3] = _enabledOnUserRole;
167         values[4] = _visibleOnUserRole;
168         values[5] = _replaceIdWithLabel;
169         return ((Object JavaDoc) (values));
170     }
171
172     public void restoreState(FacesContext context, Object JavaDoc state)
173     {
174         Object JavaDoc values[] = (Object JavaDoc[])state;
175         super.restoreState(context, values[0]);
176         _summaryFormat = (String JavaDoc)values[1];
177         _detailFormat = (String JavaDoc)values[2];
178         _enabledOnUserRole = (String JavaDoc)values[3];
179         _visibleOnUserRole = (String JavaDoc)values[4];
180         _replaceIdWithLabel = (Boolean JavaDoc)values[5];
181     }
182     //------------------ GENERATED CODE END ---------------------------------------
183
}
184
Popular Tags