myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r227053 - in /myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html: HtmlResponseWriterImpl.java util/HTMLEncoder.java util/UnicodeEncoder.java
Date Tue, 02 Aug 2005 18:06:58 GMT
Author: schof
Date: Tue Aug  2 11:06:54 2005
New Revision: 227053

URL: http://svn.apache.org/viewcvs?rev=227053&view=rev
Log:
Reverted patch for MYFACES-272.  This patch was causing "double output" of the HTML in the
simple examples.

Modified:
    myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImpl.java
    myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/HTMLEncoder.java
    myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoder.java

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImpl.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImpl.java?rev=227053&r1=227052&r2=227053&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImpl.java
(original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImpl.java
Tue Aug  2 11:06:54 2005
@@ -46,7 +46,6 @@
 
     private static final String DEFAULT_CONTENT_TYPE = "text/html";
     private static final String DEFAULT_CHARACTER_ENCODING = "ISO-8859-1";
-    private static final String UTF8 = "UTF-8";
 
     private boolean _writeDummyForm = false;
     private Set _dummyFormParams = null;
@@ -83,13 +82,13 @@
         _contentType = contentType;
         if (_contentType == null)
         {
-            if (log.isDebugEnabled()) log.debug("No content type given, using default content
type " + DEFAULT_CONTENT_TYPE);
+            if (log.isInfoEnabled()) log.debug("No content type given, using default content
type " + DEFAULT_CONTENT_TYPE);
             _contentType = DEFAULT_CONTENT_TYPE;
         }
         _characterEncoding = characterEncoding;
         if (_characterEncoding == null)
         {
-            if (log.isDebugEnabled()) log.debug("No character encoding given, using default
character encoding " + DEFAULT_CHARACTER_ENCODING);
+            if (log.isInfoEnabled()) log.debug("No character encoding given, using default
character encoding " + DEFAULT_CHARACTER_ENCODING);
             _characterEncoding = DEFAULT_CHARACTER_ENCODING;
         }
     }
@@ -265,7 +264,7 @@
             _writer.write(' ');
             _writer.write(name);
             _writer.write("=\"");
-            _writer.write(HTMLEncoder.encode(strValue, false, false, !UTF8.equals(_characterEncoding)));
+            _writer.write(HTMLEncoder.encode(strValue, false, false));
             _writer.write('"');
         }
     }
@@ -287,7 +286,7 @@
         _writer.write("=\"");
         if (strValue.toLowerCase().startsWith("javascript:"))
         {
-            _writer.write(HTMLEncoder.encode(strValue, false, false, !UTF8.equals(_characterEncoding)));
+            _writer.write(HTMLEncoder.encode(strValue, false, false));
         }
         else
         {
@@ -348,13 +347,11 @@
 
         if (isScriptOrStyle())
         {
-            // Don't bother encoding anything if chosen character encoding is UTF-8
-        	  if (UTF8.equals(_characterEncoding)) _writer.write(strValue);
-            else _writer.write(UnicodeEncoder.encode(strValue) );
+            _writer.write(UnicodeEncoder.encode(strValue, false, false));
         }
         else
         {
-            _writer.write(HTMLEncoder.encode(strValue, false, false, !UTF8.equals(_characterEncoding)));
+            _writer.write(HTMLEncoder.encode(strValue, false, false));
         }
     }
 
@@ -374,23 +371,21 @@
         if (isScriptOrStyle())
         {
             String strValue = new String(cbuf, off, len);
-            // Don't bother encoding anything if chosen character encoding is UTF-8
-        	  if (UTF8.equals(_characterEncoding)) _writer.write(strValue);
-            else _writer.write(UnicodeEncoder.encode(strValue) );
+            _writer.write(UnicodeEncoder.encode(strValue, false, false));
         }
         else if (isTextarea())
         {
             // For textareas we must *not* map successive spaces to &nbsp or Newlines
to <br/>
             // TODO: Make HTMLEncoder support char arrays directly
             String strValue = new String(cbuf, off, len);
-            _writer.write(HTMLEncoder.encode(strValue, false, false, !UTF8.equals(_characterEncoding)));
+            _writer.write(HTMLEncoder.encode(strValue, false, false));
         }
         else
         {
             // We map successive spaces to &nbsp; and Newlines to <br/>
             // TODO: Make HTMLEncoder support char arrays directly
             String strValue = new String(cbuf, off, len);
-            _writer.write(HTMLEncoder.encode(strValue, true, true, !UTF8.equals(_characterEncoding)));
+            _writer.write(HTMLEncoder.encode(strValue, true, true));
         }
     }
 
@@ -434,9 +429,7 @@
     {
         closeStartTagIfNecessary();
         String strValue = new String(cbuf, off, len);
-        // Don't bother encoding anything if chosen character encoding is UTF-8
-    	  if (UTF8.equals(_characterEncoding)) _writer.write(strValue);
-        else _writer.write(UnicodeEncoder.encode(strValue) );
+        _writer.write(UnicodeEncoder.encode(strValue, false, false));
     }
 
     public void write(int c) throws IOException
@@ -449,9 +442,7 @@
     {
         closeStartTagIfNecessary();
         String strValue = new String(cbuf);
-        // Don't bother encoding anything if chosen character encoding is UTF-8
-    	  if (UTF8.equals(_characterEncoding)) _writer.write(strValue);
-        else _writer.write(UnicodeEncoder.encode(strValue) );
+        _writer.write(UnicodeEncoder.encode(strValue, false, false));
     }
 
     public void write(String str) throws IOException
@@ -461,9 +452,7 @@
         // in such case, do not call down the writer chain
         if (str.length() > 0)
         {
-          // Don't bother encoding anything if chosen character encoding is UTF-8
-      	  if (UTF8.equals(_characterEncoding)) _writer.write(str);
-          else _writer.write(UnicodeEncoder.encode(str) );
+            _writer.write(UnicodeEncoder.encode(str, false, false));
         }
     }
 
