struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/bean PageTag.java PageTei.java StrutsTag.java StrutsTei.java LocalStrings.properties
Date Sun, 08 Oct 2000 00:40:50 GMT
craigmcc    00/10/07 17:40:49

  Modified:    src/doc  release.xml struts-bean.xml
               src/share/org/apache/struts/taglib/bean
                        LocalStrings.properties
  Added:       src/share/org/apache/struts/taglib/bean PageTag.java
                        PageTei.java StrutsTag.java StrutsTei.java
  Log:
  Add two new tags to the struts-bean library that expose interesting items
  from the page context, and Struts internal configuration objects, as beans
  (and scripting variables) that can be accessed through the remainder of
  the current page.
  
  Inspired by suggestions from Pierre Metras <genepi@sympatico.ca> to expose
  the "path" property of an ActionForward object so that it can be used in
  JavaScript to construct a new URL dynamically.
  
  Revision  Changes    Path
  1.4       +24 -0     jakarta-struts/src/doc/release.xml
  
  Index: release.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/release.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- release.xml	2000/10/07 22:55:13	1.3
  +++ release.xml	2000/10/08 00:40:48	1.4
  @@ -48,6 +48,30 @@
         very useful during development.</li>
     </ul>
   
  +  <p>The following major new features have been added to the
  +  <em>struts-bean</em> custom tag library (package
  +  <code>org.apache.struts.taglib.bean</code>):</p>
  +  <ul>
  +  <li>A new custom tag, <code>&lt;struts-bean:page&gt;</code>,
is available
  +      to expose key items from the page context associated with the current
  +      page as scripting variables, and as page-scope beans.  For example,
  +      you can use the following sequence to render the server information
  +      string returned by our servlet context:
  +      <pre>
  +      &lt;struts-bean:page id="app" property="application"/&gt;
  +      &lt;struts-bean:write name="app" property="serverInfo"/&gt;
  +      </pre></li>
  +  <li>A new custom tag, <code>&lt;struts-bean:struts&gt;</code>,
