From: Argiris K. <be...@us...> - 2005-12-09 01:24:13
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28382/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Fixed a bug of 'ReflectUpdatedFormValues' when handling <input> tags. Disabled clientside validation for storing page modes as well. Updated 'ChangeLog' and 'Limitation' docs. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** AjaxPanel.cs 8 Dec 2005 18:15:02 -0000 1.32 --- AjaxPanel.cs 9 Dec 2005 01:23:59 -0000 1.33 *************** *** 245,253 **** } ! if (IsPageNoStoreMode) ! { ! //disabling clientside validation inside AjaxPanels (not yet handled correctly) ! DisableClientValidators(); ! } } #endregion --- 245,255 ---- } ! //disabling clientside validation inside AjaxPanels (not yet handled correctly) ! // Clientside validation throws errors when a validator becomes invisible ! // during an AjaxCall (the validator is gone while the script checking for ! // it remains). ! // TODO: Find a way to avoid problems of scripts that invisible controls ! // leave behind. ! DisableClientValidators(); } #endregion *************** *** 425,570 **** /// Parses all form input controls from the html, and checks if /// their values were updated (i.e. different from the current Request.Form values) - /// </summary> - /// <param name="html"></param> - protected bool ContainsUpdatedFormValues(string html) - { - NameValueCollection form = Context.Request.Form; - RegexOptions options = RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled; - - #region Check <input> tags - // - // Check <input> tags - // - Regex regEx = new System.Text.RegularExpressions.Regex("<input\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*/>", options); - MatchCollection matches = regEx.Matches(html); - for (int i=0; i<matches.Count; i++) - { - Match match = matches[i]; - CaptureCollection attrnames = match.Groups["attrname"].Captures; - CaptureCollection attrvalues = match.Groups["attrvalue"].Captures; - - Hashtable attrNameValues = new Hashtable(); - for (int j=0; j< attrnames.Count; j++) - { - attrNameValues.Add(attrnames[j].Value.ToLower(), attrvalues[j].Value); - } - - string type = (string)attrNameValues["type"]; - string name = (string)attrNameValues["name"]; - string value = attrNameValues.ContainsKey("value") ? (string)attrNameValues["value"] : string.Empty; - bool isChecked = attrNameValues.ContainsKey("checked"); - - if (type != null && name != null) - { - switch (type) - { - case "text": - case "password": - if (value != form[name]) - return true; - break; - case "checkbox": - if (isChecked != (form[name] != null)) - return true; - break; - case "radio": - if ((isChecked && form[name] != value) || (!isChecked && form[name] == value)) - return true; - break; - } - } - } - #endregion - - #region Check <textarea> tags - // - // Check <textarea> tags - // - regEx = new System.Text.RegularExpressions.Regex("<textarea\\s.*?name=\"(?<name>[-\\w]+)\".*?>(?<value>.*?)</textarea>", options); - matches = regEx.Matches(html); - for (int i=0; i<matches.Count; i++) - { - Match match = matches[i]; - string name = match.Groups["name"].Value; - string value = match.Groups["value"].Success ? match.Groups["value"].Value : string.Empty; - - if (value != form[name]) - return true; - } - #endregion - - #region Check <select> tags - // - // Check <select> tags - // - Regex regExSelect = new System.Text.RegularExpressions.Regex("<select\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>(?<options>.*?)</select>", options); - Regex regExOption = new System.Text.RegularExpressions.Regex("<option\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>.*?</option>", options); - matches = regExSelect.Matches(html); - for (int i=0; i<matches.Count; i++) - { - Match matchSelect = matches[i]; - CaptureCollection attrnamesSelect = matchSelect.Groups["attrname"].Captures; - CaptureCollection attrvaluesSelect = matchSelect.Groups["attrvalue"].Captures; - - Hashtable attrNameValuesSelect = new Hashtable(); - for (int j = 0; j < attrnamesSelect.Count; j++) - { - attrNameValuesSelect.Add(attrnamesSelect[j].Value.ToLower(), attrvaluesSelect[j].Value); - } - - string name = (string)attrNameValuesSelect["name"]; - bool multiple = attrNameValuesSelect.ContainsKey("multiple"); - bool isDropDown = !attrNameValuesSelect.ContainsKey("size"); - - if (name != null) - { - string serverValue = null; - - //now match the <option>s within this <select> tag - MatchCollection matchesOption = regExOption.Matches(matchSelect.Groups["options"].Value); - for (int j = 0; j < matchesOption.Count; j++) - { - Match matchOption = matchesOption[j]; - CaptureCollection attrnamesOption = matchOption.Groups["attrname"].Captures; - CaptureCollection attrvaluesOption = matchOption.Groups["attrvalue"].Captures; - - Hashtable attrNameValuesOption = new Hashtable(); - for (int k = 0; k < attrnamesOption.Count; k++) - { - attrNameValuesOption.Add(attrnamesOption[k].Value.ToLower(), attrvaluesOption[k].Value); - } - - string optValue = (string)attrNameValuesOption["value"]; //TODO: check value encodings etc. - bool optSelected = attrNameValuesOption.ContainsKey("selected"); - - if (!multiple) - { - //for dropdowns: start with picking first item - if (isDropDown && serverValue == null) - serverValue = optValue; - if (optSelected) - { - serverValue = optValue; - break; - } - } - else if (optSelected) - { - serverValue += (serverValue == null ? string.Empty : ",") + optValue; - } - } - - if (serverValue != form[name]) - return true; - } - } - #endregion - - return false; - } - - /// <summary> - /// Parses all form input controls from the html, and checks if - /// their values were updated (i.e. different from the current Request.Form values) /// and sends javascript commands to update the client's form values if necessary. /// </summary> --- 427,430 ---- *************** *** 589,592 **** --- 449,458 ---- } + // If the form element has the MagicAjax 'ExcludeFromPost' attribute + // set to 'true', ignore it. + if ( attrNameValues.ContainsKey("excludefrompost") + && (attrNameValues["excludefrompost"] as String).ToLower() == "true") + continue; + string tag = match.Groups["tag"].Value.ToLower(); string name = (string)attrNameValues["name"]; *************** *** 604,608 **** if (type != null) { ! string value = (string)attrNameValues["value"]; bool isChecked = attrNameValues.ContainsKey("checked"); --- 470,474 ---- if (type != null) { ! string value = attrNameValues.ContainsKey("value") ? (string)attrNameValues["value"] : String.Empty; bool isChecked = attrNameValues.ContainsKey("checked"); *************** *** 696,699 **** --- 562,567 ---- { string[] selections = form.GetValues(name); + if ( selections == null ) + selections = new string[0]; bool elemWritten = false; *************** *** 1157,1172 **** { string htmlFingerprint = Util.GetFingerprint(html); - - //previous code, commented by Argiris - // - //if (htmlFingerprint != (string)_controlHtmlFingerprints[con] - // || ContainsUpdatedFormValues(html)) - //{ - // // Its html rendering fingerprint has changed, - // // "reflect" its html on client. - // ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); - // _controlHtmlFingerprints[con] = htmlFingerprint; - //} - if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) { --- 1025,1028 ---- |