1 14 15 package com.sun.facelets.tag.jsf.core; 16 17 import java.io.IOException ; 18 19 import javax.el.ELException; 20 import javax.faces.FacesException; 21 import javax.faces.component.UIComponent; 22 import javax.faces.component.UIComponentBase; 23 24 import com.sun.facelets.FaceletContext; 25 import com.sun.facelets.FaceletException; 26 import com.sun.facelets.tag.TagAttribute; 27 import com.sun.facelets.tag.TagConfig; 28 import com.sun.facelets.tag.TagException; 29 import com.sun.facelets.tag.TagHandler; 30 31 40 public final class FacetHandler extends TagHandler { 41 42 49 private final static class UIFacet extends UIComponentBase { 50 public String getFamily() { 51 return null; 52 } 53 } 54 55 protected final TagAttribute name; 56 57 public FacetHandler(TagConfig config) { 58 super(config); 59 this.name = this.getRequiredAttribute("name"); 60 } 61 62 65 public void apply(FaceletContext ctx, UIComponent parent) 66 throws IOException , FacesException, FaceletException, ELException { 67 UIFacet facet = new UIFacet(); 68 String name = this.name.getValue(ctx); 69 UIComponent oldFacetChild = (UIComponent) parent.getFacets().remove(name); 70 if (oldFacetChild != null) { 71 facet.getChildren().add(oldFacetChild); 72 } 73 this.nextHandler.apply(ctx, facet); 74 int childCount = facet.getChildCount(); 75 UIComponent c; 76 if (childCount == 1) { 77 c = (UIComponent) facet.getChildren().get(0); 78 parent.getFacets().put(name, c); 79 } else { 80 throw new TagException(this.tag, "Facet Tag can only have one child UIComponent"); 81 } 82 } 83 } 84 | Popular Tags |