dgraham     2003/07/25 18:11:43

  Modified:    src/share/org/apache/struts/taglib/bean DefineTag.java
               src/share/org/apache/struts/util RequestUtils.java
               src/share/org/apache/struts/taglib TagUtils.java
               src/share/org/apache/struts/taglib/tiles/util TagUtils.java
  Log:
  Moved getScope() from RequestUtils to TagUtils.
  
  Revision  Changes    Path
  1.21      +7 -5      
jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java
  
  Index: DefineTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DefineTag.java    10 May 2003 17:37:43 -0000      1.20
  +++ DefineTag.java    26 Jul 2003 01:11:43 -0000      1.21
  @@ -66,6 +66,8 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.BodyTagSupport;
  +
  +import org.apache.struts.taglib.TagUtils;
   import org.apache.struts.util.MessageResources;
   import org.apache.struts.util.RequestUtils;
   
  @@ -279,7 +281,7 @@
           int inScope = PageContext.PAGE_SCOPE;
           try {
                        if (toScope != null) {
  -                             inScope = RequestUtils.getScope(toScope);
  +                             inScope = TagUtils.getInstance().getScope(toScope);
                        }
                } catch (JspException e) {
                        //  toScope was invalid name so we default to PAGE_SCOPE
  
  
  
  1.116     +8 -24     
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
  
  Index: RequestUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
  retrieving revision 1.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- RequestUtils.java 26 Jul 2003 01:01:11 -0000      1.115
  +++ RequestUtils.java 26 Jul 2003 01:11:43 -0000      1.116
  @@ -88,7 +88,6 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.struts.Globals;
  -import org.apache.struts.action.ActionError;
   import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionMapping;
  @@ -140,13 +139,7 @@
       private static Method encode = null;
       
       /**
  -     * Maps lowercase JSP scope names to their PageContext integer constant values. 
  -     */
  -    private static Map scopes = new HashMap();
  -    
  -    /**
  -     * Initialize the encode variable with the 1.4 method if available.  Also set 
up the
  -     * scope map values.
  +     * Initialize the encode variable with the 1.4 method if available.
        */
       static {
           try {
  @@ -156,11 +149,6 @@
           } catch (NoSuchMethodException e) {
               log.debug("Could not find Java 1.4 encode method.  Using deprecated 
version.", e);
           }
  -        
  -        scopes.put("page", new Integer(PageContext.PAGE_SCOPE));
  -        scopes.put("request", new Integer(PageContext.REQUEST_SCOPE));
  -        scopes.put("session", new Integer(PageContext.SESSION_SCOPE));
  -        scopes.put("application", new Integer(PageContext.APPLICATION_SCOPE));
       }
   
       // --------------------------------------------------------- Public Methods
  @@ -879,15 +867,11 @@
        * @return The constant representing the scope (ie. PageContext.REQUEST_SCOPE).
        * @throws JspException if the scopeName is not a valid name.
        * @since Struts 1.1
  +     * @deprecated Use TagUtils.getScope() instead.  This will be removed after 
  +     * Struts 1.2.
        */
       public static int getScope(String scopeName) throws JspException {
  -        Integer scope = (Integer) scopes.get(scopeName.toLowerCase());
  -
  -        if (scope == null) {
  -            throw new JspException(messages.getMessage("lookup.scope", scope));
  -        }
  -
  -        return scope.intValue();
  +        return TagUtils.getInstance().getScope(scopeName);
       }
   
       /**
  
  
  
  1.3       +37 -0     jakarta-struts/src/share/org/apache/struts/taglib/TagUtils.java
  
  Index: TagUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/TagUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TagUtils.java     26 Jul 2003 01:02:30 -0000      1.2
  +++ TagUtils.java     26 Jul 2003 01:11:43 -0000      1.3
  @@ -61,6 +61,9 @@
   
   package org.apache.struts.taglib;
   
  +import java.util.HashMap;
  +import java.util.Map;
  +
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   
  @@ -94,9 +97,26 @@
   
       /**
        * The message resources for this package.
  +     * TODO We need to move the relevant messages out of this properties file.
        */
       private static final MessageResources messages =
           MessageResources.getMessageResources("org.apache.struts.util.LocalStrings");
  +        
  +    /**
  +     * Maps lowercase JSP scope names to their PageContext integer constant 
  +     * values. 
  +     */
  +    private static final Map scopes = new HashMap();
  +    
  +    /**
  +     * Initialize the scope names map.
  +     */
  +    static {
  +        scopes.put("page", new Integer(PageContext.PAGE_SCOPE));
  +        scopes.put("request", new Integer(PageContext.REQUEST_SCOPE));
  +        scopes.put("session", new Integer(PageContext.SESSION_SCOPE));
  +        scopes.put("application", new Integer(PageContext.APPLICATION_SCOPE));
  +    }
   
       /**
        * Constructor for TagUtils.
  @@ -160,6 +180,23 @@
           }
   
           return errors;
  +    }
  +    
  +    /**
  +     * Converts the scope name into its corresponding PageContext constant value.
  +     * @param scopeName Can be "page", "request", "session", or "application" in any
  +     * case.
  +     * @return The constant representing the scope (ie. PageContext.REQUEST_SCOPE).
  +     * @throws JspException if the scopeName is not a valid name.
  +     */
  +    public int getScope(String scopeName) throws JspException {
  +        Integer scope = (Integer) scopes.get(scopeName.toLowerCase());
  +
  +        if (scope == null) {
  +            throw new JspException(messages.getMessage("lookup.scope", scope));
  +        }
  +
  +        return scope.intValue();
       }
   
   }
  
  
  
  1.8       +8 -5      
jakarta-struts/src/share/org/apache/struts/taglib/tiles/util/TagUtils.java
  
  Index: TagUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/tiles/util/TagUtils.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TagUtils.java     10 Jul 2003 01:12:10 -0000      1.7
  +++ TagUtils.java     26 Jul 2003 01:11:43 -0000      1.8
  @@ -75,7 +75,6 @@
   import org.apache.struts.tiles.FactoryNotFoundException;
   import org.apache.struts.tiles.NoSuchDefinitionException;
   import org.apache.struts.tiles.TilesUtil;
  -import org.apache.struts.util.RequestUtils;
   
   /**
    * Collection of utilities.
  @@ -105,12 +104,16 @@
           
           if (scopeName.equalsIgnoreCase("component")) {
               return ComponentConstants.COMPONENT_SCOPE;
  +            
           } else if (scopeName.equalsIgnoreCase("template")) {
               return ComponentConstants.COMPONENT_SCOPE;
  +            
           } else if (scopeName.equalsIgnoreCase("tile")) {
               return ComponentConstants.COMPONENT_SCOPE;
  +            
           } else {
  -            return RequestUtils.getScope(scopeName);
  +            return org.apache.struts.taglib.TagUtils.getInstance().getScope(
  +                scopeName);
           }
       }
   
  
  
  

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

Reply via email to