001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.faces.taglib.html;
018:
019: import org.apache.cocoon.faces.FacesUtils;
020: import org.apache.cocoon.faces.taglib.UIComponentTag;
021: import org.apache.commons.lang.BooleanUtils;
022:
023: import javax.faces.FacesException;
024: import javax.faces.component.UIComponent;
025: import javax.faces.component.UIMessages;
026:
027: /**
028: * @version CVS $Id: MessagesTag.java 433543 2006-08-22 06:22:54Z crossley $
029: */
030: public class MessagesTag extends UIComponentTag {
031:
032: private String globalOnly;
033: private String showDetail;
034: private String showSummary;
035: private String errorClass;
036: private String errorStyle;
037: private String fatalClass;
038: private String fatalStyle;
039: private String infoClass;
040: private String infoStyle;
041: private String layout;
042: private String style;
043: private String styleClass;
044: private String title;
045: private String tooltip;
046: private String warnClass;
047: private String warnStyle;
048:
049: public void setGlobalOnly(String globalOnly) {
050: this .globalOnly = globalOnly;
051: }
052:
053: public void setShowDetail(String showDetail) {
054: this .showDetail = showDetail;
055: }
056:
057: public void setShowSummary(String showSummary) {
058: this .showSummary = showSummary;
059: }
060:
061: public void setErrorClass(String errorClass) {
062: this .errorClass = errorClass;
063: }
064:
065: public void setErrorStyle(String errorStyle) {
066: this .errorStyle = errorStyle;
067: }
068:
069: public void setFatalClass(String fatalClass) {
070: this .fatalClass = fatalClass;
071: }
072:
073: public void setFatalStyle(String fatalStyle) {
074: this .fatalStyle = fatalStyle;
075: }
076:
077: public void setInfoClass(String infoClass) {
078: this .infoClass = infoClass;
079: }
080:
081: public void setInfoStyle(String infoStyle) {
082: this .infoStyle = infoStyle;
083: }
084:
085: public void setLayout(String layout) {
086: this .layout = layout;
087: }
088:
089: public void setStyle(String style) {
090: this .style = style;
091: }
092:
093: public void setStyleClass(String styleClass) {
094: this .styleClass = styleClass;
095: }
096:
097: public void setTitle(String title) {
098: this .title = title;
099: }
100:
101: public void setTooltip(String tooltip) {
102: this .tooltip = tooltip;
103: }
104:
105: public void setWarnClass(String warnClass) {
106: this .warnClass = warnClass;
107: }
108:
109: public void setWarnStyle(String warnStyle) {
110: this .warnStyle = warnStyle;
111: }
112:
113: public String getRendererType() {
114: return "javax.faces.Messages";
115: }
116:
117: public String getComponentType() {
118: return "javax.faces.HtmlMessages";
119: }
120:
121: protected void setProperties(UIComponent component) {
122: super .setProperties(component);
123:
124: UIMessages messages = null;
125: try {
126: messages = (UIMessages) component;
127: } catch (ClassCastException cce) {
128: throw new FacesException("Tag <" + getClass().getName()
129: + "> expected UIMessages. " + "Got <"
130: + component.getClass().getName() + ">");
131: }
132:
133: if (globalOnly != null) {
134: if (FacesUtils.isExpression(globalOnly)) {
135: messages.setValueBinding("globalOnly",
136: createValueBinding(globalOnly));
137: } else {
138: messages.setGlobalOnly(BooleanUtils
139: .toBoolean(globalOnly));
140: }
141: }
142:
143: if (showDetail != null) {
144: if (FacesUtils.isExpression(showDetail)) {
145: messages.setValueBinding("showDetail",
146: createValueBinding(showDetail));
147: } else {
148: messages.setShowDetail(BooleanUtils
149: .toBoolean(showDetail));
150: }
151: }
152:
153: if (showSummary != null) {
154: if (FacesUtils.isExpression(showSummary)) {
155: messages.setValueBinding("showSummary",
156: createValueBinding(showSummary));
157: } else {
158: messages.setShowSummary(BooleanUtils
159: .toBoolean(showSummary));
160: }
161: }
162:
163: setProperty(component, "errorClass", errorClass);
164: setProperty(component, "errorStyle", errorStyle);
165: setProperty(component, "fatalClass", fatalClass);
166: setProperty(component, "fatalStyle", fatalStyle);
167: setProperty(component, "infoClass", infoClass);
168: setProperty(component, "infoStyle", infoStyle);
169: setProperty(component, "layout", layout);
170: setProperty(component, "style", style);
171: setProperty(component, "styleClass", styleClass);
172: setProperty(component, "title", title);
173:
174: setBooleanProperty(component, "tooltip", tooltip);
175:
176: setProperty(component, "warnClass", warnClass);
177: setProperty(component, "warnStyle", warnStyle);
178: }
179:
180: public void recycle() {
181: super.recycle();
182: globalOnly = null;
183: showDetail = null;
184: showSummary = null;
185: errorClass = null;
186: errorStyle = null;
187: fatalClass = null;
188: fatalStyle = null;
189: infoClass = null;
190: infoStyle = null;
191: layout = null;
192: style = null;
193: styleClass = null;
194: title = null;
195: tooltip = null;
196: warnClass = null;
197: warnStyle = null;
198: }
199: }
|