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.UICommand; 40 import javax.faces.component.UIComponent; 41 import javax.faces.component.UIOutput; 42 import javax.faces.context.FacesContext; 43 import java.io.IOException ; 44 45 public class LinkRenderer extends DomBasicRenderer { 46 47 protected CommandLinkRenderer commandLinkRendererDelegate; 48 protected OutputLinkRenderer outputLinkRendererDelegate; 49 50 public LinkRenderer() { 51 commandLinkRendererDelegate = new CommandLinkRenderer(); 52 outputLinkRendererDelegate = new OutputLinkRenderer(); 53 } 54 55 public void decode(FacesContext facesContext, UIComponent uiComponent) { 56 boolean isCommandLink = uiComponent instanceof UICommand; 57 boolean isOutputLink = uiComponent instanceof UIOutput; 58 if (isCommandLink) { 59 commandLinkRendererDelegate.decode(facesContext, uiComponent); 60 } 61 if (isOutputLink) { 62 outputLinkRendererDelegate.decode(facesContext, uiComponent); 63 } 64 return; 65 } 66 67 public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) 68 throws IOException { 69 boolean isCommandLink = uiComponent instanceof UICommand; 70 boolean isOutputLink = uiComponent instanceof UIOutput; 71 if (isCommandLink) { 72 commandLinkRendererDelegate.encodeBegin(facesContext, uiComponent); 73 } 74 if (isOutputLink) { 75 outputLinkRendererDelegate.encodeBegin(facesContext, uiComponent); 76 } 77 78 return; 79 } 80 81 public void encodeChildren(FacesContext facesContext, 82 UIComponent uiComponent) 83 throws IOException { 84 boolean isCommandLink = uiComponent instanceof UICommand; 85 boolean isOutputLink = uiComponent instanceof UIOutput; 86 if (isCommandLink) { 87 commandLinkRendererDelegate 88 .encodeChildren(facesContext, uiComponent); 89 } 90 if (isOutputLink) { 91 outputLinkRendererDelegate 92 .encodeChildren(facesContext, uiComponent); 93 } 94 return; 95 } 96 97 public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) 98 throws IOException { 99 boolean isCommandLink = uiComponent instanceof UICommand; 100 boolean isOutputLink = uiComponent instanceof UIOutput; 101 if (isCommandLink) { 102 commandLinkRendererDelegate.encodeEnd(facesContext, uiComponent); 103 } 104 if (isOutputLink) { 105 outputLinkRendererDelegate.encodeEnd(facesContext, uiComponent); 106 } 107 DOMContext domContext = 108 DOMContext.attachDOMContext(facesContext, uiComponent); 109 Element root = (Element ) domContext.getRootNode(); 110 return; 111 } 112 113 } 114 | Popular Tags |