is available
  +      to expose internal Struts configuration objects (form bean, forward,
  +      and mapping definitions) as scripting variables and page-scope beans.
  +      For example, you can use the following sequence to render the actual
  +      context-relative path of an <code>ActionForward</code> object:
  +      <pre>
  +      &lt;struts-bean:struts id="link" forward="success"/&gt;
  +      &lt;struts-bean:write name="link" property="path"/&gt;
  +      </pre></li>
  +  </ul>
  +
     </section>
   
   
  
  
  
  1.5       +109 -0    jakarta-struts/src/doc/struts-bean.xml
  
  Index: struts-bean.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/struts-bean.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- struts-bean.xml	2000/09/07 01:37:26	1.4
  +++ struts-bean.xml	2000/10/08 00:40:48	1.5
  @@ -272,6 +272,50 @@
   
     <tag>
   
  +    <name>page</name>
  +    <summary>
  +    Expose a specified item from the page context as a bean.
  +    </summary>
  +    <tagclass>org.apache.struts.taglib.bean.PageTag</tagclass>
  +    <teiclass>org.apache.struts.taglib.bean.PageTei</teiclass>
  +    <bodycontent>empty</bodycontent>
  +    <info>
  +    <p>Retrieve the value of the specified item from the page context
  +    for this page, and define it as a scripting variable, and a page scope
  +    attribute accessible to the remainder of the current page.</p>
  +
  +    <p>If a problem occurs while retrieving the specified configuration
  +    object, a request time exception will be thrown.</p>
  +    </info>
  +
  +    <attribute>
  +      <name>id</name>
  +      <required>true</required>
  +      <rtexprvalue>false</rtexprvalue>
  +      <info>
  +      <p>Specifies the name of the scripting variable (and associated
  +      page scope attribute) that will be made available with the value of
  +      the specified page context property.</p>
  +      </info>
  +    </attribute>
  +
  +    <attribute>
  +      <name>property</name>
  +      <required>true</required>
  +      <rtexprvalue>true</rtexprvalue>
  +      <info>
  +      <p>Name of the property from our page context to be retrieved and
  +      exposed.  Must be one of <code>application</code>, <code>config</code>,
  +      <code>request</code>, <code>response</code>, or <code>session</code>.
  +      </p>
  +      </info>
  +    </attribute>
  +
  +  </tag>
  +
  +
  +  <tag>
  +
       <name>parameter</name>
       <summary>
       Define a scripting variable based on the value(s) of the specified
  @@ -377,6 +421,71 @@
         <info>
         <p>Context-relative name (starting with a '/') of the web application
         resource to be loaded and made available.</p>
  +      </info>
  +    </attribute>
  +
  +  </tag>
  +
  +
  +  <tag>
  +
  +    <name>struts</name>
  +    <summary>
  +    Expose a named Struts internal configuration object as a bean.
  +    </summary>
  +    <tagclass>org.apache.struts.taglib.bean.StrutsTag</tagclass>
  +    <teiclass>org.apache.struts.taglib.bean.StrutsTei</teiclass>
  +    <bodycontent>empty</bodycontent>
  +    <info>
  +    <p>Retrieve the value of the specified Struts internal configuration
  +    object, and define it as a scripting variable and as a page scope
  +    attribute accessible to the remainder of the current page.  You must
  +    specify exactly one of the <code>formBean</code>, <code>forward</code>,
  +    and <code>mapping</code> attributes to select the configuration object
  +    to be exposed.</p>
  +
  +    <p>If a problem occurs while retrieving the specified configuration
  +    object, a request time exception will be thrown.</p>
  +    </info>
  +
  +    <attribute>
  +      <name>id</name>
  +      <required>true</required>
  +      <rtexprvalue>false</rtexprvalue>
  +      <info>
  +      <p>Specifies the name of the scripting variable (and associated
  +      page scope attribute) that will be made available with the value of
  +      the specified Struts internal configuration object.</p>
  +      </info>
  +    </attribute>
  +
  +    <attribute>
  +      <name>formBean</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +      <info>
  +      <p>Specifies the name of the Struts <code>ActionFormBean</code>
  +      definition object to be exposed.</p>
  +      </info>
  +    </attribute>
  +
  +    <attribute>
  +      <name>forward</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +      <info>
  +      <p>Specifies the name of the global Struts <code>ActionForward</code>
  +      definition object to be exposed.</p>
  +      </info>
  +    </attribute>
  +
  +    <attribute>
  +      <name>mapping</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +      <info>
  +      <p>Specifies the matching path of the Struts <code>ActionMapping</code>
  +      definition object to be exposed.</p>
         </info>
       </attribute>
   
  
  
  
  1.6       +3 -0      jakarta-struts/src/share/org/apache/struts/taglib/bean/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/LocalStrings.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocalStrings.properties	2000/09/05 21:25:45	1.5
  +++ LocalStrings.properties	2000/10/08 00:40:48	1.6
  @@ -12,3 +12,6 @@
   include.format=Context relative name {0} must start with a '/' character
   include.open=Exception opening resource {0}: {1}
   include.read=Exception reading resource {0}: {1}
  +page.selector=Invalid page context selector {0}
  +struts.missing=No Struts internal object named {0} is available
  +struts.selector=You must specify exactly one of formBean, forward, and mapping
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/bean/PageTag.java
  
  Index: PageTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/PageTag.java,v
