using System.Collections.Specialized;
using System.Globalization;
using System.Web.Hosting;
+using System.Web.J2EE;
+using System.ComponentModel;
namespace System.Web.UI
{
if (_PortletNamespace == null) {
IPortletResponse portletResponse = null;
- if (Context != null)
- portletResponse = Context.ServletResponse as IPortletResponse;
+ if (Context != null) {
+ string usePortletNamespace = J2EEUtils.GetInitParameterByHierarchy (Context.Servlet.getServletConfig (), "mainsoft.use.portlet.namespace");
+ if (usePortletNamespace == null || Boolean.Parse(usePortletNamespace))
+ portletResponse = Context.ServletResponse as IPortletResponse;
+ }
if (portletResponse != null)
_PortletNamespace = portletResponse.getNamespace ();
else if (_requestValueCollection != null && _requestValueCollection [PageNamespaceKey] != null)
return "theForm" + PortletNamespace;
}
}
+
+ internal bool IsMultiForm {
+ 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;
+ }
+ }
internal bool IsPortletRender
{
}
}
+ internal bool IsGetBack {
+ get {
+ return IsPostBack && IsPortletRender &&
+ (0 == String.Compare (Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase));
+ }
+ }
+
internal IPortletRenderResponse RenderResponse
{
get {
- if (!_renderResponseInit) {
- _renderResponse = Context.ServletResponse as IPortletRenderResponse;
- _renderResponseInit = true;
- }
+ if (!_renderResponseInit)
+ if (Context != null) {
+ _renderResponse = Context.ServletResponse as IPortletRenderResponse;
+ _renderResponseInit = true;
+ }
return _renderResponse;
}
}
public string CreateActionUrl (string url)
{
- if (url.StartsWith(RenderPageMark) || url.StartsWith(ActionPageMark))
+ if (url.StartsWith (RenderPageMark, StringComparison.Ordinal) || url.StartsWith (ActionPageMark, StringComparison.Ordinal))
return url;
if (RenderResponse != null)
Uri reqUrl = Request.Url;
string appPath = Request.ApplicationPath;
string currPage = Request.CurrentExecutionFilePath;
- if (currPage.StartsWith (appPath))
+ if (currPage.StartsWith (appPath, StringComparison.InvariantCultureIgnoreCase))
currPage = currPage.Substring (appPath.Length);
return PortletInternalUtils.mapPathIfInternal (url, reqUrl.Host, reqUrl.Port, reqUrl.Scheme, appPath, currPage);
}
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];
+ }
+ }
}
}