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 23 import com.sun.facelets.FaceletContext; 24 import com.sun.facelets.FaceletException; 25 import com.sun.facelets.el.ELAdaptor; 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 46 public final class AttributeHandler extends TagHandler { 47 48 private final TagAttribute name; 49 50 private final TagAttribute value; 51 52 55 public AttributeHandler(TagConfig config) { 56 super(config); 57 this.name = this.getRequiredAttribute("name"); 58 this.value = this.getRequiredAttribute("value"); 59 } 60 61 67 public void apply(FaceletContext ctx, UIComponent parent) 68 throws IOException , FacesException, FaceletException, ELException { 69 if (parent == null) { 70 throw new TagException(this.tag, "Parent UIComponent was null"); 71 } 72 73 if (parent.getParent() == null) { 75 String n = this.name.getValue(ctx); 76 if (!parent.getAttributes().containsKey(n)) { 77 if (this.value.isLiteral()) { 78 parent.getAttributes().put(n, this.value.getValue()); 79 } else { 80 ELAdaptor.setExpression(parent, n, this.value 81 .getValueExpression(ctx, Object .class)); 82 } 83 } 84 } 85 } 86 } 87 | Popular Tags |