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 import java.util.HashSet ; 44 45 public class SecretRenderer extends DomBasicInputRenderer { 46 47 public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) 48 throws IOException { 49 validateParameters(facesContext, uiComponent, UIInput.class); 50 } 51 52 public void encodeChildren(FacesContext facesContext, 53 UIComponent uiComponent) 54 throws IOException { 55 validateParameters(facesContext, uiComponent, UIInput.class); 56 } 57 58 protected void renderEnd(FacesContext facesContext, UIComponent uiComponent, 59 String currentValue) throws IOException { 60 61 validateParameters(facesContext, uiComponent, UIInput.class); 62 63 DOMContext domContext = 64 DOMContext.attachDOMContext(facesContext, uiComponent); 65 66 if (!domContext.isInitialized()) { 67 Element root = domContext.createElement("input"); 68 domContext.setRootNode(root); 69 setRootElementId(facesContext, root, uiComponent); 70 root.setAttribute("type", "password"); 71 root.setAttribute("name", uiComponent.getClientId(facesContext)); 72 } 73 74 Element root = (Element ) domContext.getRootNode(); 75 76 String dir = (String ) uiComponent.getAttributes().get("dir"); 77 if (dir != null) { 78 root.setAttribute("dir", dir); 79 } 80 81 String styleClass = 82 (String ) uiComponent.getAttributes().get("styleClass"); 83 if (styleClass != null) { 84 root.setAttribute("class", styleClass); 85 } 86 PassThruAttributeRenderer.renderAttributes( 87 facesContext, uiComponent, null); 88 89 if (redisplayAttributeIsTrue(uiComponent) && currentValue != null) { 93 root.setAttribute("value", currentValue); 94 } else { 95 root.setAttribute("value", ""); 96 } 97 98 HashSet excludes = new HashSet (); 99 addJavaScript(facesContext, uiComponent, root, excludes); 100 domContext.streamWrite(facesContext, uiComponent); 101 } 102 103 107 private boolean redisplayAttributeIsTrue(UIComponent uiComponent) { 108 Object redisplayAttribute = 109 uiComponent.getAttributes().get("redisplay"); 110 return redisplayAttribute != null 111 && redisplayAttribute.toString().toLowerCase().equals("true"); 112 } 113 114 protected void addJavaScript(FacesContext facesContext, 115 UIComponent uiComponent, Element root, 116 HashSet excludes) { 117 } 118 } | Popular Tags |