dgraham     2003/06/19 21:09:57

  Modified:    src/share/org/apache/struts/taglib/html RewriteTag.java
               src/share/org/apache/struts/util RequestUtils.java
  Log:
  Added new RequestUtils.computeURL() method with yet another parameter 
"encodeSeparator".
  If redirect is true, the ampersand is always written as & regardless of 
  the value of encodeSeparator.  If redirect is false and encodeSeparator is
  true we use & as a separator.  
  
  RewriteTag only encodes the ampersand in xhtml mode.
  
  PR# 20835.
  
  Revision  Changes    Path
  1.10      +6 -5      
jakarta-struts/src/share/org/apache/struts/taglib/html/RewriteTag.java
  
  Index: RewriteTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/RewriteTag.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RewriteTag.java   6 May 2003 23:44:45 -0000       1.9
  +++ RewriteTag.java   20 Jun 2003 04:09:57 -0000      1.10
  @@ -105,7 +105,8 @@
                                        null,
                                        params,
                                        anchor,
  -                                     !this.isXhtml());
  +                                     false,
  +                    this.isXhtml());
                       
           } catch (MalformedURLException e) {
               RequestUtils.saveException(pageContext, e);
  
  
  
  1.104     +67 -6     
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.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- RequestUtils.java 14 Jun 2003 18:36:19 -0000      1.103
  +++ RequestUtils.java 20 Jun 2003 04:09:57 -0000      1.104
  @@ -396,7 +396,7 @@
        return computeURL(pageContext, forward, href, page, null, params,
                          anchor, redirect);
       }
  -
  +    
       /**
        * Compute a hyperlink URL based on the <code>forward</code>,
        * <code>href</code>, <code>action</code> or <code>page</code> parameter
  @@ -432,6 +432,60 @@
           String anchor,
           boolean redirect)
           throws MalformedURLException {
  +            
  +        return computeURL(
  +            pageContext,
  +            forward,
  +            href,
  +            page,
  +            action,
  +            params,
  +            anchor,
  +            redirect,
  +            true);
  +    }
  +
  +    /**
  +     * Compute a hyperlink URL based on the <code>forward</code>,
  +     * <code>href</code>, <code>action</code> or <code>page</code> parameter
  +     * that is not null.
  +     * The returned URL will have already been passed to
  +     * <code>response.encodeURL()</code> for adding a session identifier.
  +     *
  +     * @param pageContext PageContext for the tag making this call
  +     *
  +     * @param forward Logical forward name for which to look up
  +     *  the context-relative URI (if specified)
  +     * @param href URL to be utilized unmodified (if specified)
  +     * @param page Module-relative page for which a URL should
  +     *  be created (if specified)
  +     * @param action Logical action name for which to look up
  +     *  the context-relative URI (if specified)
  +     *
  +     * @param params Map of parameters to be dynamically included (if any)
  +     * @param anchor Anchor to be dynamically included (if any)
  +     *
  +     * @param redirect Is this URL for a <code>response.sendRedirect()</code>?
  +     * @param encodeSeparator This is only checked if redirect is set to false 
(never
  +     * encoded for a redirect).  If true, query string parameter separators are 
encoded
  +     * as &gt;amp;, else &amp; is used.
  +     * @return URL with session identifier
  +     * @exception MalformedURLException if a URL cannot be created
  +     *  for the specified parameters
  +     */
  +    public static String computeURL(
  +        PageContext pageContext,
  +        String forward,
  +        String href,
  +        String page,
  +        String action,
  +        Map params,
  +        String anchor,
  +        boolean redirect,
  +        boolean encodeSeparator)
  +        throws MalformedURLException {
  +            
  +        // TODO All the computeURL() methods need refactoring!
   
           // Validate that exactly one specifier was included
           int n = 0;
  @@ -513,7 +567,14 @@
               }
   
               // Define the parameter separator
  -            String separator = redirect ? "&" : "&amp;";
  +            String separator = null;
  +            if (redirect) {
  +                separator = "&";
  +            } else if (encodeSeparator) {
  +                separator = "&amp;";
  +            } else {
  +                separator = "&";
  +            }
   
               // Add the required request parameters
               boolean question = temp.indexOf('?') >= 0;
  
  
  

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

Reply via email to