1 23 package com.sun.enterprise.tools.jsfext.renderer; 24 25 import com.sun.enterprise.tools.jsfext.component.TemplateComponent; 26 import com.sun.enterprise.tools.jsfext.layout.descriptor.LayoutDefinition; 27 import com.sun.enterprise.tools.jsfext.layout.descriptor.Resource; 28 29 import java.io.IOException ; 30 import java.util.Iterator ; 31 32 import javax.faces.context.FacesContext; 33 import javax.faces.component.UIComponent; 34 import javax.faces.render.Renderer; 35 36 37 55 public class TemplateRenderer extends Renderer { 56 57 66 public boolean getRendersChildren() { 67 return true; 68 } 69 70 71 79 public void encodeBegin(FacesContext context, UIComponent component) throws IOException { 80 if (!(component instanceof TemplateComponent)) { 82 throw new IllegalArgumentException ( 83 "TemplateRenderer requires that its UIComponent be an " 84 + "instance of TemplateComponent!"); 85 } 86 TemplateComponent tempComp = (TemplateComponent) component; 87 LayoutDefinition def = tempComp.getLayoutDefinition(context); 88 89 Iterator it = def.getResources().iterator(); 91 Resource resource = null; 92 while (it.hasNext()) { 93 resource = (Resource) it.next(); 94 resource.getFactory().getResource(context, resource); 96 } 97 98 super.encodeBegin(context, component); 100 } 101 102 111 public void encodeChildren(FacesContext context, UIComponent component) { 112 } 114 115 128 public void encodeEnd(FacesContext context, UIComponent component) throws IOException { 129 if (!component.isRendered()) { 131 return; 132 } 133 134 TemplateComponent tempComp = (TemplateComponent) component; 136 LayoutDefinition def = tempComp.getLayoutDefinition(context); 137 138 def.encode(context, (UIComponent) tempComp); 140 } 141 142 162 public void decode(FacesContext context, UIComponent component) { 163 super.decode(context, component); 165 166 TemplateComponent tempComp = (TemplateComponent) component; 168 LayoutDefinition def = tempComp.getLayoutDefinition(context); 169 def.decode(context, component); 170 } 171 } 172 | Popular Tags |