cmlenz      2002/08/01 08:36:30

  Modified:    src/taglib/jstl/org/apache/slide/taglib/tag/jstl
                        ForEachLockTag.java ForEachMemberTag.java
                        SetNamespaceTag.java NamespaceTag.java
               src/taglib slide-jstl.tld
  Log:
  Added further means to loosen the forced 'nested-ness' of the JSTL-based
  taglib, by allowing users to specify which scoped variable should be used
  as a base. This should also feature better performs, as it is no longer 
  necessary to search through the list of parent tags etc. However, this is 
  just the beginning :P
  
  Revision  Changes    Path
  1.4       +36 -5     
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/ForEachLockTag.java
  
  Index: ForEachLockTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/ForEachLockTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ForEachLockTag.java       1 Aug 2002 11:49:05 -0000       1.3
  +++ ForEachLockTag.java       1 Aug 2002 15:36:30 -0000       1.4
  @@ -94,6 +94,13 @@
       
       
       /**
  +     * Value of the 'node' attribute, which should be a JSP-EL expression 
  +     * referencing the NodeBean to use.
  +     */
  +    protected String node;
  +    
  +    
  +    /**
        * Iterator over the list of locks.
        */
       protected Iterator iterator;
  @@ -120,10 +127,22 @@
       protected void prepare()
           throws JspTagException {
           
  -        NodeBean node = JstlTagUtils.findNode(this, pageContext);
  -        if (node == null) {
  -            throw new JspTagException("The 'forEachLock' tag must be " +
  -                "nested inside a 'node' tag or an iteration over nodes.");
  +        NodeBean nodeBean = null;
  +        try {
  +            nodeBean = (NodeBean)
  +                JstlTagUtils.evaluateOptionalAttribute("forEachLock", "node",
  +                                                       node, NodeBean.class,
  +                                                       this, pageContext);
  +        } catch (JspException e) {
  +            // ignore
  +        }
  +        if (nodeBean == null) {
  +            nodeBean = JstlTagUtils.findNode(this, pageContext);
  +            if (nodeBean == null) {
  +                throw new JspTagException("The 'forEachLock' tag must be " +
  +                    "nested inside a 'node' tag or an iteration over nodes, " +
  +                    "or the 'node' attribute must be set.");
  +            }
           }
           
           int depthValue = 1;
  @@ -141,7 +160,7 @@
               }
           }
           
  -        iterator = Iterators.locksIterator(node, depthValue);
  +        iterator = Iterators.locksIterator(nodeBean, depthValue);
       }
       
       
  @@ -214,6 +233,17 @@
       }
       
       
  +    /**
  +     * Sets the 'node' attribute.
  +     *
  +     * @param node the attribute value
  +     */
  +    public void setNode(String node) {
  +        
  +        this.node = node;
  +    }
  +    
  +    
       // -------------------------------------------------------- Private Methods
       
       
  @@ -223,6 +253,7 @@
       private void init() {
           
           depth = null;
  +        node = null;
           iterator = null;
       }
       
  
  
  
  1.3       +36 -5     
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/ForEachMemberTag.java
  
  Index: ForEachMemberTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/ForEachMemberTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ForEachMemberTag.java     1 Aug 2002 11:49:05 -0000       1.2
  +++ ForEachMemberTag.java     1 Aug 2002 15:36:30 -0000       1.3
  @@ -122,6 +122,13 @@
       
       
       /**
  +     * Value of the 'node' attribute, which should be a JSP-EL expression 
  +     * referencing the NodeBean to use.
  +     */
  +    protected String node;
  +    
  +    
  +    /**
        * Iterator over the list of members.
        */
       protected Iterator iterator;
  @@ -151,10 +158,22 @@
       protected void prepare()
           throws JspTagException {
           
  -        NodeBean node = JstlTagUtils.findNode(this, pageContext);
  -        if (node == null) {
  -            throw new JspTagException("The 'forEachMember' tag must be " +
  -                "nested inside a 'node' tag or an iteration over nodes.");
  +        NodeBean nodeBean = null;
  +        try {
  +            nodeBean = (NodeBean)
  +                JstlTagUtils.evaluateOptionalAttribute("forEachMember", "node",
  +                                                       node, NodeBean.class,
  +                                                       this, pageContext);
  +        } catch (JspException e) {
  +            // ignore
  +        }
  +        if (nodeBean == null) {
  +            nodeBean = JstlTagUtils.findNode(this, pageContext);
  +            if (nodeBean == null) {
  +                throw new JspTagException("The 'forEachMember' tag must be " +
  +                    "nested inside a 'node' tag or an iteration over nodes, " +
  +                    "or the 'node' attribute must be set.");
  +            }
           }
           
           int depthValue = 1;
  @@ -172,7 +191,7 @@
               }
           }
           
  -        this.iterator = Iterators.membersIterator(node, depthValue,
  +        this.iterator = Iterators.membersIterator(nodeBean, depthValue,
                                                     tokenizeString(excludeRoles),
                                                     tokenizeString(includeRoles),
                                                     tokenizeString(excludeTypes),
  @@ -300,6 +319,17 @@
       }
       
       
  +    /**
  +     * Sets the 'node' attribute.
  +     *
  +     * @param node the attribute value
  +     */
  +    public void setNode(String node) {
  +        
  +        this.node = node;
  +    }
  +    
  +    
       // -------------------------------------------------------- Private Methods
       
       
  @@ -313,6 +343,7 @@
           excludeRoles = null;
           includeTypes = null;
           excludeTypes = null;
  +        node = null;
           iterator = null;
       }
       
  
  
  
  1.2       +32 -3     
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/SetNamespaceTag.java
  
  Index: SetNamespaceTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/SetNamespaceTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SetNamespaceTag.java      1 Aug 2002 14:42:57 -0000       1.1
  +++ SetNamespaceTag.java      1 Aug 2002 15:36:30 -0000       1.2
  @@ -78,6 +78,16 @@
       extends SetNamespaceTagSupport {
       
       
  +    // ----------------------------------------------------- Instance Variables
  +    
  +    
  +    /**
  +     * Value of the 'domain' attribute, which should be a JSP-EL expression 
  +     * referencing the DomainBean to use.
  +     */
  +    private String domain;
  +    
  +    
       // ----------------------------------------------------------- Construction
       
       
  @@ -111,8 +121,16 @@
           if (evalName != null) {
               // if the name attribute was set, look for a corresponding 
               // namespace
  -            DomainBean domain = JstlTagUtils.findDomain(this, pageContext);
  -            namespace = getNamespace(domain, evalName);
  +            
  +            // evaluate the 'domain' attribute
  +            DomainBean domainBean = (DomainBean)
  +                JstlTagUtils.evaluateOptionalAttribute("namespace", "domain",
  +                                                       domain, DomainBean.class,
  +                                                       this, pageContext);
  +            if (domainBean == null) {
  +                domainBean = JstlTagUtils.findDomain(this, pageContext);
  +            }
  +            namespace = getNamespace(domainBean, evalName);
           } else {
               // use the default namespace, if available
               namespace = JstlTagUtils.findNamespace(this, pageContext);
  @@ -136,6 +154,17 @@
       
       
       /**
  +     * Sets the 'domain' attribute.
  +     *
  +     * @param domain the attribute value
  +     */
  +    public void setDomain(String domain) {
  +        
  +        this.domain = domain;
  +    }
  +    
  +    
  +    /**
        * Returns the 'var' attribute.
        *
        * @return value of the 'var' attribute
  @@ -165,7 +194,7 @@
        */
       private void init() {
           
  -        // nothing to reset as of yet
  +        domain = null;
       }
       
       
  
  
  
  1.3       +36 -7     
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/NamespaceTag.java
  
  Index: NamespaceTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/NamespaceTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NamespaceTag.java 28 Mar 2002 06:12:05 -0000      1.2
  +++ NamespaceTag.java 1 Aug 2002 15:36:30 -0000       1.3
  @@ -80,6 +80,16 @@
       extends NamespaceTagSupport {
       
       
  +    // ----------------------------------------------------- Instance Variables
  +    
  +    
  +    /**
  +     * Value of the 'domain' attribute, which should be a JSP-EL expression 
  +     * referencing the DomainBean to use.
  +     */
  +    private String domain;
  +    
  +    
       // ----------------------------------------------------------- Construction
       
       
  @@ -113,8 +123,16 @@
           if (evalName != null) {
               // if the name attribute was set, look for a corresponding 
               // namespace
  -            DomainBean domain = JstlTagUtils.findDomain(this, pageContext);
  -            namespace = getNamespace(domain, evalName);
  +            
  +            // evaluate the 'domain' attribute
  +            DomainBean domainBean = (DomainBean)
  +                JstlTagUtils.evaluateOptionalAttribute("namespace", "domain",
  +                                                       domain, DomainBean.class,
  +                                                       this, pageContext);
  +            if (domainBean == null) {
  +                domainBean = JstlTagUtils.findDomain(this, pageContext);
  +            }
  +            namespace = getNamespace(domainBean, evalName);
           } else {
               // use the default namespace, if available
               namespace = JstlTagUtils.findNamespace(this, pageContext);
  @@ -138,6 +156,17 @@
       
       
       /**
  +     * Sets the 'domain' attribute.
  +     *
  +     * @param domain the attribute value
  +     */
  +    public void setDomain(String domain) {
  +        
  +        this.domain = domain;
  +    }
  +    
  +    
  +    /**
        * Returns the 'var' attribute.
        *
        * @return value of the 'var' attribute
  @@ -167,7 +196,7 @@
        */
       private void init() {
           
  -        // nothing to reset as of yet
  +        domain = null;
       }
       
       
  
  
  
  1.5       +20 -0     jakarta-slide/src/taglib/slide-jstl.tld
  
  Index: slide-jstl.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/taglib/slide-jstl.tld,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- slide-jstl.tld    1 Aug 2002 14:42:57 -0000       1.4
  +++ slide-jstl.tld    1 Aug 2002 15:36:30 -0000       1.5
  @@ -52,6 +52,11 @@
      <tag-class>org.apache.slide.taglib.tag.jstl.NamespaceTag</tag-class>
      <body-content>JSP</body-content>
      <attribute>
  +    <name>domain</name>
  +    <required>false</required>
  +    <rtexprvalue>false</rtexprvalue>
  +   </attribute>
  +   <attribute>
       <name>name</name>
       <required>false</required>
       <rtexprvalue>false</rtexprvalue>
  @@ -74,6 +79,11 @@
      <tag-class>org.apache.slide.taglib.tag.jstl.SetNamespaceTag</tag-class>
      <body-content>JSP</body-content>
      <attribute>
  +    <name>domain</name>
  +    <required>false</required>
  +    <rtexprvalue>false</rtexprvalue>
  +   </attribute>
  +   <attribute>
       <name>name</name>
       <required>false</required>
       <rtexprvalue>false</rtexprvalue>
  @@ -189,6 +199,11 @@
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
  +    <name>node</name>
  +    <required>false</required>
  +    <rtexprvalue>false</rtexprvalue>
  +   </attribute>
  +   <attribute>
       <name>excludeRoles</name>
       <required>false</required>
       <rtexprvalue>false</rtexprvalue>
  @@ -247,6 +262,11 @@
      </attribute>
      <attribute>
       <name>depth</name>
  +    <required>false</required>
  +    <rtexprvalue>false</rtexprvalue>
  +   </attribute>
  +   <attribute>
  +    <name>node</name>
       <required>false</required>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to