Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Tag


                {
                    public Tag createTag( String name, Attributes attributes )
                        throws JellyException
                    {
                        // lets try create a dynamic tag first
                        Tag tag = JeezTagLibrary.this.createTag( name, attributes );
                        if ( tag != null )
                        {
                            return tag;
                        }
                        else
View Full Code Here


            if ( script == null ) {
                return new DynaTagScript(
                    new TagFactory() {
                        public Tag createTag() throws Exception {
                            // lets try create a dynamic tag first
                            Tag tag = JeezTagLibrary.this.createTag(name);
                            if ( tag != null ) {
                                return tag;
                            }
                            else {
                                return antTagLib.createTag( name );
View Full Code Here

            script.run(context, output);
        }
        else {
            // note this mechanism does not work properly for arbitrarily
            // nested dynamic tags. A better way is required.
            Tag tag = findAncestorWithClass(this, DynamicTag.class);
            if (tag == null) {
                throw new JellyException("Cannot invoke body, no dynamic tag is defined in this block");
            }
            else {
                tag.invokeBody(output);
            }
        }
    }
View Full Code Here

    /**
     * Attempts to look up in the parent hierarchy for a tag that implements the BeanSource interface
     * which creates a dynamic bean, or will return the parent tag, which is also a bean.
     */
    protected Object findBeanAncestor() throws Exception {
        Tag tag = getParent();
        if (tag != null) {
            if (tag instanceof BeanSource) {
                BeanSource beanSource = (BeanSource) tag;
                return beanSource.getBean();
            }
View Full Code Here

    /**
     * @return the tag to be evaluated, creating it lazily if required.
     */
    public Tag getTag() throws Exception {
        Tag tag = (Tag) tagHolder.get();
        if ( tag == null ) {
            tag = createTag();
            if ( tag != null ) {
                configureTag(tag);
                tagHolder.set(tag);
View Full Code Here

     */
    protected void configureTag(Tag tag) throws Exception {
        if (tag instanceof CompilableTag) {
            ((CompilableTag) tag).compile();
        }
        Tag parentTag = null;
        if ( parent != null ) {
            parentTag = parent.getTag();
        }
        tag.setParent( parentTag );
        tag.setBody( tagBody );
View Full Code Here

        throws Exception {

        return new DynaTagScript(
            new TagFactory() {
                public Tag createTag() throws Exception {
                    Tag answer = DynamicTagLibrary.this.createTag(name);
                   
                    // delegate to my parent instead
                    if ( answer == null && parent != null ) {
                        return parent.createTag(name, attributes);
                    }
View Full Code Here

    /** Evaluates the body of a tag */
    public void run(JellyContext context, XMLOutput output) throws Exception {

        startNamespacePrefixes(output);
           
        Tag tag = getTag();               
       
        // lets see if we have a dynamic tag
        tag = findDynamicTag(context, (StaticTag) tag);
        setTag(tag);
       
        try {       
            if ( tag == null ) {
                return;
            }
            tag.setContext(context);
           
            DynaTag dynaTag = (DynaTag) tag;
   
            // ### probably compiling this to 2 arrays might be quicker and smaller
            for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry) iter.next();
                String name = (String) entry.getKey();
                Expression expression = (Expression) entry.getValue();
   
                Object value = expression.evaluate(context);
                dynaTag.setAttribute(name, value);
            }
       
            tag.doTag(output);
        }
        catch (JellyException e) {
            handleException(e);
        }
        catch (Exception e) {
View Full Code Here

    protected Tag findDynamicTag(JellyContext context, StaticTag tag) throws Exception {
        // lets see if there's a tag library for this URI...
        TagLibrary taglib = context.getTagLibrary( tag.getUri() );
        if ( taglib instanceof DynamicTagLibrary ) {
            DynamicTagLibrary dynaLib = (DynamicTagLibrary) taglib;
            Tag newTag = dynaLib.createTag( tag.getLocalName() );
            if ( newTag != null ) {
                newTag.setParent( tag.getParent() );
                newTag.setBody( tag.getBody() );
                return newTag;
            }
        }
        return tag;
    }
View Full Code Here

    public void run(JellyContext context, XMLOutput output) throws Exception {
        if ( ! context.isCacheTags() ) {
            clearTag();
        }
        try {
            Tag tag = getTag();
            if ( tag == null ) {
                return;
            }
            tag.setContext(context);
   
            if ( tag instanceof DynaTag ) {       
                DynaTag dynaTag = (DynaTag) tag;
       
                // ### probably compiling this to 2 arrays might be quicker and smaller
                for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
                    Map.Entry entry = (Map.Entry) iter.next();
                    String name = (String) entry.getKey();
                    Expression expression = (Expression) entry.getValue();
       
                    Object value = expression.evaluate(context);
                    dynaTag.setAttribute(name, value);
                }
            }
            else {
                // treat the tag as a bean
                DynaBean dynaBean = new ConvertingWrapDynaBean( tag );
                for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
                    Map.Entry entry = (Map.Entry) iter.next();
                    String name = (String) entry.getKey();
                    Expression expression = (Expression) entry.getValue();
       
                    Object value = expression.evaluate(context);
                    dynaBean.set(name, value);
                }
            }
       
            tag.doTag(output);
        }
        catch (JellyException e) {
            handleException(e);
        }
        catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.