KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > faces > taglib > html > MessageTag


1 /*
2  * Copyright 1999-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.cocoon.faces.taglib.html;
17
18 import org.apache.cocoon.faces.FacesUtils;
19 import org.apache.cocoon.faces.taglib.UIComponentTag;
20 import org.apache.commons.lang.BooleanUtils;
21
22 import javax.faces.FacesException;
23 import javax.faces.component.UIComponent;
24 import javax.faces.component.UIMessage;
25
26 /**
27  * @version CVS $Id: MessageTag.java 46253 2004-09-17 14:36:29Z vgritsenko $
28  */

29 public class MessageTag extends UIComponentTag {
30
31     private String JavaDoc _for;
32     private String JavaDoc showDetail;
33     private String JavaDoc showSummary;
34     private String JavaDoc errorClass;
35     private String JavaDoc errorStyle;
36     private String JavaDoc fatalClass;
37     private String JavaDoc fatalStyle;
38     private String JavaDoc infoClass;
39     private String JavaDoc infoStyle;
40     private String JavaDoc layout;
41     private String JavaDoc style;
42     private String JavaDoc styleClass;
43     private String JavaDoc title;
44     private String JavaDoc tooltip;
45     private String JavaDoc warnClass;
46     private String JavaDoc warnStyle;
47
48
49     public void setFor(String JavaDoc _for) {
50         this._for = _for;
51     }
52
53     public void setShowDetail(String JavaDoc showDetail) {
54         this.showDetail = showDetail;
55     }
56
57     public void setShowSummary(String JavaDoc showSummary) {
58         this.showSummary = showSummary;
59     }
60
61     public void setErrorClass(String JavaDoc errorClass) {
62         this.errorClass = errorClass;
63     }
64
65     public void setErrorStyle(String JavaDoc errorStyle) {
66         this.errorStyle = errorStyle;
67     }
68
69     public void setFatalClass(String JavaDoc fatalClass) {
70         this.fatalClass = fatalClass;
71     }
72
73     public void setFatalStyle(String JavaDoc fatalStyle) {
74         this.fatalStyle = fatalStyle;
75     }
76
77     public void setInfoClass(String JavaDoc infoClass) {
78         this.infoClass = infoClass;
79     }
80
81     public void setInfoStyle(String JavaDoc infoStyle) {
82         this.infoStyle = infoStyle;
83     }
84
85     public void setLayout(String JavaDoc layout) {
86         this.layout = layout;
87     }
88
89     public void setStyle(String JavaDoc style) {
90         this.style = style;
91     }
92
93     public void setStyleClass(String JavaDoc styleClass) {
94         this.styleClass = styleClass;
95     }
96
97     public void setTitle(String JavaDoc title) {
98         this.title = title;
99     }
100
101     public void setTooltip(String JavaDoc tooltip) {
102         this.tooltip = tooltip;
103     }
104
105     public void setWarnClass(String JavaDoc warnClass) {
106         this.warnClass = warnClass;
107     }
108
109     public void setWarnStyle(String JavaDoc warnStyle) {
110         this.warnStyle = warnStyle;
111     }
112
113
114     public String JavaDoc getRendererType() {
115         return "javax.faces.Message";
116     }
117
118     public String JavaDoc getComponentType() {
119         return "javax.faces.HtmlMessage";
120     }
121
122
123     protected void setProperties(UIComponent component) {
124         super.setProperties(component);
125
126         UIMessage message = null;
127         try {
128             message = (UIMessage) component;
129         } catch (ClassCastException JavaDoc cce) {
130             throw new FacesException("Tag <" + getClass().getName() + "> expected UIMessage. " +
131                                      "Got <" + component.getClass().getName() + ">");
132         }
133
134         if (_for != null) {
135             // FIXME Should it be "for"?
136
if (FacesUtils.isExpression(_for)) {
137                 message.setValueBinding("_for", createValueBinding(_for));
138             } else {
139                 message.setFor(_for);
140             }
141         }
142
143         if (showDetail != null) {
144             if (FacesUtils.isExpression(showDetail)) {
145                 message.setValueBinding("showDetail", createValueBinding(showDetail));
146             } else {
147                 message.setShowDetail(BooleanUtils.toBoolean(showDetail));
148             }
149         }
150
151         if (showSummary != null) {
152             if (FacesUtils.isExpression(showSummary)) {
153                 message.setValueBinding("showSummary", createValueBinding(showSummary));
154             } else {
155                 message.setShowSummary(BooleanUtils.toBoolean(showSummary));
156             }
157         }
158
159         setProperty(component, "errorClass", errorClass);
160         setProperty(component, "errorStyle", errorStyle);
161         setProperty(component, "fatalClass", fatalClass);
162         setProperty(component, "fatalStyle", fatalStyle);
163         setProperty(component, "infoClass", infoClass);
164         setProperty(component, "infoStyle", infoStyle);
165         setProperty(component, "layout", layout);
166         setProperty(component, "style", style);
167         setProperty(component, "styleClass", styleClass);
168         setProperty(component, "title", title);
169
170         setBooleanProperty(component, "tooltip", tooltip);
171
172         setProperty(component, "warnClass", warnClass);
173         setProperty(component, "warnStyle", warnStyle);
174     }
175
176     public void recycle() {
177         super.recycle();
178         _for = null;
179         showDetail = null;
180         showSummary = null;
181         errorClass = null;
182         errorStyle = null;
183         fatalClass = null;
184         fatalStyle = null;
185         infoClass = null;
186         infoStyle = null;
187         layout = null;
188         style = null;
189         styleClass = null;
190         title = null;
191         tooltip = null;
192         warnClass = null;
193         warnStyle = null;
194     }
195 }
196
Popular Tags