You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2007/06/23 17:25:52 UTC

svn commit: r550053 - in /tapestry/tapestry4/trunk: src/site/xdoc/components/general/ tapestry-framework/src/java/org/apache/tapestry/dojo/ tapestry-framework/src/java/org/apache/tapestry/dojo/html/ tapestry-framework/src/java/org/apache/tapestry/html/...

Author: jkuhnert
Date: Sat Jun 23 08:25:51 2007
New Revision: 550053

URL: http://svn.apache.org/viewvc?view=rev&rev=550053
Log:
TAPESTRY-1591.  Client side XHR call encoding should match IEngine output encoding.

Modified:
    tapestry/tapestry4/trunk/src/site/xdoc/components/general/scriptincludes.xml
    tapestry/tapestry4/trunk/src/site/xdoc/components/general/shell.xml
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/ScriptIncludes.jwc
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.jwc
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/scriptaculous/Suggest.java
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java

Modified: tapestry/tapestry4/trunk/src/site/xdoc/components/general/scriptincludes.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/src/site/xdoc/components/general/scriptincludes.xml?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/src/site/xdoc/components/general/scriptincludes.xml (original)
+++ tapestry/tapestry4/trunk/src/site/xdoc/components/general/scriptincludes.xml Sat Jun 23 08:25:51 2007
@@ -116,7 +116,7 @@
                         <td>debugEnabled</td>
                         <td>boolean</td>
                         <td>no</td>
-                        <td>true</td>
+                        <td>false</td>
                         <td>
                             Turns browser level logging completely on/off.
                         </td>
@@ -142,7 +142,7 @@
                         <td>debugContainerId</td>
                         <td>String</td>
                         <td>no</td>
-                        <td>debug</td>
+                        <td> </td>
                         <td>
                             Sets the html element node id of the element you would like all browser debug content to
                             go to, if you have logging turned on.

Modified: tapestry/tapestry4/trunk/src/site/xdoc/components/general/shell.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/src/site/xdoc/components/general/shell.xml?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/src/site/xdoc/components/general/shell.xml (original)
+++ tapestry/tapestry4/trunk/src/site/xdoc/components/general/shell.xml Sat Jun 23 08:25:51 2007
@@ -262,7 +262,7 @@
                         <td>debugContainerId</td>
                         <td>String</td>
                         <td>no</td>
-                        <td>debug</td>
+                        <td> </td>
                         <td>
                             Sets the html element node id of the element you would like all browser debug content to
                             go to, if you have logging turned on.

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java Sat Jun 23 08:25:51 2007
@@ -21,14 +21,11 @@
 import java.util.Locale;
 
 /**
- * The default rendering delegate responseible for include the 
- * dojo sources into the {@link Shell} component.
- *
- * @author jkuhnert
+ * The default rendering delegate responseible for include the dojo sources in
+ * to the {@link Shell} component.
  */
