jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core RedirectTag.java UrlTag.java
Date Wed, 17 Apr 2002 13:22:18 GMT
shawn       02/04/17 06:22:18

  Modified:    standard/conf c-rt.tld c.tld
               standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/src/org/apache/taglibs/standard/tag/common/core
                        RedirectSupport.java UrlSupport.java
               standard/src/org/apache/taglibs/standard/tag/el/core
                        RedirectTag.java UrlTag.java
               standard/src/org/apache/taglibs/standard/tag/rt/core
                        RedirectTag.java UrlTag.java
  Log:
  In PFD, URL tags
   - normalize URLs (including page-relative URLs) against a context root
   - have a 'context' attribute
  
  Revision  Changes    Path
  1.13      +10 -0     jakarta-taglibs/standard/conf/c-rt.tld
  
  Index: c-rt.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/conf/c-rt.tld,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- c-rt.tld	17 Apr 2002 11:21:32 -0000	1.12
  +++ c-rt.tld	17 Apr 2002 13:22:18 -0000	1.13
  @@ -260,6 +260,11 @@
           <required>false</required>
           <rtexprvalue>true</rtexprvalue>
       </attribute>
  +    <attribute>
  +        <name>context</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
     </tag>
   
     <tag>
  @@ -281,6 +286,11 @@
       </attribute>
       <attribute>
           <name>value</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>context</name>
           <required>false</required>
           <rtexprvalue>true</rtexprvalue>
       </attribute>
  
  
  
  1.15      +12 -0     jakarta-taglibs/standard/conf/c.tld
  
  Index: c.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/conf/c.tld,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- c.tld	17 Apr 2002 02:53:35 -0000	1.14
  +++ c.tld	17 Apr 2002 13:22:18 -0000	1.15
  @@ -34,8 +34,10 @@
   	    param:encode
   	    param:name
   	    param:value
  +            redirect:context
               redirect:url
   	    set:value
  +	    url:context
   	    url:value
   	    when:test
   	</param-value>
  @@ -306,6 +308,11 @@
           <required>false</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>
  +    <attribute>
  +        <name>context</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +    </attribute>
     </tag>
   
     <tag>
  @@ -371,6 +378,11 @@
       </attribute>
       <attribute>
           <name>value</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>context</name>
           <required>false</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>
  
  
  
  1.23      +2 -2      jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Resources.properties	16 Apr 2002 18:17:51 -0000	1.22
  +++ Resources.properties	17 Apr 2002 13:22:18 -0000	1.23
  @@ -37,8 +37,8 @@
       Don't know how to iterate over supplied "items" in &lt;forEach&gt;
   
   IMPORT_BAD_RELATIVE=\
  -    In &lt;import&gt;, when "context" attribute is specified, \
  -    values of both "context" and "url" must start with "/"
  +    In URL tags, when the "context" attribute is specified, \
  +    values of both "context" and "url" must start with "/".
   
   IMPORT_REL_WITHOUT_HTTP=\
       Relative &lt;import&gt; from non-HTTP request not allowed
  
  
  
  1.2       +3 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/RedirectSupport.java
  
  Index: RedirectSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/RedirectSupport.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RedirectSupport.java	9 Mar 2002 00:17:14 -0000	1.1
  +++ RedirectSupport.java	17 Apr 2002 13:22:18 -0000	1.2
  @@ -77,6 +77,7 @@
       // Protected state
   
       protected String url;                        // 'url' attribute
  +    protected String context;                    // 'context' attribute
   
       //*********************************************************************
       // Private state
  @@ -136,7 +137,8 @@
   	String result;				// the eventual result
   
   	// add (already encoded) parameters
  -	result = params.aggregateParams(url);
  +        String baseUrl = UrlSupport.resolveUrl(url, context, pageContext);
  +        result = params.aggregateParams(baseUrl);
   
           // if the URL is relative, rewrite it with 'redirect' encoding rules
           HttpServletResponse response =
  
  
  
  1.3       +34 -1     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/UrlSupport.java
  
  Index: UrlSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/UrlSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UrlSupport.java	9 Mar 2002 00:12:31 -0000	1.2
  +++ UrlSupport.java	17 Apr 2002 13:22:18 -0000	1.3
  @@ -77,6 +77,7 @@
       // Protected state
   
       protected String value;                      // 'value' attribute
  +    protected String context;			 // 'context' attribute
   
       //*********************************************************************
       // Private state
  @@ -96,6 +97,7 @@
       private void init() {
   	value = var = null;
   	params = null;
  +	context = null;
   	scope = PageContext.PAGE_SCOPE;
       }
   
  @@ -136,7 +138,8 @@
   	String result;				// the eventual result
   
   	// add (already encoded) parameters
  -	result = params.aggregateParams(value);
  +	String baseUrl = resolveUrl(value, context, pageContext);
  +	result = params.aggregateParams(baseUrl);
   
   	// if the URL is relative, rewrite it
   	if (!ImportSupport.isAbsoluteUrl(result)) {
  @@ -163,4 +166,34 @@
       public void release() {
   	init();
       }
  +
  +    //*********************************************************************
  +    // Utility methods
  +
  +    public static String resolveUrl(
  +            String url, String context, PageContext pageContext)
  +	    throws JspException {
  +	// don't touch absolute URLs
  +	if (ImportSupport.isAbsoluteUrl(url))
  +	    return url;
  +
  +	// normalize relative URLs against a context root
  +	HttpServletRequest request =
  +	    (HttpServletRequest) pageContext.getRequest();
  +	if (context == null) {
  +	    if (!url.startsWith("/")) {
  +                String page =
  +		    request.getContextPath() + request.getServletPath();
  +		String dir = page.substring(0, page.lastIndexOf("/") + 1);
  +	        return (dir + url);
  +	    } else
  +	        return (request.getContextPath() + url);
  +	} else {
  +            if (!context.startsWith("/") || !url.startsWith("/"))
  +                throw new JspTagException(
  +                    Resources.getMessage("IMPORT_BAD_RELATIVE"));
  +            return (context + url);
  +        }
  +    }
  +
   }
  
  
  
  1.2       +9 -2      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/RedirectTag.java
  
  Index: RedirectTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/RedirectTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RedirectTag.java	9 Mar 2002 00:17:14 -0000	1.1
  +++ RedirectTag.java	17 Apr 2002 13:22:18 -0000	1.2
  @@ -72,6 +72,7 @@
       // 'Private' state (implementation details)
   
       private String url_;			// stores EL-based property
  +    private String context_;			// stores EL-based property
   
   
       //*********************************************************************
  @@ -116,13 +117,17 @@
           this.url_ = url_;
       }
   
  +    public void setContext(String context_) {
  +        this.context_ = context_;
  +    }
  +
       //*********************************************************************
       // Private (utility) methods
   
       // (re)initializes state (during release() or construction)
       private void init() {
           // null implies "no expression"
  -	url_ = null;
  +	url_ = context_ = null;
       }
   
       /* Evaluates expressions as necessary */
  @@ -136,6 +141,8 @@
            */
   
   	url = (String) ExpressionUtil.evalNotNull(
  -	    "import", "url", url_, String.class, this, pageContext);
  +	    "redirect", "url", url_, String.class, this, pageContext);
  +	context = (String) ExpressionUtil.evalNotNull(
  +	    "redirect", "context", context_, String.class, this, pageContext);
       }
   }
  
  
  
  1.2       +9 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/UrlTag.java
  
  Index: UrlTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/UrlTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UrlTag.java	8 Mar 2002 22:14:33 -0000	1.1
  +++ UrlTag.java	17 Apr 2002 13:22:18 -0000	1.2
  @@ -72,6 +72,7 @@
       // 'Private' state (implementation details)
   
       private String value_;			// stores EL-based property
  +    private String context_;			// stores EL-based property
   
   
       //*********************************************************************
  @@ -116,6 +117,11 @@
           this.value_ = value_;
       }
   
  +    public void setContext(String context_) {
  +        this.context_ = context_;
  +    }
  +
  +
       //*********************************************************************
       // Private (utility) methods
   
  @@ -136,6 +142,8 @@
            */
   
   	value = (String) ExpressionUtil.evalNotNull(
  -	    "import", "value", value_, String.class, this, pageContext);
  +	    "url", "value", value_, String.class, this, pageContext);
  +	context = (String) ExpressionUtil.evalNotNull(
  +	    "url", "context", context_, String.class, this, pageContext);
       }
   }
  
  
  
  1.2       +5 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core/RedirectTag.java
  
  Index: RedirectTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core/RedirectTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RedirectTag.java	9 Mar 2002 00:17:14 -0000	1.1
  +++ RedirectTag.java	17 Apr 2002 13:22:18 -0000	1.2
  @@ -76,4 +76,9 @@
           this.url = url;
       }
   
  +    // for tag attribute
  +    public void setContext(String context) throws JspTagException {
  +        this.context = context;
  +    }
  +
   }
  
  
  
  1.2       +5 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core/UrlTag.java
  
  Index: UrlTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core/UrlTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UrlTag.java	8 Mar 2002 22:14:33 -0000	1.1
  +++ UrlTag.java	17 Apr 2002 13:22:18 -0000	1.2
  @@ -76,4 +76,9 @@
           this.value = value;
       }
   
  +    // for tag attribute
  +    public void setContext(String context) throws JspTagException {
  +        this.context = context;
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message