1.1 2000/10/08 00:40:49 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 00:40:49 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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/>.
   *
   */
  
  
  package org.apache.struts.taglib.bean;
  
  
  import java.io.IOException;
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  import javax.servlet.jsp.tagext.TagSupport;
  import org.apache.struts.util.BeanUtils;
  import org.apache.struts.util.MessageResources;
  import org.apache.struts.util.PropertyUtils;
  
  
  /**
   * Define a scripting variable that exposes the requested page context
   * item as a scripting variable and a page scope bean.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/08 00:40:49 $
   */
  
  public final class PageTag extends TagSupport {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The name of the scripting variable that will be exposed as a page
       * scope attribute.
       */
      private String id = null;
  
      public String getId() {
          return (this.id);
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
  
      /**
       * The message resources for this package.
       */
      private static MessageResources messages =
          MessageResources.getMessageResources
          ("org.apache.struts.taglib.bean.LocalStrings");
  
  
      /**
       * The name of the page context property to be retrieved.
       */
      private String property = null;
  
      public String getProperty() {
          return (this.property);
      }
  
      public void setProperty(String property) {
          this.property = property;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Retrieve the required configuration object and expose it as a
       * scripting variable.
       *
       * @exception JspException if a JSP exception has occurred
       */
      public int doStartTag() throws JspException {
  
          // Retrieve the requested object to be exposed
          Object object = null;
          if ("application".equalsIgnoreCase(property))
              object = pageContext.getServletContext();
          else if ("config".equalsIgnoreCase(property))
              object = pageContext.getServletConfig();
          else if ("request".equalsIgnoreCase(property))
              object = pageContext.getRequest();
          else if ("response".equalsIgnoreCase(property))
              object = pageContext.getResponse();
          else if ("session".equalsIgnoreCase(property))
              object = pageContext.getSession();
          else
              throw new JspException
                  (messages.getMessage("page.selector", property));
  
          // Expose this value as a scripting variable
          pageContext.setAttribute(id, object);
          return (SKIP_BODY);
  
      }
  
  
      /**
       * Reset custom attributes to their default values.
       */
      public void releaseCustomAttributes() {
  
          id = null;
          property = null;
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/bean/PageTei.java
  
  Index: PageTei.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/PageTei.java,v
1.1 2000/10/08 00:40:49 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 00:40:49 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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/>.
   *
   */
  
  
  package org.apache.struts.taglib.bean;
  
  
  import javax.servlet.jsp.tagext.TagData;
  import javax.servlet.jsp.tagext.TagExtraInfo;
  import javax.servlet.jsp.tagext.VariableInfo;
  
  
  /**
   * Implementation of <code>TagExtraInfo</code> for the <b>page</b>
   * tag, identifying the scripting object(s) to be made visible.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/08 00:40:49 $
   */
  
  public final class PageTei extends TagExtraInfo {
  
  
      /**
       * Return information about the scripting variables to be created.
       */
      public VariableInfo[] getVariableInfo(TagData data) {
  
          String type = null;
          String property = data.getAttributeString("property");
          if ("application".equalsIgnoreCase(property))
              type = "javax.servlet.ServletContext";
          else if ("config".equalsIgnoreCase(property))
              type = "javax.servlet.ServletConfig";
          else if ("request".equalsIgnoreCase(property))
              type = "javax.servlet.ServletRequest";
          else if ("response".equalsIgnoreCase(property))
              type = "javax.servlet.ServletResponse";
          else if ("session".equalsIgnoreCase(property))
              type = "javax.servlet.http.HttpSession";
          else
              type = "java.lang.Object";
  
  	return new VariableInfo[] {
  	  new VariableInfo(data.getAttributeString("id"),
  	                   type,
  	                   true,
  	                   VariableInfo.AT_BEGIN)
  	};
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/bean/StrutsTag.java
  
  Index: StrutsTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/StrutsTag.java,v
1.1 2000/10/08 00:40:49 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 00:40:49 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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/>.
   *
   */
  
  
  package org.apache.struts.taglib.bean;
  
  
  import java.io.IOException;
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  import javax.servlet.jsp.tagext.TagSupport;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionFormBeans;
  import org.apache.struts.action.ActionForwards;
  import org.apache.struts.action.ActionMappings;
  import org.apache.struts.util.BeanUtils;
  import org.apache.struts.util.MessageResources;
  import org.apache.struts.util.PropertyUtils;
  
  
  /**
   * Define a scripting variable that exposes the requested Struts
   * internal configuraton object.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/08 00:40:49 $
   */
  
  public final class StrutsTag extends TagSupport {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The name of the scripting variable that will be exposed as a page
       * scope attribute.
       */
      private String id = null;
  
      public String getId() {
          return (this.id);
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
  
      /**
       * The message resources for this package.
       */
      private static MessageResources messages =
          MessageResources.getMessageResources
          ("org.apache.struts.taglib.bean.LocalStrings");
  
  
      /**
       * The name of the <code>ActionFormBean</code> object to be exposed.
       */
      private String formBean = null;
  
      public String getFormBean() {
          return (this.formBean);
      }
  
      public void setFormBean(String formBean) {
          this.formBean = formBean;
      }
  
  
      /**
       * The name of the <code>ActionForward</code> object to be exposed.
       */
      private String forward = null;
  
      public String getForward() {
          return (this.forward);
      }
  
      public void setForward(String forward) {
          this.forward = forward;
      }
  
  
      /**
       * The name of the <code>ActionMapping</code> object to be exposed.
       */
      private String mapping = null;
  
      public String getMapping() {
          return (this.mapping);
      }
  
      public void setMapping(String mapping) {
          this.mapping = mapping;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Retrieve the required configuration object and expose it as a
       * scripting variable.
       *
       * @exception JspException if a JSP exception has occurred
       */
      public int doStartTag() throws JspException {
  
          // Validate the selector arguments
          int n = 0;
          if (formBean != null)
              n++;
          if (forward != null)
              n++;
          if (mapping != null)
              n++;
          if (n != 1)
              throw new JspException
                  (messages.getMessage("struts.selector"));
  
          // Retrieve the requested object to be exposed
          Object object = null;
          String selector = null;
          if (formBean != null) {
              selector = formBean;
              ActionFormBeans collection = (ActionFormBeans)
                  pageContext.getAttribute(Action.FORM_BEANS_KEY);
              if (collection != null)
                  object = collection.findFormBean(formBean);
          } else if (forward != null) {
              selector = forward;
              ActionForwards collection = (ActionForwards)
                  pageContext.getAttribute(Action.FORWARDS_KEY);
              if (collection != null)
                  object = collection.findForward(forward);
          } else if (mapping != null) {
              selector = mapping;
              ActionMappings collection = (ActionMappings)
                  pageContext.getAttribute(Action.MAPPINGS_KEY);
              if (collection != null)
                  object = collection.findMapping(mapping);
          }
          if (object == null)
              throw new JspException
                  (messages.getMessage("struts.missing", selector));
  
          // Expose this value as a scripting variable
          pageContext.setAttribute(id, object);
          return (SKIP_BODY);
  
      }
  
  
      /**
       * Reset custom attributes to their default values.
       */
      public void releaseCustomAttributes() {
  
          id = null;
          formBean = null;
          forward = null;
          mapping = null;
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/bean/StrutsTei.java
  
  Index: StrutsTei.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/StrutsTei.java,v
1.1 2000/10/08 00:40:49 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 00:40:49 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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/>.
   *
   */
  
  
  package org.apache.struts.taglib.bean;
  
  
  import javax.servlet.jsp.tagext.TagData;
  import javax.servlet.jsp.tagext.TagExtraInfo;
  import javax.servlet.jsp.tagext.VariableInfo;
  
  
  /**
   * Implementation of <code>TagExtraInfo</code> for the <b>struts</b>
   * tag, identifying the scripting object(s) to be made visible.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/10/08 00:40:49 $
   */
  
  public final class StrutsTei extends TagExtraInfo {
  
  
      /**
       * Return information about the scripting variables to be created.
       */
      public VariableInfo[] getVariableInfo(TagData data) {
  
          String type = null;
          if (data.getAttributeString("formBean") != null)
              type = "org.apache.struts.action.ActionFormBean";
          else if (data.getAttributeString("forward") != null)
              type = "org.apache.struts.action.ActionForward";
          else if (data.getAttributeString("mapping") != null)
              type = "org.apache.struts.action.ActionMapping";
          else
              type = "java.lang.Object";
  
  	return new VariableInfo[] {
  	  new VariableInfo(data.getAttributeString("id"),
  	                   type,
  	                   true,
  	                   VariableInfo.AT_BEGIN)
  	};
  
      }
  
  
  }
  
  
  

Mime
View raw message