1 14 15 package com.sun.facelets.tag; 16 17 import java.io.FileNotFoundException ; 18 import java.io.IOException ; 19 import java.net.URL ; 20 21 import javax.el.ELException; 22 import javax.el.VariableMapper; 23 import javax.faces.FacesException; 24 import javax.faces.component.UIComponent; 25 26 import com.sun.facelets.FaceletContext; 27 import com.sun.facelets.FaceletException; 28 import com.sun.facelets.FaceletHandler; 29 import com.sun.facelets.TemplateClient; 30 import com.sun.facelets.el.VariableMapperWrapper; 31 32 39 final class UserTagHandler extends TagHandler implements TemplateClient { 40 41 protected final TagAttribute[] vars; 42 43 protected final URL location; 44 45 48 public UserTagHandler(TagConfig config, URL location) { 49 super(config); 50 this.vars = this.tag.getAttributes().getAll(); 51 this.location = location; 52 } 53 54 64 public void apply(FaceletContext ctx, UIComponent parent) 65 throws IOException , FacesException, FaceletException, ELException { 66 VariableMapper orig = ctx.getVariableMapper(); 67 68 if (this.vars.length > 0) { 70 VariableMapper varMapper = new VariableMapperWrapper(orig); 71 for (int i = 0; i < this.vars.length; i++) { 72 varMapper.setVariable(this.vars[i].getLocalName(), this.vars[i] 73 .getValueExpression(ctx, Object .class)); 74 } 75 ctx.setVariableMapper(varMapper); 76 } 77 78 try { 80 ctx.pushClient(this); 81 ctx.includeFacelet(parent, this.location); 82 } catch (FileNotFoundException e) { 83 throw new TagException(this.tag, e.getMessage()); 84 } finally { 85 86 ctx.popClient(this); 88 ctx.setVariableMapper(orig); 89 } 90 } 91 92 public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException , FacesException, FaceletException, ELException { 93 if (name == null) { 94 this.nextHandler.apply(ctx, parent); 95 return true; 96 } 97 return false; 98 } 99 100 } 101 | Popular Tags |