From: Argiris K. <be...@us...> - 2005-11-21 12:18:45
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2251/Core Modified Files: MagicAjaxModule.cs Util.cs Web.config Log Message: Replaced RBS_Control_Stores with a single field storing the form's html. Added 'tracing' configuration option, used to monitor the traffic of AjaxCalls. Added a check that does not enable MagicAjax for browsers other than IE and Firefox. Index: Web.config =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Web.config,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Web.config 20 Nov 2005 20:04:24 -0000 1.4 --- Web.config 21 Nov 2005 12:18:36 -0000 1.5 *************** *** 11,14 **** --- 11,17 ---- If omitted, the embedded "AjaxCallObject.js" file is used (default). example: <magicAjax ajaxCallScriptPath="~/script" /> + tracing - "true" : When an AjaxCall is invoked a popup window displays the data that were sent + to the server and the data that the client received. Used to monitor the traffic of AjaxCalls. + "false" : tracing is disabled (Default). pageStore/mode - "NoStore" : Doesn't store the page object, it is recreated for each AjaxCall "Session" : Saves the page object in session, works only for "InProc" SessionState *************** *** 27,34 **** limit is reached. Default is false pageStore/outputCompareMode - "HashCode" : Use String.GetHashCode() to find changed Html output ! "MD5" : Use MD5 hashing to find changed Html output (slower, but practically no collisions) "FullHtml" : Use the complete Html output to find changes (for debugging purposes only) Default is "HashCode" --> ! <magicAjax> <pageStore mode="NoStore" --- 30,38 ---- limit is reached. Default is false pageStore/outputCompareMode - "HashCode" : Use String.GetHashCode() to find changed Html output ! "MD5" : Use MD5 hashing to find changed Html output (slower and larger in size, but practically no collisions) "FullHtml" : Use the complete Html output to find changes (for debugging purposes only) Default is "HashCode" --> ! <magicAjax ! tracing="false"> <pageStore mode="NoStore" Index: Util.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Util.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Util.cs 20 Nov 2005 20:04:24 -0000 1.4 --- Util.cs 21 Nov 2005 12:18:36 -0000 1.5 *************** *** 24,39 **** case MagicAjax.Configuration.OutputCompareMode.FullHtml: return input; - break; case MagicAjax.Configuration.OutputCompareMode.HashCode: return input.GetHashCode().ToString("X2"); - break; case MagicAjax.Configuration.OutputCompareMode.MD5: byte[] inputBytes = UnicodeEncoding.Default.GetBytes(input); byte[] hashedBytes = new MD5CryptoServiceProvider().ComputeHash(inputBytes); return Convert.ToBase64String(hashedBytes); - break; default: return input; - break; } } --- 24,35 ---- Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** MagicAjaxModule.cs 20 Nov 2005 20:04:24 -0000 1.19 --- MagicAjaxModule.cs 21 Nov 2005 12:18:36 -0000 1.20 *************** *** 146,149 **** --- 146,155 ---- if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; + // Enable AJAX only for IE and Firefox, to be on the safe side. + // Other browsers will get a plain postback page. + if (page.Request.Browser.Type != "IE6" + && page.Request.Browser.Type != "Firefox") + return; + string STARTUP_SCRIPT_FORMAT = @" <script language='javascript'> *************** *** 151,155 **** alert(""Unable to find script library '{0}/{1}'. Copy the file to the required location, or change the 'ajaxCallScriptPath' setting at magicAjax section of web.config.""); else ! AJAXCbo.HookAjaxCall({2},{3}); </script>"; --- 157,161 ---- alert(""Unable to find script library '{0}/{1}'. Copy the file to the required location, or change the 'ajaxCallScriptPath' setting at magicAjax section of web.config.""); else ! AJAXCbo.HookAjaxCall({2},{3},{4},{5}); </script>"; *************** *** 179,184 **** bool pageIsStored = (_config.PageStore.Mode != PageStoreMode.NoStore); ! bool unloadStoredPage = _config.PageStore.UnloadStoredPage; ! page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower())); if ( pageIsStored ) --- 185,189 ---- bool pageIsStored = (_config.PageStore.Mode != PageStoreMode.NoStore); ! string pageStateCacheName; if ( pageIsStored ) *************** *** 193,197 **** --- 198,221 ---- page.RegisterHiddenField (PageKeyFieldName, key); } + + // At storing modes we don't mess with the ViewState field, so use + // a different name for the hidden field at each page request so that + // it can be reset for Firefox's "Refresh". + pageStateCacheName = "__PAGE_STATE_CACHE" + DateTime.Now.Ticks; + } + else + { + // Firefox, when performing a refresh, loads the page but keeps any changed INPUT + // field values. Thus, the html of __PAGE_STATE_CACHE is restored + // as if the page was loaded because of the browser's "Back Button". + // We cannot avoid this because Firefox also keeps any changes that occured + // to ViewState, so we need the controls to keep their changes. + pageStateCacheName = "__PAGE_STATE_CACHE"; } + + page.RegisterHiddenField(pageStateCacheName, String.Empty); + + bool unloadStoredPage = _config.PageStore.UnloadStoredPage; + page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower(), String.Format("document.all[\"{0}\"]", pageStateCacheName), _config.Tracing.ToString().ToLower())); } } *************** *** 409,416 **** { case PageStoreMode.Session: ! return String.Format("__AJAX_{0}_{1}", page.Request.FilePath, page.GetTypeHashCode()); case PageStoreMode.Cache: ! return String.Format("__AJAX_{0}_{1}_{2}", _context.Session.SessionID, page.Request.FilePath, page.GetTypeHashCode()); default: --- 433,440 ---- { case PageStoreMode.Session: ! return String.Format("__AJAX_{0}_{1}", page.Request.FilePath, page.GetTypeHashCode().ToString("X2")); case PageStoreMode.Cache: ! return String.Format("__AJAX_{0}_{1}_{2}", _context.Session.SessionID, page.Request.FilePath, page.GetTypeHashCode().ToString("X2")); default: |