| 1 33 34 package com.icesoft.faces.renderkit.dom_html_basic; 35 36 import com.icesoft.faces.context.DOMContext; 37 import org.w3c.dom.Element ; 38 39 import javax.faces.component.UIComponent; 40 import javax.faces.component.UIInput; 41 import javax.faces.context.FacesContext; 42 import java.io.IOException ; 43 44 public class HiddenRenderer extends DomBasicInputRenderer { 45 46 public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) 47 throws IOException { 48 validateParameters(facesContext, uiComponent, UIInput.class); 49 } 50 51 public void encodeChildren(FacesContext facesContext, 52 UIComponent uiComponent) { 53 validateParameters(facesContext, uiComponent, UIInput.class); 54 } 55 56 protected void renderEnd(FacesContext facesContext, 57 UIComponent uiComponent, String currentValue) 58 throws IOException { 59 60 validateParameters(facesContext, uiComponent, UIInput.class); 61 DOMContext domContext = 62 DOMContext.attachDOMContext(facesContext, uiComponent); 63 if (!domContext.isInitialized()) { 64 Element root = domContext.createElement("input"); 65 domContext.setRootNode(root); 66 setRootElementId(facesContext, root, uiComponent); 67 String clientId = uiComponent.getClientId(facesContext); 68 root.setAttribute("name", clientId); 69 root.setAttribute("type", "hidden"); 70 } 71 Element root = (Element ) domContext.getRootNode(); 72 if (currentValue != null) { 73 root.setAttribute("value", currentValue); 74 } 75 domContext.streamWrite(facesContext, uiComponent); 76 } 77 } 78 79 | Popular Tags |