-public class AjaxShellDelegate implements IRender
-{
-    
+public class AjaxShellDelegate implements IRender {
+
     /** Client side debug log level. */
     public static final String BROWSER_LOG_DEBUG="DEBUG";
     /** Client side info log level. */
@@ -39,7 +36,7 @@
     public static final String BROWSER_LOG_ERROR="ERROR";
     /** Client side critical log level. */
     public static final String BROWSER_LOG_CRITICAL="CRITICAL";
-    
+
     private IAsset _dojoSource;
 
     private IAsset _dojoFormSource;
@@ -47,40 +44,40 @@
     private IAsset _dojoWidgetSource;
 
     private IAsset _dojoPath;
-    
+
     private IAsset _tapestrySource;
-    
+
     private IAsset _tapestryPath;
-    
+
     private boolean _parseWidgets;
-    
+
     private String _browserLogLevel = BROWSER_LOG_WARNING;
-    
+
     private boolean _debug;
-    
+
     private String _debugContainerId;
-    
+
     private boolean _consoleEnabled;
-    
+
     private boolean _preventBackButtonFix;
-    
+
     private boolean _debugAtAllCosts;
-    
+
     /**
      * {@inheritDoc}
      */
     public void render(IMarkupWriter writer, IRequestCycle cycle)
     {
         // first configure dojo, has to happen before package include
-        
+
         JSONObject dojoConfig = new JSONObject();
-        
+
         // Debugging configuration , debugAtAlCosts causes the individual 
         // .js files to included in the document head so that javascript errors
         // are able to resolve to the context of the file instead of just "dojo.js"
-        
+
         dojoConfig.put("isDebug", _debug);
-        
+
         if (_debugAtAllCosts)
             dojoConfig.put("debugAtAllCosts", _debugAtAllCosts);
         if (_debugContainerId != null)
@@ -89,88 +86,91 @@
         IPage page = cycle.getPage();
 
         // The key to resolving everything out of the asset service
-        
+
         dojoConfig.put("baseRelativePath", _dojoPath.buildURL());
-        
-        if (page.hasFormComponents()) {
 
-            dojoConfig.put("preventBackButtonFix", false);
+        if (page.hasFormComponents())
+        {
+            dojoConfig.put("preventBackButtonFix", _preventBackButtonFix);
         }
         dojoConfig.put("parseWidgets", _parseWidgets);
-        
+
         // Supports setting up locale in dojo environment to match the requested page locale.
         // (for things that use these settings, like DropdownDatePicker / date parsing / etc..
 
         Locale locale = cycle.getPage().getLocale();
 
         dojoConfig.put("locale", locale.getLanguage().toLowerCase()
-                + ((locale.getCountry() != null && locale.getCountry().trim().length() > 0)
-                ? "-" + locale.getCountry().toLowerCase()
-                        : ""));
-        
+                                 + ((locale.getCountry() != null && locale.getCountry().trim().length() > 0)
+                                    ? "-" + locale.getCountry().toLowerCase()
+                                    : ""));
+
         // Write the required script includes and dojo.requires
-        
+
         StringBuffer str = new StringBuffer("<script type=\"text/javascript\">");
         str.append("djConfig = ").append(dojoConfig.toString())
-        .append(" </script>\n\n ");
-        
+          .append(" </script>\n\n ");
+
         // include the core dojo.js package
-        
-        str.append("<script type=\"text/javascript\" src=\"")
-        .append(_dojoSource.buildURL()).append("\"></script>");
 
-        if (page.hasFormComponents()) {
+        str.append("<script type=\"text/javascript\" src=\"")
+          .append(_dojoSource.buildURL()).append("\"></script>");
 
+        if (page.hasFormComponents())
+        {
             str.append("<script type=\"text/javascript\" src=\"")
-                    .append(_dojoFormSource.buildURL()).append("\"></script>");
+              .append(_dojoFormSource.buildURL()).append("\"></script>");
         }
 
-        if (page.hasWidgets()) {
-
+        if (page.hasWidgets())
+        {
             str.append("<script type=\"text/javascript\" src=\"")
-                    .append(_dojoWidgetSource.buildURL()).append("\"></script>");
+              .append(_dojoWidgetSource.buildURL()).append("\"></script>");
         }
-        
-        // configure basic dojo properties , logging includes
 
-        if (_debug) {
+        // configure basic dojo properties , logging includes
 
+        if (_debug)
+        {
             String logRequire = _consoleEnabled ? "dojo.require(\"dojo.debug.console\");\n"
-                : "dojo.require(\"dojo.logging.Logger\");\n";
+                                : "dojo.require(\"dojo.logging.Logger\");\n";
 
             str.append("\n<script type=\"text/javascript\">\n");
             str.append(logRequire)
-            .append("dojo.log.setLevel(dojo.log.getLevel(\"").append(_browserLogLevel)
-            .append("\"));\n")
-            .append("</script>");
+              .append("dojo.log.setLevel(dojo.log.getLevel(\"").append(_browserLogLevel)
+              .append("\"));\n")
+              .append("</script>");
         }
-        
+
         // module path registration to tapestry javascript sources
 
         String tapestryUrl = _tapestryPath.buildURL();
-        if (tapestryUrl.endsWith("/")) {
+        if (tapestryUrl.endsWith("/"))
+        {
             tapestryUrl = tapestryUrl.substring(0, tapestryUrl.length() - 1);
         }
 
         str.append("\n<script type=\"text/javascript\">\n")
-        .append("dojo.registerModulePath(\"tapestry\", \"")
-        .append(tapestryUrl).append("\");\n");
+          .append("dojo.registerModulePath(\"tapestry\", \"")
+          .append(tapestryUrl).append("\");\n");
         str.append("</script>\n");
-        
+
         // include core tapestry.js package
-        
+
         str.append("<script type=\"text/javascript\" src=\"")
-        .append(_tapestrySource.buildURL()).append("\"></script>");
-        
+          .append(_tapestrySource.buildURL()).append("\"></script>");
+
         // namespace registration
-        
+
         str.append("\n<script type=\"text/javascript\">\n");
-        str.append("dojo.require(\"tapestry.namespace\");\n").append("</script>");
-        
+        str.append("dojo.require(\"tapestry.namespace\");\n")
+          .append("tapestry.requestEncoding='").append(cycle.getEngine().getOutputEncoding())
+          .append("';\n").append("</script>");
+
         writer.printRaw(str.toString());
         writer.println();
     }
-    
+
     /**
      * Sets the dojo logging level. Similar to log4j style
      * log levels. 
@@ -189,85 +189,86 @@
     public void setLogLevel(String level)
     {
         Defense.notNull("level", level);
-        
+
         _browserLogLevel = level;
     }
-    
+
     /**
      * Allows for turning browser debugging on/off.
-     * 
+     *
      * @param debug If false, no logging output will be written.
      */
     public void setDebug(boolean debug)
     {
         _debug = debug;
     }
-    
+
     /**
      * Turns off deep context level javascript debugging mode for dojo. This means
      * that exceptions/debug statements will show you line numbers from the actual 
      * javascript file that generated them instead of the normal default which is 
      * usually bootstrap.js .
-     * 
+     *
      * <p>The default value is false if not set.</p>
-     * 
+     *
      * <p>
      *  People should be wary of turning this on as it may cause problems
      *  under certain conditions, and you definitely don't ever want this 
      *  on in production. 
      * </p>
-     * 
+     *
      * @param value If true deep debugging will be turned on.
      */
     public void setDebugAtAllCosts(boolean value)
     {
         _debugAtAllCosts = value;
     }
-    
+
     /**
      * Sets the html element node id of the element you would like all browser
      * debug content to go to.
-     * 
+     *
      * @param debugContainerId the debugContainerId to set
      */
     public void setDebugContainerId(String debugContainerId)
     {
         _debugContainerId = debugContainerId;
     }
-    
+
     /**
      * Enables/disables the dojo.debug.console functionality which should redirect
      * most logging messages to your browsers javascript console. (if it supports 
      * one).
-     * 
+     *
      * <p>
      *  The debug console is disabled by default. Currently known supported 
      *  browsers are FireFox(having FireBug extension helps a great deal)/Opera/Safari.
      * </p>
-     * 
+     *
      * @param enabled Whether or not the enable debug console.
      */
     public void setConsoleEnabled(boolean enabled)
     {
         _consoleEnabled = enabled;
     }
-    
+
     /**
      * Sets the dojo preventBackButtonFix djConfig configuration. This should
      * typically be avoided but is provided for flexibility.
-     * 
+     *
      * @param prevent
+     *          Whether or not to prevent back button fix.
      */
     public void setPreventBackButtonFix(boolean prevent)
     {
         _preventBackButtonFix = prevent;
     }
-    
+
     /**
      * Tells dojo whether or not to parse widgets by traversing the entire 
      * dom node of your document. It is highly reccomended that you keep this
      * at its default value of false.
-     * 
+     *
      * @param parseWidgets the parseWidgets to set
      */
     public void setParseWidgets(boolean parseWidgets)
@@ -278,7 +279,9 @@
     /**
      * Sets a valid path to the base dojo javascript installation
      * directory.
+     *
      * @param dojoSource
+     *          Path to dojo source directory core "dojo.js" file.
      */
     public void setDojoSource(IAsset dojoSource)
     {
@@ -297,26 +300,30 @@
 
     /**
      * Sets the dojo baseRelativePath value.
+     *
      * @param dojoPath
+     *          The base path to dojo directory.
      */
     public void setDojoPath(IAsset dojoPath)
     {
         _dojoPath = dojoPath;
     }
-    
+
     /**
-     * Sets a valid base path to resolve tapestry.js.
+     * Sets a valid base path to resolve tapestry core.js.
+     *
      * @param tapestrySource
+     *          Main tapestry core.js file.
      */
     public void setTapestrySource(IAsset tapestrySource)
     {
         _tapestrySource = tapestrySource;
     }
-    
+
     /**
      * Sets the path to the tapestry javascript modules. (Needed for dojo to resolve the 
      * path to tapestry javascript, esp when overriding the default bundled dojo.)
-     * 
+     *
      * @param tapestryPath The path to tapestry.
      */
     public void setTapestryPath(IAsset tapestryPath)

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/ScriptIncludes.jwc
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/ScriptIncludes.jwc?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/ScriptIncludes.jwc (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/ScriptIncludes.jwc Sat Jun 23 08:25:51 2007
@@ -48,13 +48,13 @@
         </description>
     </parameter>
 
-    <parameter name="debugEnabled" default-value="true">
+    <parameter name="debugEnabled" default-value="false">
         <description>Allows turning browser debug logging statements on/off.</description>
     </parameter>
     
     <parameter name="debugAtAllCosts" default-value="false" />
     
-    <parameter name="debugContainerId" default-value="literal:debug">
+    <parameter name="debugContainerId">
         <description>
             Sets the html element node id of the element you would like all browser debug content to
             go to, if you have logging turned on.

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.jwc
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.jwc?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.jwc (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.jwc Sat Jun 23 08:25:51 2007
@@ -121,7 +121,7 @@
     
     <parameter name="debugAtAllCosts" default-value="false" />
     
-    <parameter name="debugContainerId" default-value="literal:debug">
+    <parameter name="debugContainerId">
         <description>
             Sets the html element node id of the element you would like all browser debug content to
             go to, if you have logging turned on.

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/scriptaculous/Suggest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/scriptaculous/Suggest.java?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/scriptaculous/Suggest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/scriptaculous/Suggest.java Sat Jun 23 08:25:51 2007
@@ -80,7 +80,7 @@
      * @return The value converter to use.
      */
     public abstract ValueConverter getValueConverter();
-    
+
     /**
      * Injected.
      *
@@ -146,17 +146,17 @@
 
         IForm form = TapestryUtils.getForm(cycle, this);
         setForm(form);
-        
+
         if (form.wasPrerendered(writer, this))
-                return;
-        
-        if (!form.isRewinding() && !cycle.isRewinding()
-            && getResponse().isDynamic() && isSearchTriggered()) {
+            return;
 
+        if (!form.isRewinding() && !cycle.isRewinding()
+            && getResponse().isDynamic() && isSearchTriggered())
+        {
             setName(form);
 
             // do nothing if it wasn't for this instance - such as in a loop
-            
+
             if (cycle.getParameter(getClientId()) == null)
                 return;
 
@@ -183,12 +183,12 @@
         Defense.notNull(getListSource(), "listSource for Suggest component.");
 
         Iterator values = (Iterator)getValueConverter().coerceValue(getListSource(), Iterator.class);
-        
+
         if (isParameterBound("maxResults"))
         {
             values = new SizeRestrictingIterator(values, getMaxResults());
         }
-        
+
         getListItemRenderer().renderList(writer, cycle, values);
     }
 
@@ -249,22 +249,28 @@
 
         JSONObject json = null;
         String options = getOptions();
-        
+
         try {
 
             json = options != null ? new JSONObject(options) : new JSONObject();
-            
+
         } catch (ParseException ex)
         {
             throw new ApplicationRuntimeException(ScriptaculousMessages.invalidOptions(options, ex), this.getBinding("options").getLocation(), ex);
         }
 
         // bind onFailure client side function if not already defined
+
         if (!json.has("onFailure"))
         {
             json.put("onFailure", "tapestry.error");
         }
 
+        if (!json.has("encoding"))
+        {
+            json.put("encoding", cycle.getEngine().getOutputEncoding());
+        }
+
         Map parms = new HashMap();
         parms.put("inputId", getClientId());
         parms.put("updateId", getClientId() + "choices");
@@ -280,7 +286,7 @@
 
             listenerParams = new Object[1];
         }
-        
+
         listenerParams[0] = getClientId();
 
         ILink updateLink = getEngineService().getLink(isStateful(), new DirectServiceParameter(this, listenerParams));

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Sat Jun 23 08:25:51 2007
@@ -46,8 +46,12 @@
     GlobalScriptFragment:new RegExp('(?:<script.*?>)((\n|.|\r)*?)(?:<\/script>)', 'img'), // regexp for global script fragments
     requestsInFlight:0, // how many ajax requests are currently in progress
     isIE:dojo.render.html.ie,
+	// property: requestEncoding
+	// Defines the encoding that will be used in all Tapestry initiated XHR requests to encode
+	// URL or form data. Gets set by AjaxShellDelegate class on server on most requests by default.
+	requestEncoding:"UTF-8",
 
-    /**
+	/**
 	 * Function: bind
 	 *
 	 * Core XHR bind function for tapestry internals. The
@@ -67,7 +71,8 @@
 			content:content,
             useCache:true,
             preventCache:true,
-            error: (function(){tapestry.error.apply(this, arguments);})
+			encoding: tapestry.requestEncoding,
+			error: (function(){tapestry.error.apply(this, arguments);})
 		};
 
 		// setup content type
@@ -78,7 +83,6 @@
 		} else {
 			parms.headers={"dojo-ajax-request":true};
 			parms.mimetype="text/xml";
-			parms.encoding="UTF-8";
 			parms.load=(function(){tapestry.load.apply(this, arguments);});
 		}
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js Sat Jun 23 08:25:51 2007
@@ -418,7 +418,7 @@
             useCache:true,
             preventCache:true,
             error: (function(){tapestry.error.apply(this, arguments);}),
-            encoding: "UTF-8"
+            encoding: tapestry.requestEncoding
 		};
 		
 		// check for override

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java Sat Jun 23 08:25:51 2007
@@ -65,10 +65,13 @@
         IAsset tPath = newAsset();
         IPage page = newMock(IPage.class);
         checkOrder(page, false);
+        IEngine engine = newMock(IEngine.class);
         
         IRequestCycle cycle = newCycle();
         IMarkupWriter writer = newBufferWriter();
 
+        expect(cycle.getEngine()).andReturn(engine);
+        expect(engine.getOutputEncoding()).andReturn("utf-foo");
         expect(cycle.getPage()).andReturn(page);
         expect(dojoPath.buildURL()).andReturn("http:///dojo/path");
 
@@ -78,9 +81,7 @@
         trainPageLocale(cycle, Locale.US);
         
         expect(dojoSource.buildURL()).andReturn("http:///dojo/path/dojo.js");
-        
         expect(tPath.buildURL()).andReturn("/tapestry");
-        
         expect(tSource.buildURL()).andReturn("/tapestry/tapestry.js");
         
         AjaxShellDelegate d = new AjaxShellDelegate();
@@ -97,15 +98,16 @@
         
         assertBuffer("<script type=\"text/javascript\">djConfig = {\"isDebug\":false,"
                 + "\"baseRelativePath\":\"http:///dojo/path\","
-                +"\"parseWidgets\":false,\"locale\":\"en-us\"} </script>\n" + 
-                "\n" + 
-                " <script type=\"text/javascript\" src=\"http:///dojo/path/dojo.js\"></script>\n"
-                + "<script type=\"text/javascript\">\n" + 
-                "dojo.registerModulePath(\"tapestry\", \"/tapestry\");\n" + 
-                "</script>\n" + 
-                "<script type=\"text/javascript\" src=\"/tapestry/tapestry.js\"></script>\n" + 
-                "<script type=\"text/javascript\">\n" + 
-                "dojo.require(\"tapestry.namespace\");\n" + 
+                +"\"parseWidgets\":false,\"locale\":\"en-us\"} </script>" + SYSTEM_NEWLINE +
+                SYSTEM_NEWLINE + 
+                " <script type=\"text/javascript\" src=\"http:///dojo/path/dojo.js\"></script>" + SYSTEM_NEWLINE
+                + "<script type=\"text/javascript\">" + SYSTEM_NEWLINE + 
+                "dojo.registerModulePath(\"tapestry\", \"/tapestry\");" + SYSTEM_NEWLINE +
+                "</script>" + SYSTEM_NEWLINE +
+                "<script type=\"text/javascript\" src=\"/tapestry/tapestry.js\"></script>" + SYSTEM_NEWLINE +
+                "<script type=\"text/javascript\">" + SYSTEM_NEWLINE +
+                "dojo.require(\"tapestry.namespace\");" + SYSTEM_NEWLINE +
+                "tapestry.requestEncoding='utf-foo';" + SYSTEM_NEWLINE + 
                 "</script>" + SYSTEM_NEWLINE);
     }
     
@@ -117,10 +119,13 @@
         IAsset tPath = newAsset();
         IPage page = newMock(IPage.class);
         checkOrder(page, false);
+        IEngine engine = newMock(IEngine.class);
         
         IRequestCycle cycle = newCycle();
         IMarkupWriter writer = newBufferWriter();
 
+        expect(cycle.getEngine()).andReturn(engine);
+        expect(engine.getOutputEncoding()).andReturn("utf-foo");
         expect(cycle.getPage()).andReturn(page);
         expect(dojoPath.buildURL()).andReturn("http:///dojo/path");
 
@@ -130,9 +135,7 @@
         trainPageLocale(cycle, Locale.UK);
         
         expect(dojoSource.buildURL()).andReturn("http:///dojo/path/dojo.js");
-        
         expect(tPath.buildURL()).andReturn("/tapestry");
-        
         expect(tSource.buildURL()).andReturn("/tapestry/tapestry.js");
         
         AjaxShellDelegate d = new AjaxShellDelegate();
@@ -164,6 +167,7 @@
                      "<script type=\"text/javascript\" src=\"/tapestry/tapestry.js\"></script>\n" +
                      "<script type=\"text/javascript\">\n" +
                      "dojo.require(\"tapestry.namespace\");\n" +
+                     "tapestry.requestEncoding='utf-foo';" + SYSTEM_NEWLINE + 
                      "</script>" + SYSTEM_NEWLINE);
     }
 }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java?view=diff&rev=550053&r1=550052&r2=550053
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java Sat Jun 23 08:25:51 2007
@@ -37,6 +37,7 @@
         
         ResponseBuilder resp = newMock(ResponseBuilder.class);
         IEngineService engine = newMock(IEngineService.class);
+        IEngine cengine = newMock(IEngine.class);
         ILink link = newMock(ILink.class);
         IScript script = newMock(IScript.class);
         PageRenderSupport prs = newMock(PageRenderSupport.class);
@@ -74,6 +75,8 @@
         translator.renderContributions(comp, writer, cycle);
         validator.renderContributions(comp, writer, cycle);
 
+        expect(cycle.getEngine()).andReturn(cengine);
+        expect(cengine.getOutputEncoding()).andReturn("utf-8");
         expect(engine.getLink(eq(false), isA(DirectServiceParameter.class))).andReturn(link);
         expect(link.getURL()).andReturn("http://url");
 
@@ -94,7 +97,7 @@
         assertEquals(parms.size(), 4);
         assertEquals(parms.get("inputId"), "suggest");
         assertEquals(parms.get("updateId"), "suggestchoices");
-        assertEquals(parms.get("options"), "{\"onFailure\":\"tapestry.error\"}");
+        assertEquals(parms.get("options"), "{\"onFailure\":\"tapestry.error\",\"encoding\":\"utf-8\"}");
         assertEquals(parms.get("updateUrl"), "http://url");
 
         assertBuffer("<input type=\"text\" autocomplete=\"off\" " +
@@ -109,6 +112,7 @@
 
         ResponseBuilder resp = newMock(ResponseBuilder.class);
         IEngineService engine = newMock(IEngineService.class);
+        IEngine cengine = newMock(IEngine.class);
         ILink link = newMock(ILink.class);
         IScript script = newMock(IScript.class);
         PageRenderSupport prs = newMock(PageRenderSupport.class);
@@ -146,6 +150,8 @@
         translator.renderContributions(comp, writer, cycle);
         validator.renderContributions(comp, writer, cycle);
 
+        expect(cycle.getEngine()).andReturn(cengine);
+        expect(cengine.getOutputEncoding()).andReturn("utf-8");
         expect(engine.getLink(eq(false), isA(DirectServiceParameter.class))).andReturn(link);
         expect(link.getURL()).andReturn("http://url");
 
@@ -166,7 +172,7 @@
         assertEquals(parms.size(), 4);
         assertEquals(parms.get("inputId"), "suggest");
         assertEquals(parms.get("updateId"), "suggestchoices");
-        assertEquals(parms.get("options"), "{\"onFailure\":\"tapestry.error\"}");
+        assertEquals(parms.get("options"), "{\"onFailure\":\"tapestry.error\",\"encoding\":\"utf-8\"}");
         assertEquals(parms.get("updateUrl"), "http://url");
 
         assertBuffer("<textarea id=\"suggest\" name=\"suggest\">r2d2</textarea>" +