KickJava   Java API By Example, From Geeks To Geeks.

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


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
21 import javax.faces.FacesException;
22 import javax.faces.component.UIComponent;
23 import javax.faces.component.UIOutput;
24
25 /**
26  * @version CVS $Id: OutputTextTag.java 46253 2004-09-17 14:36:29Z vgritsenko $
27  */

28 public class OutputTextTag extends UIComponentTag {
29
30     private String JavaDoc converter;
31     private String JavaDoc value;
32     private String JavaDoc escape;
33     private String JavaDoc style;
34     private String JavaDoc styleClass;
35     private String JavaDoc title;
36
37
38     public void setConverter(String JavaDoc converter) {
39         this.converter = converter;
40     }
41
42     public void setValue(String JavaDoc value) {
43         this.value = value;
44     }
45
46     public void setEscape(String JavaDoc escape) {
47         this.escape = escape;
48     }
49
50     public void setStyle(String JavaDoc style) {
51         this.style = style;
52     }
53
54     public void setStyleClass(String JavaDoc styleClass) {
55         this.styleClass = styleClass;
56     }
57
58     public void setTitle(String JavaDoc title) {
59         this.title = title;
60     }
61
62     public String JavaDoc getRendererType() {
63         return "javax.faces.Text";
64     }
65
66     public String JavaDoc getComponentType() {
67         return "javax.faces.HtmlOutputText";
68     }
69
70     protected void setProperties(UIComponent component) {
71         super.setProperties(component);
72
73         UIOutput output;
74         try {
75             output = (UIOutput) component;
76         } catch (ClassCastException JavaDoc cce) {
77             throw new FacesException("Tag <" + getClass().getName() + "> expected UIOutput. " +
78                                      "Got <" + component.getClass().getName() + ">");
79         }
80
81         if (converter != null) {
82             if (FacesUtils.isExpression(converter)) {
83                 output.setValueBinding("converter", createValueBinding(converter));
84             } else {
85                 output.setConverter(getApplication().createConverter(converter));
86             }
87         }
88
89         if (value != null) {
90             if (FacesUtils.isExpression(value)) {
91                 output.setValueBinding("value", createValueBinding(value));
92             } else {
93                 output.setValue(value);
94             }
95         }
96
97         setBooleanProperty(component, "escape", escape);
98
99         setProperty(component, "style", style);
100         setProperty(component, "styleClass", styleClass);
101         setProperty(component, "title", title);
102     }
103
104     public void recycle() {
105         super.recycle();
106         converter = null;
107         value = null;
108         escape = null;
109         style = null;
110         styleClass = null;
111         title = null;
112     }
113 }
114
Popular Tags