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:
022: import javax.faces.FacesException;
023: import javax.faces.component.UIComponent;
024: import javax.faces.component.UIOutput;
025:
026: /**
027: * @version CVS $Id: OutputTextTag.java 433543 2006-08-22 06:22:54Z crossley $
028: */
029: public class OutputTextTag extends UIComponentTag {
030:
031: private String converter;
032: private String value;
033: private String escape;
034: private String style;
035: private String styleClass;
036: private String title;
037:
038: public void setConverter(String converter) {
039: this .converter = converter;
040: }
041:
042: public void setValue(String value) {
043: this .value = value;
044: }
045:
046: public void setEscape(String escape) {
047: this .escape = escape;
048: }
049:
050: public void setStyle(String style) {
051: this .style = style;
052: }
053:
054: public void setStyleClass(String styleClass) {
055: this .styleClass = styleClass;
056: }
057:
058: public void setTitle(String title) {
059: this .title = title;
060: }
061:
062: public String getRendererType() {
063: return "javax.faces.Text";
064: }
065:
066: public String getComponentType() {
067: return "javax.faces.HtmlOutputText";
068: }
069:
070: protected void setProperties(UIComponent component) {
071: super .setProperties(component);
072:
073: UIOutput output;
074: try {
075: output = (UIOutput) component;
076: } catch (ClassCastException cce) {
077: throw new FacesException("Tag <" + getClass().getName()
078: + "> expected UIOutput. " + "Got <"
079: + component.getClass().getName() + ">");
080: }
081:
082: if (converter != null) {
083: if (FacesUtils.isExpression(converter)) {
084: output.setValueBinding("converter",
085: createValueBinding(converter));
086: } else {
087: output.setConverter(getApplication().createConverter(
088: converter));
089: }
090: }
091:
092: if (value != null) {
093: if (FacesUtils.isExpression(value)) {
094: output.setValueBinding("value",
095: createValueBinding(value));
096: } else {
097: output.setValue(value);
098: }
099: }
100:
101: setBooleanProperty(component, "escape", escape);
102:
103: setProperty(component, "style", style);
104: setProperty(component, "styleClass", styleClass);
105: setProperty(component, "title", title);
106: }
107:
108: public void recycle() {
109: super.recycle();
110: converter = null;
111: value = null;
112: escape = null;
113: style = null;
114: styleClass = null;
115: title = null;
116: }
117: }
|