1 14 15 package com.sun.facelets.tag.ui; 16 17 import java.io.IOException ; 18 19 import javax.el.ELException; 20 import javax.faces.FacesException; 21 import javax.faces.component.UIComponent; 22 23 import com.sun.facelets.FaceletContext; 24 import com.sun.facelets.FaceletException; 25 import com.sun.facelets.FaceletHandler; 26 import com.sun.facelets.TemplateClient; 27 import com.sun.facelets.tag.TagAttribute; 28 import com.sun.facelets.tag.TagAttributeException; 29 import com.sun.facelets.tag.TagConfig; 30 import com.sun.facelets.tag.TagHandler; 31 32 36 public final class InsertHandler extends TagHandler implements TemplateClient { 37 38 private final String name; 39 40 43 public InsertHandler(TagConfig config) { 44 super(config); 45 TagAttribute attr = this.getAttribute("name"); 46 if (attr != null) { 47 if (!attr.isLiteral()) { 48 throw new TagAttributeException(this.tag, attr, "Must be Literal"); 49 } 50 this.name = attr.getValue(); 51 } else { 52 this.name = null; 53 } 54 } 55 56 62 public void apply(FaceletContext ctx, UIComponent parent) 63 throws IOException , FacesException, FaceletException, ELException { 64 65 ctx.extendClient(this); 66 boolean found = false; 67 try { 68 found = ctx.includeDefinition(parent, this.name); 69 } finally { 70 ctx.popClient(this); 71 } 72 if (!found) { 73 this.nextHandler.apply(ctx, parent); 74 } 75 } 76 77 public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException , FacesException, FaceletException, ELException { 78 if (this.name == name || this.name != null && this.name.equals(name)) { 79 this.nextHandler.apply(ctx, parent); 80 return true; 81 } 82 return false; 83 } 84 } 85 | Popular Tags |