1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.shared_impl.renderkit.html; |
20 | |
|
21 | |
import org.apache.myfaces.shared_impl.renderkit.RendererUtils; |
22 | |
import org.apache.myfaces.shared_impl.renderkit.html.HTML; |
23 | |
import org.apache.myfaces.shared_impl.renderkit.html.HtmlRenderer; |
24 | |
import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils; |
25 | |
|
26 | |
import javax.faces.component.UIComponent; |
27 | |
import javax.faces.component.UIInput; |
28 | |
import javax.faces.component.UIOutput; |
29 | |
import javax.faces.component.html.HtmlInputTextarea; |
30 | |
import javax.faces.context.FacesContext; |
31 | |
import javax.faces.context.ResponseWriter; |
32 | |
import javax.faces.convert.ConverterException; |
33 | |
import java.io.IOException; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class HtmlTextareaRendererBase |
42 | |
extends HtmlRenderer |
43 | |
{ |
44 | |
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) |
45 | |
throws IOException |
46 | |
{ |
47 | 0 | RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class); |
48 | |
|
49 | 0 | encodeTextArea(facesContext, uiComponent); |
50 | |
|
51 | 0 | } |
52 | |
|
53 | |
protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent) throws IOException { |
54 | 0 | ResponseWriter writer = facesContext.getResponseWriter(); |
55 | 0 | writer.startElement(HTML.TEXTAREA_ELEM, uiComponent); |
56 | |
|
57 | 0 | String clientId = uiComponent.getClientId(facesContext); |
58 | 0 | writer.writeAttribute(HTML.NAME_ATTR, clientId, null); |
59 | 0 | HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext); |
60 | |
|
61 | 0 | HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED); |
62 | 0 | if (isDisabled(facesContext, uiComponent)) |
63 | |
{ |
64 | 0 | writer.writeAttribute(org.apache.myfaces.shared_impl.renderkit.html.HTML.DISABLED_ATTR, Boolean.TRUE, null); |
65 | |
} |
66 | |
|
67 | 0 | String strValue = org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(facesContext, uiComponent); |
68 | 0 | writer.writeText(strValue, org.apache.myfaces.shared_impl.renderkit.JSFAttr.VALUE_ATTR); |
69 | |
|
70 | 0 | writer.endElement(HTML.TEXTAREA_ELEM); |
71 | 0 | } |
72 | |
|
73 | |
protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent) |
74 | |
{ |
75 | |
|
76 | 0 | if (uiComponent instanceof HtmlInputTextarea) |
77 | |
{ |
78 | 0 | return ((HtmlInputTextarea)uiComponent).isDisabled(); |
79 | |
} |
80 | |
|
81 | 0 | return org.apache.myfaces.shared_impl.renderkit.RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false); |
82 | |
|
83 | |
} |
84 | |
|
85 | |
public void decode(FacesContext facesContext, UIComponent component) |
86 | |
{ |
87 | 0 | RendererUtils.checkParamValidity(facesContext, component, UIInput.class); |
88 | 0 | HtmlRendererUtils.decodeUIInput(facesContext, component); |
89 | 0 | } |
90 | |
|
91 | |
public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException |
92 | |
{ |
93 | 0 | RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class); |
94 | 0 | return org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUIOutputValue(facesContext, |
95 | |
(UIOutput)uiComponent, |
96 | |
submittedValue); |
97 | |
} |
98 | |
|
99 | |
} |