@@ -471,9 +460,7 @@
     {
         closeStartTagIfNecessary();
         String strValue = str.substring(off, off+len);
-        // Don't bother encoding anything if chosen character encoding is UTF-8
-    	  if (UTF8.equals(_characterEncoding)) _writer.write(str);
-        else _writer.write(UnicodeEncoder.encode(str) );
+        _writer.write(UnicodeEncoder.encode(strValue, false, false));
     }
 
     // DummyFormResponseWriter support

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/HTMLEncoder.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/HTMLEncoder.java?rev=227053&r1=227052&r2=227053&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/HTMLEncoder.java (original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/HTMLEncoder.java Tue
Aug  2 11:06:54 2005
@@ -40,25 +40,14 @@
 	}
 
 	/**
-	 * Variant of {@link #encode} where encodeNbsp is true.
-	 */
-	public static String encode (String string, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp)
-	{
-		return encode(string, encodeNewline, true);
-	}
-	
-	
-	/**
 	 * Encodes the given string, so that it can be used within a html page.
 	 * @param string the string to convert
 	 * @param encodeNewline if true newline characters are converted to &lt;br&gt;'s
 	 * @param encodeSubsequentBlanksToNbsp if true subsequent blanks are converted to &amp;nbsp;'s
-	 * @param encodeNonLatin if true encode non-latin characters as numeric character references

 	 */
 	public static String encode (String string,
 								 boolean encodeNewline,
-								 boolean encodeSubsequentBlanksToNbsp,
-								 boolean encodeNonLatin)
+								 boolean encodeSubsequentBlanksToNbsp)
 	{
 		if (string == null)
 		{
@@ -94,13 +83,13 @@
                     break;
 
                 //german umlauts
-			    case '\u00E4' : if (encodeNonLatin) app = "&auml;";  break;
-			    case '\u00C4' : if (encodeNonLatin) app = "&Auml;";  break;
-			    case '\u00F6' : if (encodeNonLatin) app = "&ouml;";  break;
-			    case '\u00D6' : if (encodeNonLatin) app = "&Ouml;";  break;
-			    case '\u00FC' : if (encodeNonLatin) app = "&uuml;";  break;
-			    case '\u00DC' : if (encodeNonLatin) app = "&Uuml;";  break;
-			    case '\u00DF' : if (encodeNonLatin) app = "&szlig;"; break;
+			    case '\u00E4' : app = "&auml;";  break;
+			    case '\u00C4' : app = "&Auml;";  break;
+			    case '\u00F6' : app = "&ouml;";  break;
+			    case '\u00D6' : app = "&Ouml;";  break;
+			    case '\u00FC' : app = "&uuml;";  break;
+			    case '\u00DC' : app = "&Uuml;";  break;
+			    case '\u00DF' : app = "&szlig;"; break;
 
                 //misc
                 //case 0x80: app = "&euro;"; break;  sometimes euro symbol is ascii 128,
should we suport it?
@@ -110,7 +99,7 @@
                 case '\u00A0': app = "&#160;"; break;
 
                 default:
-                    if (encodeNonLatin && ((int)c) >= 0x80)
+                    if (((int)c) >= 0x80)
                     {
                         //encode all non basic latin characters
                         app = "&#" + ((int)c) + ";";

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoder.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoder.java?rev=227053&r1=227052&r2=227053&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoder.java
(original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoder.java
Tue Aug  2 11:06:54 2005
@@ -19,15 +19,35 @@
 
 
 /**
- * Converts characters out of latin-1 set in a string to numeric character references.
+ * Converts Strings so that they can be used within HTML-Code.
  */
 public abstract class UnicodeEncoder
 {
 	/**
+	 * Variant of {@link #encode} where encodeNewline is false and encodeNbsp is true.
+	 */
+	public static String encode (String string)
+	{
+		return encode(string, false, true);
+	}
+
+	/**
+	 * Variant of {@link #encode} where encodeNbsp is true.
+	 */
+	public static String encode (String string, boolean encodeNewline)
+	{
+		return encode(string, encodeNewline, true);
+	}
+
+	/**
 	 * Encodes the given string, so that it can be used within a html page.
 	 * @param string the string to convert
+	 * @param encodeNewline if true newline characters are converted to &lt;br&gt;'s
+	 * @param encodeSubsequentBlanksToNbsp if true subsequent blanks are converted to &amp;nbsp;'s
 	 */
-	public static String encode (String string)
+	public static String encode (String string,
+								 boolean encodeNewline,
+								 boolean encodeSubsequentBlanksToNbsp)
 	{
 		if (string == null)
 		{



Mime
View raw message