KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > wap > renderkit > wml > OutputTextRenderer


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.wap.renderkit.wml;
17
18 import javax.faces.component.UIComponent;
19 import javax.faces.context.FacesContext;
20 import javax.faces.context.ResponseWriter;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.myfaces.wap.component.OutputText;
25 import org.apache.myfaces.wap.renderkit.Attributes;
26 import org.apache.myfaces.wap.renderkit.RendererUtils;
27 import org.apache.myfaces.wap.renderkit.WmlRenderer;
28
29 /**
30  * @author <a HREF="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author: matzew $)
31  * @version $Revision: 1.1 $ $Date: 2004/12/30 09:37:26 $
32  * $Log: OutputTextRenderer.java,v $
33  * Revision 1.1 2004/12/30 09:37:26 matzew
34  * added a new RenderKit for WML. Thanks to Jirí Žaloudek
35  *
36  */

37 public class OutputTextRenderer extends WmlRenderer {
38     private static Log log = LogFactory.getLog(OutputTextRenderer.class);
39     
40     /** Creates a new instance of TextRenderer */
41     public OutputTextRenderer() {
42         super();
43         log.debug("created object " + this.getClass().getName());
44     }
45     
46     public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException JavaDoc {
47         log.debug("encodeBegin(" + component.getId() + ")");
48         if (context == null || component == null) {
49             throw new NullPointerException JavaDoc();
50         }
51     }
52     
53     public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException JavaDoc {
54         log.debug("encodeChildren(" + component.getId() + ")");
55         if (context == null || component == null) {
56             throw new NullPointerException JavaDoc();
57         }
58     }
59     
60     public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException JavaDoc {
61         log.debug("encodeEnd(" + component.getId() + ")");
62         if (context == null || component == null) {
63             throw new NullPointerException JavaDoc();
64         }
65         
66         if (!component.isRendered()) return;
67         
68         OutputText comp = (OutputText)component;
69         
70         ResponseWriter writer = context.getResponseWriter();
71         
72         if (comp.getValue() != null) {
73             String JavaDoc textValue = RendererUtils.convertToString(context, component);
74             log.debug("OutputText value:" + textValue);
75             
76             if (comp.isEscape())
77                 writer.writeText(textValue, Attributes.VALUE);
78             else
79                 writer.write(textValue);
80             
81         }
82     }
83     
84     public void decode(FacesContext context, UIComponent component) {
85         if (component == null ) throw new NullPointerException JavaDoc();
86     }
87     
88     /** Overrides method getConvertedValue */
89     public Object JavaDoc getConvertedValue(FacesContext context, UIComponent component, Object JavaDoc submittedValue) throws javax.faces.convert.ConverterException {
90         return(RendererUtils.convertToObject(context, component));
91     }
92 }
93
94
Popular Tags