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.context.FacesContext; 25 import javax.faces.context.ResponseWriter; 26 import javax.faces.convert.ConverterException; 27 import java.io.IOException ; 28 29 30 50 public class HtmlHiddenRenderer 51 extends HtmlRenderer 52 { 53 public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) 54 throws IOException 55 { 56 RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class); 57 58 ResponseWriter writer = facesContext.getResponseWriter(); 59 60 writer.startElement(HTML.INPUT_ELEM, uiComponent); 61 writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null); 62 63 String clientId = uiComponent.getClientId(facesContext); 64 writer.writeAttribute(HTML.ID_ATTR, clientId, null); 65 writer.writeAttribute(HTML.NAME_ATTR, clientId, null); 66 67 String value = RendererUtils.getStringValue(facesContext, uiComponent); 68 if (value != null) 69 { 70 writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR); 71 } 72 73 writer.endElement(HTML.INPUT_ELEM); 74 } 75 76 public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException 77 { 78 RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class); 79 return RendererUtils.getConvertedUIOutputValue(facesContext, 80 (UIOutput)uiComponent, 81 submittedValue); 82 } 83 84 85 public void decode(FacesContext facesContext, UIComponent component) 86 { 87 RendererUtils.checkParamValidity(facesContext,component,null); 88 89 if (component instanceof UIInput) 90 { 91 HtmlRendererUtils.decodeUIInput(facesContext, component); 92 } 93 else 94 { 95 throw new IllegalArgumentException ("Unsupported component class " + component.getClass().getName()); 96 } 97 } 98 99 } 100 | Popular Tags |