cmlenz      02/01/27 07:46:37

  Modified:    .        build.xml
  Added:       src/taglib slide-jstl.tld
               src/taglib/jstl/org/apache/slide/taglib/tag/jstl
                        DomainTag.java JstlTagUtils.java NamespaceTag.java
                        NodeTag.java PropertyTag.java RevisionTag.java
  Log:
  first shot at a JSTL/EA variant of the slide taglib. this is not exte
  tested yet.
  
  Revision  Changes    Path
  1.148     +56 -11    jakarta-slide/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/build.xml,v
  retrieving revision 1.147
  retrieving revision 1.148
  diff -u -r1.147 -r1.148
  --- build.xml 25 Jan 2002 16:24:18 -0000      1.147
  +++ build.xml 27 Jan 2002 15:46:37 -0000      1.148
  @@ -68,6 +68,9 @@
     <property name="struts.home"           value="."/>
     <property name="struts.jar"
               value="${struts.home}/lib/struts.jar"/>
  +  <property name="taglibs.home"          value="../jakarta-taglibs/dist"/>
  +  <property name="taglibs-standard.jar"
  +            value="${taglibs.home}/standard/standard.jar"/>
     <property name="commons-httpclient.jar"
               value="lib/commons-httpclient.jar"/>
     <property name="tomcat.build"          value="../jakarta-tomcat-4.0/build" />
  @@ -198,6 +201,7 @@
     <path id="taglib.classpath">
       <pathelement location="${servlet.jar}"/>
       <pathelement location="${struts.jar}"/>
  +    <pathelement location="${taglibs-standard.jar}"/>
       <pathelement location="${jta.jar}"/>
       <pathelement location="${slide.build}/classes"/>
     </path>
  @@ -337,6 +341,9 @@
       <available property="struts.present"
        classname="org.apache.struts.action.Action"
        classpath="${struts.jar}" />
  +    <available property="jstl.present" 
  +     classname="org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager"
  +     classpath="${taglibs-standard.jar}" />
       <available property="jndi.present"
        classname="javax.naming.Context"
        classpath="${jndi.jar}" />
  @@ -383,6 +390,7 @@
       <echo message="naming.present (optional) = ${naming.present}" />
       <echo message="resources.present (optional) = ${resources.present}" />
       <echo message="struts.present (optional) = ${struts.present}" />
  +    <echo message="jstl.present (optional) = ${jstl.present}" />
       <echo message="jdbc-ext.present (optional) = ${jdbc-ext.present}" />
   
       <echo message="--- Property values" />
  @@ -405,6 +413,7 @@
       <echo message="commons-httpclient.jar=${commons-httpclient.jar}" />
       <echo message="tomcat.build=${tomcat.build}" />
       <echo message="struts.jar=${struts.jar}" />
  +    <echo message="taglibs-standard.jar=${taglibs-standard.jar}" />
       <echo message="slide.build=${slide.build}" />
       <echo message="slide.dist=${slide.dist}" />
       <echo message="webapp.dist=${webapp.dist}" />
  @@ -1024,20 +1033,20 @@
     <target name="taglib-prepare" depends="prepare,main">
       <mkdir dir="${slide.build}/doc/taglib-javadoc"/>
     </target>
  -
  +  
     <!-- Build common tag library classes -->
     <target name="taglib-common-compile" depends="taglib-prepare">
       <echo message="Compiling common tag library classes..." />
       <javac srcdir="src/taglib/common"
        destdir="${slide.build}/classes"
  -     debug="${compile.debug}"
  +     debug="${compile.debug}" 
        deprecation="${compile.deprecation}"
        optimize="${compile.optimize}"
        excludes="**/CVS/**,**/package.html">
         <classpath refid="taglib.classpath"/>
       </javac>
     </target>
  -
  +  
     <!-- Build common tag library classes JAR file -->
     <target name="taglib-common-jar"
      depends="prepare-dist,taglib-common-compile">
  @@ -1052,21 +1061,55 @@
        includes="**/taglib/bean/*.*,**/taglib/tag/*.*"
        excludes="**/struts/**"/>
     </target>
  -
  +  
  +  <!-- Build JSTL based tag library classes -->
  +  <target name="taglib-jstl-compile"
  +   depends="taglib-common-compile"
  +   if="jstl.present">
  +    <echo message="Compiling JSTL based tag library classes..." />
  +    <javac srcdir="src/taglib/jstl"
  +     destdir="${slide.build}/classes"
  +     debug="${compile.debug}"
  +     deprecation="${compile.deprecation}"
  +     optimize="${compile.optimize}"
  +     excludes="**/CVS/**,**/package.html">
  +      <classpath refid="taglib.classpath"/>
  +    </javac>
  +  </target>
  +  
  +  <!-- Make JSTL based tag library distribution -->
  +  <target name="taglib-jstl-jar"
  +   depends="prepare-dist,taglib-jstl-compile"
  +   if="jstl.present">
  +    <echo message="Building the JSTL based tag library JAR..." />
  +    <copy file="src/etc/MANIFEST.MF"
  +     tofile="${slide.build}/classes/MANIFEST.MF" />
  +    <replace  file="${slide.build}/classes/MANIFEST.MF"
  +     token="$$VERSION$$" value="${version}" />
  +    <jar jarfile="${slide.dist}/slide/lib/slide-taglib-jstl.jar"
  +     basedir="${slide.build}/classes"
  +     manifest="${slide.build}/classes/MANIFEST.MF"
  +     includes="**/taglib/tag/jstl/*.*"
  +     excludes="**/bean/*.*,**/tag/*.*,**/struts/*.*">
  +      <metainf dir="src/taglib"
  +       includes="slide-jstl.tld"/>
  +    </jar>
  +  </target>
  +  
     <!-- Build Struts based tag library classes -->
     <target name="taglib-struts-compile" depends="taglib-common-compile"
      if="struts.present">
       <echo message="Compiling Struts based tag library classes..." />
       <javac srcdir="src/taglib/struts"
        destdir="${slide.build}/classes"
  -     debug="${compile.debug}"
  +     debug="${compile.debug}" 
        deprecation="${compile.deprecation}"
        optimize="${compile.optimize}"
        excludes="**/CVS/**,**/package.html">
         <classpath refid="taglib.classpath"/>
       </javac>
     </target>
  -
  +  
     <!-- Make Struts based tag library distribution -->
     <target name="taglib-struts-jar"
      depends="prepare-dist,taglib-struts-compile"
  @@ -1080,12 +1123,12 @@
        basedir="${slide.build}/classes"
        manifest="${slide.build}/classes/MANIFEST.MF"
        includes="**/taglib/tag/struts/*.*"
  -     excludes="**/bean/*.*,**/tag/*.*">
  +     excludes="**/bean/*.*,**/tag/*.*,**/jstl/*.*">
         <metainf dir="src/taglib"
          includes="slide-struts.tld"/>
       </jar>
     </target>
  -
  +  
     <!-- Generate JavaDocs for the tag library components -->
     <target name="taglib-javadoc" unless="skip.javadoc"
      description="Generate API docs for the Slide tag library"
  @@ -1093,21 +1136,23 @@
       <echo message="Generating the tag libraries API documentation..." />
       <property name="copyright" value="" />
       <javadoc destdir="${slide.build}/doc/taglib-javadoc"
  -     doctitle="Slide ${version} Tag Library API Documentation"
  +     doctitle="Slide ${version} Tag Library API Documentation" 
        windowtitle="Slide ${version} Tag Library API Documentation"
        package="true" noindex="false" author="true" version="true"
        packagenames="org.apache.slide.taglib.*">
         <sourcepath>
           <pathelement location="src/taglib/common"/>
  +        <pathelement location="src/taglib/jstl"/>
           <pathelement location="src/taglib/struts"/>
  +        <pathelement location="src/taglib/jstl"/>
         </sourcepath>
         <classpath refid="taglib.classpath"/>
       </javadoc>
     </target>
  -
  +  
     <!-- Make tag libraries distribution -->
     <target name="taglib-dist"
  -   depends="taglib-common-jar,taglib-struts-jar,taglib-javadoc"
  +   depends="taglib-common-jar,taglib-jstl-jar,taglib-struts-jar,taglib-javadoc"
      description="Build the Slide tag library JARs">
       <copy todir="${slide.dist}/doc/taglib-javadoc">
         <fileset dir="${slide.build}/doc/taglib-javadoc" />
  
  
  
  1.1                  jakarta-slide/src/taglib/slide-jstl.tld
  
  Index: slide-jstl.tld
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd";>
  
  <taglib>
    
    <tlibversion>1.0</tlibversion>
    <jspversion>1.2</jspversion>
    <shortname>slide-jstl</shortname>
    <uri>http://jakarta.apache.org/slide/tags-jstl-1.0</uri>
    <info>
      JSTL (EA3) based JSP Tag Library for Jakarta Slide
    </info>
    
    <!-- The 'domain' Tag -->
    <tag>
     <name>domain</name>
     <tagclass>org.apache.slide.taglib.tag.jstl.DomainTag</tagclass>
     <bodycontent>JSP</bodycontent>
     <attribute>
      <name>var</name>
      <required>true</required>
     </attribute>
    </tag>
    
    <!-- The 'namespace' Tag -->
    <tag>
     <name>namespace</name>
     <tagclass>org.apache.slide.taglib.tag.jstl.NamespaceTag</tagclass>
     <bodycontent>JSP</bodycontent>
     <attribute>
      <name>name</name>
      <required>false</required>
     </attribute>
     <attribute>
      <name>var</name>
      <required>false</required>
     </attribute>
    </tag>
    
    <!-- The 'node' Tag -->
    <tag>
     <name>node</name>
     <tagclass>org.apache.slide.taglib.tag.jstl.NodeTag</tagclass>
     <bodycontent>JSP</bodycontent>
     <attribute>
      <name>uri</name>
      <required>true</required>
     </attribute>
     <attribute>
      <name>resolveLinks</name>
      <required>false</required>
     </attribute>
     <attribute>
      <name>var</name>
      <required>false</required>
     </attribute>
    </tag>
    
    <!-- The 'revision' Tag -->
    <tag>
     <name>revision</name>
     <tagclass>org.apache.slide.taglib.tag.jstl.RevisionTag</tagclass>
     <bodycontent>JSP</bodycontent>
     <attribute>
      <name>number</name>
      <required>false</required>
     </attribute>
     <attribute>
      <name>branch</name>
      <required>false</required>
     </attribute>
     <attribute>
      <name>var</name>
      <required>false</required>
     </attribute>
    </tag>
    
    <!-- The 'property' Tag -->
    <tag>
     <name>property</name>
     <tagclass>org.apache.slide.taglib.tag.jstl.PropertyTag</tagclass>
     <bodycontent>JSP</bodycontent>
     <attribute>
      <name>namespace</name>
      <required>false</required>
     </attribute>
     <attribute>
      <name>name</name>
      <required>true</required>
     </attribute>
     <attribute>
      <name>var</name>
      <required>false</required>
     </attribute>
    </tag>
    
  </taglib>
  
  
  
  1.1                  
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/DomainTag.java
  
  Index: DomainTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/DomainTag.java,v
 1.1 2002/01/27 15:46:37 cmlenz Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/27 15:46:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.slide.taglib.tag.jstl;
  
  import java.security.Principal;
  
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  
  import org.apache.slide.taglib.bean.DomainBean;
  import org.apache.slide.taglib.tag.DomainTagSupport;
  
  /**
   * Tag class that represents the Slide domain in a JSTL context. This class 
   * extends 
   * {@link org.apache.slide.taglib.tag.DomainTagSupport DomainTagSupport} only 
   * to provide a setter method for the attribute name the domain bean should be 
   * stored under, using the 'var' tag attribute.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christopher Lenz</a>
   * @version $Revision: 1.1 $
   */
  public class DomainTag
      extends DomainTagSupport {
      
      
      // ------------------------------------------------------------ Tag Methods
      
      
      /**
       * Called by the JSP Engine when opening this tag.
       *
       * @throws JspException not thrown
       */
      public int doStartTag()
          throws JspException {
          
          // this util method will create the DomainBean if we're not already
          // nested in another DomainTag
          domain = JstlTagUtils.findDomain(this, pageContext);
          
          return super.doStartTag();
      }
      
      
      // --------------------------------------------------------- Public Methods
      
      
      /**
       * Returns the 'var' attribute.
       *
       * @return value of the 'var' attribute
       */
      public String getVar() {
          
          return attrName;
      }
      
      
      /**
       * Sets the 'var' attribute.
       *
       * @param id the attribute value
       */
      public void setVar(String var) {
          
          attrName = var;
      }
      
      
  }
  
  
  
  
  1.1                  
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/JstlTagUtils.java
  
  Index: JstlTagUtils.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/JstlTagUtils.java,v
 1.1 2002/01/27 15:46:37 cmlenz Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/27 15:46:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.slide.taglib.tag.jstl;
  
  import java.security.Principal;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  import javax.servlet.jsp.tagext.Tag;
  import javax.servlet.jsp.jstl.core.ExpressionException;
  import javax.servlet.jsp.jstl.core.IteratorTag;
  
  import org.apache.slide.authenticate.CredentialsToken;
  import org.apache.slide.authenticate.SecurityToken;
  import org.apache.slide.common.Domain;
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.common.SlideToken;
  import org.apache.slide.common.SlideTokenImpl;
  import org.apache.slide.taglib.bean.*;
  import org.apache.slide.taglib.tag.*;
  import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
  import org.apache.taglibs.standard.tag.common.core.NullAttributeException;
  
  /**
   * Contains static methods to locate beans in the JSP page context that 
   * represent certain Slide objects. These methods closely cooperate with the
   * JSP standard tag library, especially the <code>&lt;c:forEach&gt;</code> 
   * tag.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christopher Lenz</a>
   * @version $Revision: 1.1 $
   */
  public class JstlTagUtils {
      
      
      // -------------------------------------------------- Public Static Methods
      
      
      /**
       * Use the JSTL expression evaluation mechanisms to evaluate an optional 
       * attribute. If the expression evaluates to <code>null</code> or the 
       * evaluation fails, this method returns <code>null</code>.
       */
      public static Object evaluateOptionalAttribute(String tagName,
                                                     String attributeName,
                                                     String expression,
                                                     Class expectedType, Tag tag,
                                                     PageContext pageContext)
          throws JspException {
          
          Object result = null;
          try {
              result =
                  ExpressionEvaluatorManager.evaluate(attributeName, expression,
                                                      expectedType, tag,
                                                      pageContext);
          } catch (ExpressionException e) {
              // ignore, the attribute is optional
          }
          
          return result;
      }
      
      
      /**
       * Use the JSTL expression evaluation mechanisms to evaluate a required 
       * attribute. If the expression evaluates to <code>null</code> or the 
       * evaluation fails, this method throws a JspException.
       */
      public static Object evaluateRequiredAttribute(String tagName,
                                                     String attributeName,
                                                     String expression,
                                                     Class expectedType, Tag tag,
                                                     PageContext pageContext)
          throws JspException {
          
          Object result = 
              ExpressionEvaluatorManager.evaluate(attributeName, expression,
                                                  expectedType, tag,
                                                  pageContext);
          if (result == null) {
              throw new NullAttributeException(tagName, attributeName);
          }
          
          return result;
      }
      
      
      /**
       * Locate the closest DomainBean up the tag hierarchy, or create one if 
       * none was found.
       */
      public static DomainBean findDomain(Tag from, PageContext context)
          throws JspException {
          
          DomainBean bean = null;
          
          // look for the closest NamespaceTagSupport or IterateTag up the tag 
          // hierarchy
          Tag tag = from.getParent();
          while (tag != null) {
              if (tag instanceof DomainTagSupport) {
                  return ((DomainTagSupport)tag).getDomain();
              }
              tag = tag.getParent();
          }
          
          // create a new domain bean
          HttpServletRequest request =
              (HttpServletRequest)context.getRequest();
          Principal principal = request.getUserPrincipal();
          CredentialsToken credentials;
          if (principal == null) {
              credentials = new CredentialsToken("");
          } else {
              credentials = new CredentialsToken(principal);
          }
          SlideToken st = new SlideTokenImpl(credentials);
          return new DomainBean(st);
      }
      
      
      /**
       * Locate the closest NamespaceBean up the tag hierarchy, or use the 
       * default namespace if none was found.
       */
      public static NamespaceBean findNamespace(Tag from, PageContext context)
          throws JspException {
          
          NamespaceBean bean = null;
          
          // look for the closest NamespaceTagSupport or IterateTag up the tag 
          // hierarchy
          Tag tag = from.getParent();
          while (tag != null) {
              if (tag instanceof NamespaceTagSupport) {
                  bean = ((NamespaceTagSupport)tag).getNamespace();
              } else if (tag instanceof IteratorTag) {
                  // check whether we're actually iterating over NamespaceBean
                  // objects
                  Object object = ((IteratorTag)tag).getCurrent();
                  if (object instanceof NamespaceBean) {
                      bean = (NamespaceBean)object;
                  }
              }
              if (bean != null) {
                  return bean;
              }
              tag = tag.getParent();
          }
          
          // not nested in a namespace tag, so return either:
          // - the namespace specified as context parameter or
          // - the default namespace
          DomainBean domain = findDomain(from, context);
          if (domain != null) {
              String namespaceName = 
                  (String) context.getServletContext().getAttribute
                  ("org.apache.slide.NamespaceName");
              if (namespaceName == null) {
                  namespaceName =
                      context.getServletContext().getInitParameter("namespace");
              }
              if (namespaceName != null) {
                  bean = domain.getNamespace(namespaceName);
              } else {
                  bean = domain.getDefaultNamespace();
              }
          }
          
          return bean;
      }
      
      
      /**
       * Locate the closest NodeBean up the tag hierarchy. If no NodeBean can be
       * found, return <code>null</code>.
       */
      public static NodeBean findNode(Tag from, PageContext context)
          throws JspException {
          
          NodeBean bean = null;
          
          // look for the closest NodeTagSupport or IterateTag up the tag 
          // hierarchy
          Tag tag = from.getParent();
          while (tag != null) {
              if (tag instanceof NodeTagSupport) {
                  bean = ((NodeTagSupport)tag).getNode();
              } else if (tag instanceof IteratorTag) {
                  // check whether we're actually iterating over NamespaceBean
                  // objects
                  Object object = ((IteratorTag)tag).getCurrent();
                  if (object instanceof NodeBean) {
                      bean = (NodeBean)object;
                  }
              }
              if (bean != null) {
                  return bean;
              }
              tag = tag.getParent();
          }
          
          return bean;
      }
      
      
      /**
       * Locate the closest RevisionBean up the tag hierarchy. If no RevisionBean
       * can be found, return <code>null</code>.
       */
      public static RevisionBean findRevision(Tag from, PageContext context)
          throws JspException {
          
          RevisionBean bean = null;
          
          // look for the closest RevisionTagSupport or IterateTag up the tag 
          // hierarchy
          Tag tag = from.getParent();
          while (tag != null) {
              if (tag instanceof RevisionTagSupport) {
                  bean = ((RevisionTagSupport)tag).getRevision();
              } else if (tag instanceof NodeTagSupport) {
                  bean = ((NodeTagSupport)tag).getNode().getLatestRevision();
              } else if (tag instanceof IteratorTag) {
                  // check whether we're actually iterating over RevisionBean
                  // or NodeBean objects
                  Object object = ((IteratorTag)tag).getCurrent();
                  if (object instanceof RevisionBean) {
                      bean = (RevisionBean)object;
                  } else if (object instanceof NodeBean) {
                      bean = ((NodeBean)object).getLatestRevision();
                  }
              }
              if (bean != null) {
                  return bean;
              }
              tag = tag.getParent();
          }
          
          return bean;
      }
      
      
  }
  
  
  
  
  1.1                  
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/NamespaceTag.java
  
  Index: NamespaceTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/NamespaceTag.java,v
 1.1 2002/01/27 15:46:37 cmlenz Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/27 15:46:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.slide.taglib.tag.jstl;
  
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  
  import org.apache.slide.taglib.bean.DomainBean;
  import org.apache.slide.taglib.bean.NamespaceBean;
  import org.apache.slide.taglib.tag.NamespaceTagSupport;
  
  /**
   * Tag class for tags that represent a Slide namespace.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christopher Lenz</a>
   * @version $Revision: 1.1 $
   */
  public class NamespaceTag
      extends NamespaceTagSupport {
      
      
      // ----------------------------------------------------------- Construction
      
      
      /**
       * Initialize inherited and local state.
       */
      public NamespaceTag() {
          super();
          
          init();
      }
      
      
      // ------------------------------------------------------------ Tag Methods
      
      
      /**
       * Called by the JSP Engine when opening this tag.
       *
       * @throws JspException not thrown
       */
      public int doStartTag()
          throws JspException {
          
          // evaluate the 'name' attribute
          String evalName = (String)
              JstlTagUtils.evaluateOptionalAttribute("namespace", "name", name, 
                                                     String.class, this,
                                                     pageContext);
          
          if (evalName != null) {
              // if the name attribute was set, look for a corresponding 
              // namespace
              DomainBean domain = JstlTagUtils.findDomain(this, pageContext);
              namespace = getNamespace(domain, evalName);
          } else {
              // use the default namespace, if available
              namespace = JstlTagUtils.findNamespace(this, pageContext);
          }
          
          return super.doStartTag();
      }
      
      
      /**
       * Releases any resources we may have (or inherit).
       */
      public void release() {
          super.release();
          
          init();
      }
      
      
      // ------------------------------------------------------------- Properties
      
      
      /**
       * Returns the 'var' attribute.
       *
       * @return value of the 'var' attribute
       */
      public String getVar() {
          
          return attrName;
      }
      
      
      /**
       * Sets the 'var' attribute.
       *
       * @param var the attribute value
       */
      public void setVar(String var) {
          
          attrName = var;
      }
      
      
      // -------------------------------------------------------- Private Methods
      
      
      /**
       * Reset internal state.
       */
      private void init() {
          
          // nothing to reset as of yet
      }
      
      
  }
  
  
  
  
  1.1                  
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/NodeTag.java
  
  Index: NodeTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/NodeTag.java,v
 1.1 2002/01/27 15:46:37 cmlenz Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/27 15:46:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.slide.taglib.tag.jstl;
  
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  
  import org.apache.slide.common.SlideException;
  import org.apache.slide.taglib.bean.NamespaceBean;
  import org.apache.slide.taglib.bean.NodeBean;
  import org.apache.slide.taglib.tag.NodeTagSupport;
  
  
  /**
   * Tag class for tags that represent a particular node in a Slide namespace.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christopher Lenz</a>
   * @version $Revision: 1.1 $
   */
  public class NodeTag
      extends NodeTagSupport {
      
      
      // ------------------------------------------------------------ Tag Methods
      
      
      /**
       * Called by the JSP Engine when opening this tag.
       *
       * @throws JspException not thrown
       */
      public int doStartTag()
          throws JspException {
          
          // evaluate the 'uri' attribute
          String evalUri = (String)
              JstlTagUtils.evaluateRequiredAttribute("node", "uri", uri,
                                                     String.class, this,
                                                     pageContext);
          
          // evaluate the 'resolveLinks' attribute
          Boolean evalResolveLinks = (Boolean)
              JstlTagUtils.evaluateOptionalAttribute("node", "resolveLinks",
                                                     resolveLinks, Boolean.class,
                                                     this, pageContext);
          
          // we trust the 'uri' attribute to be != null, because it is specified
          // as required attribute in the TLD
          NamespaceBean namespace = 
              JstlTagUtils.findNamespace(this, pageContext);
          node = getNode(namespace, evalUri, evalResolveLinks != null ? 
                                             evalResolveLinks.booleanValue() : 
                                             true);
          
          return super.doStartTag();
      }
      
      
      // --------------------------------------------------------- Public Methods
      
      
      /**
       * Returns the 'var' attribute.
       *
       * @return value of the 'var' attribute
       */
      public String getVar() {
          
          return attrName;
      }
      
      
      /**
       * Set the 'var' attribute.
       *
       * @param var the attribute value
       */
      public void setVar(String var) {
          
          attrName = var;
      }
      
      
  }
  
  
  
  
  1.1                  
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/PropertyTag.java
  
  Index: PropertyTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/PropertyTag.java,v
 1.1 2002/01/27 15:46:37 cmlenz Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/27 15:46:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.slide.taglib.tag.jstl;
  
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  
  import org.apache.slide.taglib.bean.PropertyBean;
  import org.apache.slide.taglib.bean.RevisionBean;
  import org.apache.slide.taglib.tag.PropertyTagSupport;
  
  
  /**
   * Tag class for tags that represent a node property.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christopher Lenz</a>
   * @version $Revision: 1.1 $
   */
  public class PropertyTag
      extends PropertyTagSupport {
      
      
      // ------------------------------------------------------------ Tag Methods
      
      
      /**
       * Called by the JSP Engine when opening this tag.
       *
       * @throws JspException not thrown
       */
      public int doStartTag()
          throws JspException {
          super.doStartTag();
          
          // evaluate the 'name' attribute
          String evalName = (String)
              JstlTagUtils.evaluateRequiredAttribute("property", "name",
                                                     name, String.class, this,
                                                     pageContext);
          
          // evaluate the 'namespace' attribute
          String evalNamespace = (String)
              JstlTagUtils.evaluateRequiredAttribute("property", "namespace",
                                                     namespace, String.class,
                                                     this, pageContext);
          
          RevisionBean revision = JstlTagUtils.findRevision(this, pageContext);
          property = getProperty(revision, evalName, evalNamespace);
          
          return super.doStartTag();
      }
      
      
      // --------------------------------------------------------- Public Methods
      
      
      /**
       * Returns the 'var' attribute.
       *
       * @return value of the 'var' attribute
       */
      public String getVar() {
          
          return attrName;
      }
      
      
      /**
       * Set the 'var' attribute.
       *
       * @param var the attribute value
       */
      public void setVar(String var) {
          
          attrName = var;
      }
      
      
  }
  
  
  
  
  1.1                  
jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/RevisionTag.java
  
  Index: RevisionTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/taglib/jstl/org/apache/slide/taglib/tag/jstl/RevisionTag.java,v
 1.1 2002/01/27 15:46:37 cmlenz Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/27 15:46:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.slide.taglib.tag.jstl;
  
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  
  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;
  
  
  /**
   * Tag class for tags that represent a revision of a node.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christopher Lenz</a>
   * @version $Revision: 1.1 $
   */
  public class RevisionTag
      extends RevisionTagSupport {
      
      
      // ------------------------------------------------------------ Tag Methods
      
      
      /**
       * Called by the JSP Engine when opening this tag.
       *
       * @throws JspException if the 'number' attribute does not contain a 
       *         version number in a valid format
       */
      public int doStartTag()
          throws JspException {
          
          // evaluate the 'number' attribute
          String evalNumber = (String)
              JstlTagUtils.evaluateOptionalAttribute("revision", "number",
                                                     number, String.class, this,
                                                     pageContext);
          
          // evaluate the 'branch' attribute
          String evalBranch = (String)
              JstlTagUtils.evaluateOptionalAttribute("revision", "branch",
                                                     branch, String.class, this,
                                                     pageContext);
          
          // if neither revision number nor branch name have been specified,
          // first check whether we're inside an iteration over revisions
          NodeRevisionNumber nrn = null;
          if (evalNumber != null) {
              try {
                  nrn = new NodeRevisionNumber(evalNumber);
              }
              catch (NumberFormatException e) {
                  throw new JspException("The attribute 'number' of " +
                      "the 'revision' tag contains an invalid version " +
                      "number.");
              }
          }
          
          NodeBean node = JstlTagUtils.findNode(this, pageContext);
          revision = getRevision(node, nrn, evalBranch);
          
          return super.doStartTag();
      }
      
      
      // --------------------------------------------------------- Public Methods
      
      
      /**
       * Returns the 'var' attribute.
       *
       * @return value of the 'var' attribute
       */
      public String getVar() {
          
          return attrName;
      }
      
      
      /**
       * Set the 'var' attribute.
       *
       * @param var the attribute value
       */
      public void setVar(String var) {
          
          attrName = var;
      }
      
      
  }
  
  
  
  

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

Reply via email to