New tests, update
[mono.git] / mcs / class / System.Web / System.Web.UI / Page.jvm.cs
index 28232d547ffd09bb2760f5dc75b597e89234bc7f..9fd544b58b5753a1498e23f408518e402747fb84 100644 (file)
@@ -80,11 +80,11 @@ namespace System.Web.UI
                }
                
                internal bool IsMultiForm {
-                       get {\r
-                               Mainsoft.Web.Configuration.PagesSection pageSection = (Mainsoft.Web.Configuration.PagesSection) System.Web.Configuration.WebConfigurationManager.GetSection ("mainsoft.web/pages");\r
-                               if (pageSection != null)\r
-                                       return pageSection.MultiForm;\r
-                               return false;\r
+                       get {
+                               Mainsoft.Web.Configuration.PagesSection pageSection = (Mainsoft.Web.Configuration.PagesSection) System.Web.Configuration.WebConfigurationManager.GetSection ("mainsoft.web/pages");
+                               if (pageSection != null)
+                                       return pageSection.MultiForm;
+                               return false;
                        }
                }
 
@@ -181,11 +181,49 @@ namespace System.Web.UI
                                if (ClientScript.hiddenFields != null)
                                        foreach (string key in ClientScript.hiddenFields.Keys)
                                                resp.setRenderParameter (key, (string) ClientScript.hiddenFields [key]);
+
+                               if (is_validated && Validators.Count > 0) {
+                                       string validatorsState = GetValidatorsState ();
+#if DEBUG
+                                       Console.WriteLine ("__VALIDATORSSTATE: " + validatorsState);
+#endif
+                                       if (!String.IsNullOrEmpty (validatorsState))
+                                               resp.setRenderParameter ("__VALIDATORSSTATE", validatorsState);
+                               }
                        }
 
                        // Stop processing only if we are handling processAction. If we
                        // are handling a postback from render then fall through.
                        return req.processActionOnly ();
                }
+
+               string GetValidatorsState () {
+                       bool [] validatorsState = new bool [Validators.Count];
+                       bool isValid = true;
+                       for (int i = 0; i < Validators.Count; i++) {
+                               IValidator val = Validators [i];
+                               if (!val.IsValid)
+                                       isValid = false;
+                               else
+                                       validatorsState [i] = true;
+                       }
+                       if (isValid)
+                               return null;
+
+                       return GetFormatter ().Serialize (validatorsState);
+               }
+
+               void RestoreValidatorsState () {
+                       string validatorsStateSerialized = Request.Form ["__VALIDATORSSTATE"];
+                       if (String.IsNullOrEmpty (validatorsStateSerialized))
+                               return;
+
+                       is_validated = true;
+                       bool [] validatorsState = (bool []) GetFormatter ().Deserialize (validatorsStateSerialized);
+                       for (int i = 0; i < Math.Min (validatorsState.Length, Validators.Count); i++) {
+                               IValidator val = Validators [i];
+                               val.IsValid = validatorsState [i];
+                       }
+               }
        }
 }