You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/09/05 15:36:44 UTC

cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define TaglibTag.java

jstrachan    2002/09/05 06:36:44

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/define
                        TaglibTag.java
  Log:
  Added support for inheritence of dynamic tag libraries. This allows individual tags to be overloaded from an existing library or from a dynamic library.
  
  Revision  Changes    Path
  1.2       +36 -3     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/TaglibTag.java
  
  Index: TaglibTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/TaglibTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TaglibTag.java	9 Aug 2002 18:01:01 -0000	1.1
  +++ TaglibTag.java	5 Sep 2002 13:36:44 -0000	1.2
  @@ -84,6 +84,8 @@
       private String uri;
       /** The new tags being added */
       private DynamicTagLibrary tagLibrary;
  +    /** Whether or not inheritence is enabled */
  +    private boolean inherit = true;
       
       public TaglibTag() {
       }
  @@ -95,9 +97,14 @@
       // Tag interface
       //-------------------------------------------------------------------------                    
       public void doTag(XMLOutput output) throws Exception {
  -        tagLibrary = new DynamicTagLibrary( getUri() );
  +        String uri = getUri();
  +        tagLibrary = new DynamicTagLibrary( uri );
   
  -        context.registerTagLibrary( getUri(), tagLibrary );
  +        // inherit tags from an existing tag library
  +        if ( isInherit() ) {
  +            tagLibrary.setParent( context.getTagLibrary( uri ) );
  +        }
  +        context.registerTagLibrary( uri, tagLibrary );
           
           invokeBody(output);
   
  @@ -109,7 +116,10 @@
       public String getUri() {
           return uri;
       }
  -    
  +
  +    /**
  +     * Sets the namespace URI to register this new dynamic tag library with
  +     */    
       public void setUri(String uri) {
           this.uri = uri;
       }
  @@ -117,4 +127,27 @@
       public DynamicTagLibrary getTagLibrary() {
           return tagLibrary;
       }
  +    
  +    /**
  +     * Returns the inherit.
  +     * @return boolean
  +     */
  +    public boolean isInherit() {
  +        return inherit;
  +    }
  +
  +    /**
  +     * Sets whether this dynamic tag should inherit from the current existing tag library 
  +     * of the same URI. This feature is enabled by default so that tags can easily be
  +     * some tags can be overridden in an existing library, such as when making Mock Tags.
  +     * 
  +     * You can disable this option if you want to disable any tags in the base library,
  +     * turning them into just normal static XML.
  +     *
  +     * @param inherit The inherit to set
  +     */
  +    public void setInherit(boolean inherit) {
  +        this.inherit = inherit;
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>