You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by dg...@apache.org on 2003/05/07 01:44:46 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html RewriteTag.java

dgraham     2003/05/06 16:44:45

  Modified:    src/share/org/apache/struts/taglib/html RewriteTag.java
  Log:
  Encode the & character to & in XHTML mode only,
  otherwise write the & as is so the url will work in javascripts.
  
  Revision  Changes    Path
  1.9       +21 -14    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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RewriteTag.java	23 Sep 2002 05:13:43 -0000	1.8
  +++ RewriteTag.java	6 May 2003 23:44:45 -0000	1.9
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -59,10 +59,8 @@
    *
    */
   
  -
   package org.apache.struts.taglib.html;
   
  -
   import java.net.MalformedURLException;
   import java.util.Map;
   import javax.servlet.jsp.JspException;
  @@ -76,7 +74,6 @@
    * @author Craig R. McClanahan
    * @version $Revision$ $Date$
    */
  -
   public class RewriteTag extends LinkTag {
   
   
  @@ -90,25 +87,35 @@
        */
       public int doStartTag() throws JspException {
   
  -	// Generate the hyperlink URL
  +        // Generate the hyperlink URL
           Map params = RequestUtils.computeParameters
               (pageContext, paramId, paramName, paramProperty, paramScope,
                name, property, scope, transaction);
  +             
           String url = null;
           try {
  -            url = RequestUtils.computeURL(pageContext, forward, href,
  -                                          page, params, anchor, false);
  +            // Note that we're encoding the & character to & in XHTML mode only, 
  +            // otherwise the & is written as is to work in javascripts. 
  +			url =
  +				RequestUtils.computeURL(
  +					pageContext,
  +					forward,
  +					href,
  +					page,
  +					null,
  +					params,
  +					anchor,
  +					!this.isXhtml());
  +                    
           } catch (MalformedURLException e) {
               RequestUtils.saveException(pageContext, e);
               throw new JspException
                   (messages.getMessage("rewrite.url", e.toString()));
           }
   
  -	// Print this element to our output writer
           ResponseUtils.write(pageContext, url);
   
  -	// Skip the body of this tag
  -	return (SKIP_BODY);
  +        return (SKIP_BODY);
   
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org