1 16 package org.apache.commons.jelly.tags.define; 17 18 import org.apache.commons.jelly.JellyTagException; 19 import org.apache.commons.jelly.TagSupport; 20 import org.apache.commons.jelly.XMLOutput; 21 import org.apache.commons.jelly.expression.Expression; 22 import org.apache.commons.jelly.impl.Attribute; 23 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 37 public class AttributeTag extends TagSupport { 38 39 40 private static final Log log = LogFactory.getLog(AttributeTag.class); 41 42 43 private Attribute attribute; 44 45 public AttributeTag() { 46 attribute = new Attribute(); 47 } 48 49 public AttributeTag(Attribute attribute) { 50 this.attribute = attribute; 51 } 52 53 public void doTag(XMLOutput output) throws JellyTagException { 56 BeanTag tag = (BeanTag) findAncestorWithClass( BeanTag.class ); 57 if ( tag == null ) { 58 throw new JellyTagException( "This tag should be nested inside a <define:bean> or <define:jellybean> tag" ); 59 } 60 61 tag.addAttribute( attribute ); 62 } 63 64 67 70 public void setName(String name) { 71 attribute.setName(name); 72 } 73 74 77 public void setRequired(boolean required) { 78 attribute.setRequired(required); 79 } 80 81 84 public void setDefaultValue(Expression defaultValue) { 85 attribute.setDefaultValue(defaultValue); 86 } 87 } 88 | Popular Tags |