cmlenz      2002/08/01 09:42:35

  Modified:    src/taglib/jstl/org/apache/slide/taglib/tag/jstl
                        RevisionTag.java
  Log:
  - Added node attribute for non-nested use
  
  Revision  Changes    Path
  1.4       +94 -9     
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/RevisionTag.java
  
  Index: RevisionTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/RevisionTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RevisionTag.java  1 Aug 2002 15:43:52 -0000       1.3
  +++ RevisionTag.java  1 Aug 2002 16:42:35 -0000       1.4
  @@ -64,12 +64,10 @@
   package org.apache.slide.taglib.tag.jstl;
   
   import javax.servlet.jsp.JspException;
  -import javax.servlet.jsp.PageContext;
  +import javax.servlet.jsp.JspTagException;
   
  -import org.apache.slide.common.SlideException;
   import org.apache.slide.content.NodeRevisionNumber;
   import org.apache.slide.taglib.bean.NodeBean;
  -import org.apache.slide.taglib.bean.RevisionBean;
   import org.apache.slide.taglib.tag.RevisionTagSupport;
   
   
  @@ -83,6 +81,29 @@
       extends RevisionTagSupport {
       
       
  +    // ----------------------------------------------------- Instance Variables
  +    
  +    
  +    /**
  +     * Value of the 'node' attribute, which should be a JSP-EL expression 
  +     * referencing the NodeBean to use.
  +     */
  +    protected String node;
  +    
  +    
  +    // ----------------------------------------------------------- Construction
  +    
  +    
  +    /**
  +     * Initialize inherited and local state.
  +     */
  +    public RevisionTag() {
  +        super();
  +        
  +        init();
  +    }
  +    
  +    
       // ------------------------------------------------------------ Tag Methods
       
       
  @@ -121,17 +142,69 @@
               }
           }
           
  -        NodeBean node = JstlTagUtils.findNode(this, pageContext);
  -        revision = getRevision(node, nrn, evalBranch);
  +        NodeBean nodeBean = null;
  +        try {
  +            nodeBean = (NodeBean)
  +                JstlTagUtils.evaluateOptionalAttribute("revision", "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 'revision' tag must be " +
  +                    "nested inside a 'node' tag or an iteration over nodes, " +
  +                    "or the 'node' attribute must be set.");
  +            }
  +        }
  +        
  +        revision = getRevision(nodeBean, nrn, evalBranch);
           
           return super.doStartTag();
       }
       
       
  +    /**
  +     * Called by the JSP Engine when closing of this tag.
  +     *
  +     * @throws JspException never thrown
  +     */
  +    public int doEndTag()
  +        throws JspException {
  +        
  +        init();
  +        
  +        return super.doEndTag();
  +    }
  +    
  +    
  +    /**
  +     * Releases any resources we may have (or inherit).
  +     */
  +    public void release() {
  +        super.release();
  +        
  +        init();
  +    }
  +    
  +    
       // --------------------------------------------------------- Public Methods
       
       
       /**
  +     * Sets the 'node' attribute.
  +     *
  +     * @param node the attribute value
  +     */
  +    public void setNode(String node) {
  +        
  +        this.node = node;
  +    }
  +    
  +    
  +    /**
        * Set the 'var' attribute.
        *
        * @param var the attribute value
  @@ -139,6 +212,18 @@
       public void setVar(String var) {
           
           attrName = var;
  +    }
  +    
  +    
  +    // -------------------------------------------------------- Private Methods
  +    
  +    
  +    /**
  +     * Reset internal state.
  +     */
  +    private void init() {
  +        
  +        node = null;
       }
       
       
  
  
  

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

Reply via email to