1 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 ; 29 30 31 49 public class HtmlTextareaRendererBase 50 extends HtmlRenderer 51 { 52 public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) 53 throws IOException 54 { 55 RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class); 56 57 ResponseWriter writer = facesContext.getResponseWriter(); 58 writer.startElement(HTML.TEXTAREA_ELEM, uiComponent); 59 60 String 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 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 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 getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object 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 |