KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > renderkit > html > HtmlTextareaRendererBase


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.renderkit.html;
17
18 import org.apache.myfaces.renderkit.JSFAttr;
19 import org.apache.myfaces.renderkit.RendererUtils;
20
21 import javax.faces.component.UIComponent;
22 import javax.faces.component.UIInput;
23 import javax.faces.component.UIOutput;
24 import javax.faces.component.html.HtmlInputTextarea;
25 import javax.faces.context.FacesContext;
26 import javax.faces.context.ResponseWriter;
27 import javax.faces.convert.ConverterException;
28 import java.io.IOException JavaDoc;
29
30
31 /**
32  * @author Manfred Geiler (latest modification by $Author: mmarinschek $)
33  * @author Anton Koinov
34  * @version $Revision: 1.4 $ $Date: 2004/12/23 13:03:09 $
35  * $Log: HtmlTextareaRendererBase.java,v $
36  * Revision 1.4 2004/12/23 13:03:09 mmarinschek
37  * id's not rendered (or not conditionally rendered); changes in jslistener to support both ie and firefox now
38  *
39  * Revision 1.3 2004/10/13 11:51:01 matze
40  * renamed packages to org.apache
41  *
42  * Revision 1.2 2004/07/01 22:00:57 mwessendorf
43  * ASF switch
44  *
45  * Revision 1.1 2004/05/18 14:31:39 manolito
46  * user role support completely moved to components source tree
47  *
48  */

49 public class HtmlTextareaRendererBase
50         extends HtmlRenderer
51 {
52     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
53             throws IOException JavaDoc
54     {
55         RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
56
57         ResponseWriter writer = facesContext.getResponseWriter();
58         writer.startElement(HTML.TEXTAREA_ELEM, uiComponent);
59
60         String JavaDoc clientId = uiComponent.getClientId(facesContext);
61         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
62         HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
63
64         HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
65         if (isDisabled(facesContext, uiComponent))
66         {
67             writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
68         }
69
70         String JavaDoc strValue = RendererUtils.getStringValue(facesContext, uiComponent);
71         writer.writeText(strValue, JSFAttr.VALUE_ATTR);
72
73         writer.endElement(HTML.TEXTAREA_ELEM);
74     }
75
76     protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
77     {
78         //TODO: overwrite in extended HtmlTextareaRenderer and check for enabledOnUserRole
79
if (uiComponent instanceof HtmlInputTextarea)
80         {
81             return ((HtmlInputTextarea)uiComponent).isDisabled();
82         }
83         else
84         {
85             return RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false);
86         }
87     }
88
89     public void decode(FacesContext facesContext, UIComponent component)
90     {
91         RendererUtils.checkParamValidity(facesContext, component, UIInput.class);
92         HtmlRendererUtils.decodeUIInput(facesContext, component);
93     }
94
95     public Object JavaDoc getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object JavaDoc submittedValue) throws ConverterException
96     {
97         RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
98         return RendererUtils.getConvertedUIOutputValue(facesContext,
99                                                        (UIOutput)uiComponent,
100                                                        submittedValue);
101     }
102
103 }
104
Popular Tags