jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin van Dijken" <suns...@windgazer.nl>
Subject RE: cvs commit: jakarta-taglibs/string/xml string.xml
Date Thu, 11 Mar 2004 12:15:18 GMT
Hey Felipe,

Shouldn't the encoding also be reset in release or wherever it is that
variables are reset according to spec?

Martin

-----Oorspronkelijk bericht-----
Van: felipeal@apache.org [mailto:felipeal@apache.org]
Verzonden: donderdag 11 maart 2004 13:09
Aan: jakarta-taglibs-cvs@apache.org
Onderwerp: cvs commit: jakarta-taglibs/string/xml string.xml


felipeal    2004/03/11 04:09:05

  Modified:    string/src/org/apache/taglibs/string EncodeUrlTag.java
               string/xml string.xml
  Log:
  added 'encoding' attribute for <str:encodeUrl> - see bug 18964 for more
details

  Revision  Changes    Path
  1.5       +26 -1
jakarta-taglibs/string/src/org/apache/taglibs/string/EncodeUrlTag.java

  Index: EncodeUrlTag.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/EncodeUrlTag.
java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EncodeUrlTag.java	6 Mar 2004 06:58:48 -0000	1.4
  +++ EncodeUrlTag.java	11 Mar 2004 12:09:05 -0000	1.5
  @@ -17,6 +17,7 @@

   import java.net.URLEncoder;
   import javax.servlet.jsp.JspException;
  +import java.io.UnsupportedEncodingException;

   /**
    * Encode a String to that it may be used as a URL.
  @@ -25,13 +26,37 @@
    */
   public class EncodeUrlTag extends StringTagSupport {

  +  private String encoding = null;
  +
       public EncodeUrlTag() {
           super();
       }

  +  public void setEncoding( String encoding ) {
  +    this.encoding = encoding;
  +  }
  +

       public String changeString(String text) throws JspException {
  -        return URLEncoder.encode(text);
  +
  +      String result = null;
  +      if ( this.encoding != null ) {
  +        try {
  +          //          System.out.println( "++++ TEXT: "+ text + "
ENCODING: "+ this.encoding );
  +          result = URLEncoder.encode( text, this.encoding );
  +          //          System.out.println( "RESULT: "+ result );
  +        } catch( NoSuchMethodError exc ) {
  +          System.err.println( "WARNING: attribute encoding on tag
encodeUrl should be used in a " +
  +                            "J2SE 1.4 compatible web container. Using
default container.");
  +        } catch( UnsupportedEncodingException exc2 ) {
  +          System.err.println( "WARNING: unsupported encoding used on tag
encodeUrl: " + this.encoding );
  +        }
  +      }
  +      if ( result == null ) {
  +        result = URLEncoder.encode(text);
  +      }
  +      return result;
  +
       }

       public void initAttributes() {



  1.32      +10 -0     jakarta-taglibs/string/xml/string.xml

  Index: string.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/xml/string.xml,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- string.xml	10 Mar 2004 03:26:23 -0000	1.31
  +++ string.xml	11 Mar 2004 12:09:05 -0000	1.32
  @@ -467,6 +467,16 @@
             </description>
             <availability>1.0</availability>
           </attribute>
  +        <attribute>
  +          <name>encoding</name>
  +          <required>false</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Encoding the URL should be encoded by (NOTE: available only
on J2SE 1.4 compatible containers - otherwise, will use container's platform
default encoding);
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
           <example>
             <usage>
               <comment>




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



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


Mime
View raw message