+2007-02-18 Eyal Alaluf <eyala@mainsoft.com>
+
+ * HtmlForm.cs: Under TARGET_J2EE use Page.RenderResponse instead of
+ GetRenderResponse.
+
2007-01-20 Miguel de Icaza <miguel@novell.com>
* HtmlHead.cs: comment out unused code, in particular metadata is
2007-01-14 Eyal Alaluf <eyala@mainsoft.com>
- * HtmlForm.cs, HtmlAnchor.cs: Added H2EE Portal support for TARGET_J2EE.
+ * HtmlForm.cs, HtmlAnchor.cs: Added J2EE Portal support for TARGET_J2EE.
2007-01-14 Eyal Alaluf <eyala@mainsoft.com>
action += Page.Request.QueryStringRaw;
#if TARGET_J2EE
- vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse();
- if (resp != null)
- action = resp.createActionURL(action);
+ // Allow the page to transform action to a portlet action url
+ if (Page.IsPortletRender)
+ action = Page.RenderResponse.createActionURL(action);
#endif
w.WriteAttribute ("name", Name);
{
PostBackOptions options = new PostBackOptions (this);
options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null);
-#if TARGET_J2EE
- vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse();
- if (resp != null && options.ActionUrl != null)
- options.ActionUrl = resp.createActionURL(options.ActionUrl);
-#endif
options.ValidationGroup = null;
options.Argument = "";
options.RequiresJavaScriptProtocol = false;
+2007-02-18 Eyal Alaluf <eyala@mainsoft.com>
+
+ * Button.cs, ImageButton.cs, LinkButton.cs: Hanlding of PostbackOptions for
+ TARGET_J2EE is now centralized in ClientScriptManager.
+ * TreeView.cs, DetailsView.cs, GridView.cs, TreeView.js, DetailsView.js,
+ GridView.js: Added a field to the controls JavaScript 'data' object. The
+ form is initialized to the page 'theForm'. This is used for J2EE portlets
+ callback support.
+
2006-02-18 Igor Zelmanovich <igorz@mainsoft.com>
* Wizard: fixed:
string script = string.Format ("var {0} = new Object ();\n", cgrid);\r
script += string.Format ("{0}.pageIndex = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (PageIndex));\r
script += string.Format ("{0}.uid = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (UniqueID));\r
+ script += string.Format ("{0}.form = {1};\n", cgrid, Page.theForm);\r
Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);\r
\r
// Make sure the basic script infrastructure is rendered\r
if (!gridData)\r
return null;\r
var clientData = gridData.pageIndex + '|' + evnt;\r
- WebForm_DoCallback (gridData.uid, clientData, DetailsView_ClientRender, ctrlId, DetailsView_ClientRender_Error);\r
+ WebForm_DoCallback (gridData.uid, clientData, DetailsView_ClientRender, ctrlId, DetailsView_ClientRender_Error, gridData.form);\r
}\r
\r
function DetailsView_ClientRender (data, ctx)\r
script += string.Format ("{0}.sortExp = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (SortExpression == null ? "" : SortExpression));
script += string.Format ("{0}.sortDir = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral ((int) SortDirection));
script += string.Format ("{0}.uid = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (UniqueID));
+ script += string.Format ("{0}.form = {1};\n", cgrid, Page.theForm);
Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);
// Make sure the basic script infrastructure is rendered
if (!gridData)
return null;
var clientData = gridData.pageIndex + '|' + escape (gridData.sortExp) + '|' + gridData.sortDir + '|' + evnt;
- WebForm_DoCallback (gridData.uid, clientData, GridView_ClientRender, ctrlId, GridView_ClientRender_Error);
+ WebForm_DoCallback (gridData.uid, clientData, GridView_ClientRender, ctrlId, GridView_ClientRender_Error, gridData.form);
}
function GridView_ClientRender (data, ctx)
{
PostBackOptions options = new PostBackOptions (this);
options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null);
-#if TARGET_J2EE
- vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse();
- if (resp != null && options.ActionUrl != null)
- options.ActionUrl = resp.createActionURL(options.ActionUrl);
-#endif
options.ValidationGroup = null;
options.Argument = "";
options.ClientSubmit = false;
{
PostBackOptions options = new PostBackOptions (this);
options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null);
-#if TARGET_J2EE
- vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse();
- if (resp != null && options.ActionUrl != null)
- options.ActionUrl = resp.createActionURL(options.ActionUrl);
-#endif
options.ValidationGroup = null;
options.Argument = "";
options.ClientSubmit = true;
}
if (Page != null) {
+ script += string.Format ("{0}.form = {1};\n", ctree, Page.theForm);
script += string.Format ("{0}.populateFromClient = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (PopulateNodesFromClient));
script += string.Format ("{0}.expandAlt = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (true, null)));
script += string.Format ("{0}.collapseAlt = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (false, null)));
var expand = node.style.display == "none";
if (tree.populateFromClient && expand && node.populated != true && (node.innerHTML.length == 0 || node.hasError)) {
- WebForm_DoCallback (tree.uid, nodeId, TreeView_PopulateCallback, treeId + " " + nodeId, TreeView_PopulateCallback)
+ WebForm_DoCallback (tree.uid, nodeId, TreeView_PopulateCallback, treeId + " " + nodeId, TreeView_PopulateCallback, tree.form)
return;
}
node.style.display = expand ? "block" : "none";
- var myForm = WebForm_GetFormFromCtrl (treeId);
- var inputStates = myForm [treeId + "_ExpandStates"];
+ var inputStates = tree.form [treeId + "_ExpandStates"];
TreeView_SetNodeFlag (inputStates, nodeId, expand);
if (tree.showImage) {
if (data != "*") {
node.innerHTML = data;
TreeView_ToggleExpand (idArray[0], idArray[1]);
- var myForm = WebForm_GetFormFromCtrl (idArray[0]);
- TreeView_SetNodeFlag (myForm [idArray[0] + "_PopulatedStates"], idArray[1], true);
+ TreeView_SetNodeFlag (tree.form [idArray[0] + "_PopulatedStates"], idArray[1], true);
} else {
if (tree.showImage && tree.noExpandImage != null) {
var image = document.getElementById (spanId + "_img");
+2007-02-18 Eyal Alaluf <eyala@mainsoft.com>
+
+ * Control.jvm.cs, Control.cs: Move TemplateSourceDirectory to .jvm file.
+ * Control.jvm.cs, Page.jvm.cs: Centralize Portlet specific API in Page.jvm
+ * Page.cs, Page.jvm.cs, ClientScriptManager.cs: Support for Http callbacks
+ for J2EE portlets.
+
2007-02-14 Igor Zelmanovich <igorz@mainsoft.com>
* Page.cs: for 2.0:
{
if (options == null)
throw new ArgumentNullException ("options");
-
+
if (options.ActionUrl == null && options.ValidationGroup == null && !options.TrackFocus &&
!options.AutoPostBack && !options.PerformValidation)
{
}
RegisterWebFormClientScript ();
-
- if (options.ActionUrl != null)
+
+ string actionUrl = options.ActionUrl;
+ if (actionUrl != null)
RegisterHiddenField (Page.PreviousPageID, page.Request.FilePath);
-
- return String.Format ("{0}WebForm_DoPostback({1},{2},{3},{4},{5},{6},{7},{8})",
- options.RequiresJavaScriptProtocol ? "javascript:" : "",
+
+ string prefix = options.RequiresJavaScriptProtocol ? "javascript:" : "";
+#if TARGET_J2EE
+ // Allow the page to transform ActionUrl to a portlet action url
+ if (actionUrl != null && page.PortletNamespace != null) {
+ actionUrl = page.CreateActionUrl(actionUrl);
+ prefix += "Portal";
+ }
+#endif
+
+ return String.Format ("{0}WebForm_DoPostback({1},{2},{3},{4},{5},{6},{7},{8},{9})",
+ prefix,
ClientScriptManager.GetScriptLiteral (options.TargetControl.UniqueID),
ClientScriptManager.GetScriptLiteral (options.Argument),
- ClientScriptManager.GetScriptLiteral (options.ActionUrl),
+ ClientScriptManager.GetScriptLiteral (actionUrl),
ClientScriptManager.GetScriptLiteral (options.AutoPostBack),
ClientScriptManager.GetScriptLiteral (options.PerformValidation),
ClientScriptManager.GetScriptLiteral (options.TrackFocus),
ClientScriptManager.GetScriptLiteral (options.ClientSubmit),
- ClientScriptManager.GetScriptLiteral (options.ValidationGroup)
+ ClientScriptManager.GetScriptLiteral (options.ValidationGroup),
+ page.theForm
);
}
{
RegisterWebFormClientScript ();
- return string.Format ("WebForm_DoCallback('{0}',{1},{2},{3},{4},{5})", target, argument, clientCallback, context, ((clientErrorCallback == null) ? "null" : clientErrorCallback), (useAsync ? "true" : "false"));
+ return string.Format ("WebForm_DoCallback('{0}',{1},{2},{3},{4},{5},{6})", target, argument, clientCallback, context, ((clientErrorCallback == null) ? "null" : clientErrorCallback), (useAsync ? "true" : "false"), page.theForm);
}
#endif
}
#endif
-#if TARGET_JVM
- private string _templateSourceDir;
- public virtual string TemplateSourceDirectory
- {
- get
- {
- int location = 0;
- if (_templateSourceDir == null) {
- string tempSrcDir = _appRelativeTemplateSourceDirectory;
- if (tempSrcDir == null && Parent != null)
- tempSrcDir = Parent.TemplateSourceDirectory;
- if (tempSrcDir != null && tempSrcDir.Length > 1) {
- location = tempSrcDir.IndexOf ('/', 1);
- if (location != -1)
- tempSrcDir = tempSrcDir.Substring (location + 1);
- else
- tempSrcDir = string.Empty;
- }
- string answer = HttpRuntime.AppDomainAppVirtualPath;
- if (tempSrcDir == null)
- tempSrcDir = "";
-
- if (tempSrcDir.Length > 0 && tempSrcDir [tempSrcDir.Length - 1] == '/')
- tempSrcDir = tempSrcDir.Substring (0, tempSrcDir.Length - 1);
-
- if (tempSrcDir.StartsWith ("/") || tempSrcDir.Length == 0)
- _templateSourceDir = answer + tempSrcDir;
- else
- _templateSourceDir = answer + "/" + tempSrcDir;
- }
- return _templateSourceDir;
- }
- }
-
-#else
+#if !TARGET_J2EE
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
[WebSysDescription ("A virtual directory containing the parent of the control.")]
Control LookForControlByName (string id)
{
#if TARGET_J2EE
- if (this == _page && id != null && id == _page.PortletNamespace)
+ if (this == Page && id != null && id == Page.PortletNamespace)
return this;
#endif
if (!HasControls ())
string absoluteUrl = ResolveUrl (relativeUrl);
#if TARGET_J2EE
// There are no relative paths when rendering a J2EE portlet
- if (IsPortletRender)
+ if (Page != null && Page.PortletNamespace != null)
return absoluteUrl;
#endif
if (Context != null && Context.Request != null) {
{\r
public partial class Control\r
{\r
- internal bool IsPortletRender\r
+ private string _templateSourceDir;\r
+\r
+ public virtual string TemplateSourceDirectory\r
{\r
- get {\r
- return GetRenderResponse() != null;\r
+ get\r
+ {\r
+ int location = 0;\r
+ if (_templateSourceDir == null) {\r
+ string tempSrcDir = _appRelativeTemplateSourceDirectory;\r
+ if (tempSrcDir == null && Parent != null)\r
+ tempSrcDir = Parent.TemplateSourceDirectory;\r
+ if (tempSrcDir != null && tempSrcDir.Length > 1) {\r
+ location = tempSrcDir.IndexOf ('/', 1);\r
+ if (location != -1)\r
+ tempSrcDir = tempSrcDir.Substring (location + 1);\r
+ else\r
+ tempSrcDir = string.Empty;\r
+ }\r
+ string answer = HttpRuntime.AppDomainAppVirtualPath;\r
+ if (tempSrcDir == null)\r
+ tempSrcDir = "";\r
+\r
+ if (tempSrcDir.Length > 0 && tempSrcDir [tempSrcDir.Length - 1] == '/')\r
+ tempSrcDir = tempSrcDir.Substring (0, tempSrcDir.Length - 1);\r
+\r
+ if (tempSrcDir.StartsWith ("/") || tempSrcDir.Length == 0)\r
+ _templateSourceDir = answer + tempSrcDir;\r
+ else\r
+ _templateSourceDir = answer + "/" + tempSrcDir;\r
+ }\r
+ return _templateSourceDir;\r
}\r
}\r
\r
+\r
// Add a variant for specifying use of portlet resolveRenderUrl\r
internal string ResolveUrl (string relativeUrl, bool usePortletRenderResolve)\r
{\r
relativeUrl = ResolveUrl (relativeUrl);\r
- if (usePortletRenderResolve) {\r
- IPortletRenderResponse resp = GetRenderResponse ();\r
- if (resp != null)\r
- relativeUrl = resp.createRenderURL (relativeUrl);\r
- }\r
+ if (usePortletRenderResolve && Page != null)\r
+ relativeUrl = Page.CreateRenderUrl (relativeUrl);\r
return relativeUrl;\r
}\r
\r
internal string ResolveClientUrl (string relativeUrl, bool usePortletRenderResolve)\r
{\r
relativeUrl = ResolveClientUrl (relativeUrl);\r
- if (usePortletRenderResolve) {\r
- IPortletRenderResponse resp = GetRenderResponse ();\r
- if (resp != null)\r
- relativeUrl = resp.createRenderURL (relativeUrl);\r
- }\r
+ if (usePortletRenderResolve && Page != null)\r
+ relativeUrl = Page.CreateRenderUrl (relativeUrl);\r
return relativeUrl;\r
}\r
-\r
- internal IPortletRenderResponse GetRenderResponse ()\r
- {\r
- return Context.ServletResponse as IPortletRenderResponse;\r
- }\r
}\r
}\r
writer.WriteLine ("\tvar {0};\n\tif (document.getElementById) {{ {0} = document.getElementById ('{1}'); }}", theForm, formUniqueID);
writer.WriteLine ("\telse {{ {0} = document.{1}; }}", theForm, formUniqueID);
writer.WriteLine ("\t{0}.isAspForm = true;", theForm);
+#if TARGET_J2EE
+ string serverUrl = Context.ServletResponse.encodeURL (Request.RawUrl);
+ writer.WriteLine ("\t{0}.serverURL = {1};", theForm, ClientScriptManager.GetScriptLiteral (serverUrl));
+#endif
}
internal void OnFormRender (HtmlTextWriter writer, string formUniqueID)
}
[EditorBrowsable (EditorBrowsableState.Never)]
-#if NET_2_0 || TARGET_JVM
+#if NET_2_0
public virtual void ProcessRequest (HttpContext context)
#else
public void ProcessRequest (HttpContext context)
#if NET_2_0
_lifeCycle = PageLifeCycle.SaveStateComplete;
OnSaveStateComplete (EventArgs.Empty);
-#endif
-
#if TARGET_J2EE
- if (SaveViewStateForNextPortletRender())
+ if (OnSaveStateCompleteForPortlet ())
return;
-#endif
+#endif // TARGET_J2EE
+#endif // NET_2_0
#if NET_2_0
_lifeCycle = PageLifeCycle.Render;
//
using vmw.@internal.j2ee;
-using javax.servlet.http;\r
-using System.Collections.Specialized;\r
+using javax.servlet.http;
+using System.Collections.Specialized;
using System.Globalization;
using System.Web.Hosting;
{
public partial class Page
{
+ const string PageNamespaceKey = "__PAGENAMESPACE";
+ const string RenderPageMark = "vmw.render.page=";
+ const string ActionPageMark = "vmw.action.page=";
+ static readonly string NextActionPageKey = PortletInternalUtils.NextActionPage;
+ static readonly string NextRenderPageKey = PortletInternalUtils.NextRenderPage;
+
bool _emptyPortletNamespace = false;
string _PortletNamespace = null;
+ bool _renderResponseInit = false;
+ IPortletRenderResponse _renderResponse = null;
internal string PortletNamespace
{
return null;
if (_PortletNamespace == null) {
- IPortletResponse portletResponse = Context.ServletResponse as IPortletResponse;
+ IPortletResponse portletResponse = null;
+ if (Context != null)
+ portletResponse = Context.ServletResponse as IPortletResponse;
if (portletResponse != null)
_PortletNamespace = portletResponse.getNamespace ();
+ else if (_requestValueCollection != null && _requestValueCollection [PageNamespaceKey] != null)
+ _PortletNamespace = _requestValueCollection [PageNamespaceKey];
+
_emptyPortletNamespace = _PortletNamespace == null;
}
return _PortletNamespace;
}
}
- internal bool SaveViewStateForNextPortletRender ()
+ internal bool IsPortletRender
+ {
+ get {
+ return RenderResponse != null;
+ }
+ }
+
+ internal IPortletRenderResponse RenderResponse
+ {
+ get {
+ if (!_renderResponseInit) {
+ _renderResponse = Context.ServletResponse as IPortletRenderResponse;
+ _renderResponseInit = true;
+ }
+ return _renderResponse;
+ }
+ }
+
+ public string CreateRenderUrl (string url)
+ {
+ if (RenderResponse != null)
+ return RenderResponse.createRenderURL (url);
+ if (PortletNamespace == null)
+ return url;
+
+ string internalUrl = RemoveAppPathIfInternal (url);
+ if (internalUrl == null)
+ return url;
+
+ PostBackOptions options = new PostBackOptions (this);
+ options.ActionUrl = RenderPageMark + internalUrl;
+ options.RequiresJavaScriptProtocol = true;
+ return ClientScript.GetPostBackEventReference (options);
+ }
+
+ public string CreateActionUrl (string url)
+ {
+ if (url.StartsWith(RenderPageMark) || url.StartsWith(ActionPageMark))
+ return url;
+
+ if (RenderResponse != null)
+ return RenderResponse.createActionURL (url);
+ if (PortletNamespace == null)
+ return url;
+
+ Uri requestUrl = Request.Url;
+ string internalUrl = RemoveAppPathIfInternal (url);
+ if (internalUrl == null)
+ return url;
+
+ return ActionPageMark + internalUrl;
+ }
+
+ private string RemoveAppPathIfInternal (string url)
{
+ Uri reqUrl = Request.Url;
+ string appPath = Request.ApplicationPath;
+ string currPage = Request.CurrentExecutionFilePath;
+ if (currPage.StartsWith (appPath))
+ currPage = currPage.Substring (appPath.Length);
+ return PortletInternalUtils.mapPathIfInternal (url, reqUrl.Host, reqUrl.Port, reqUrl.Scheme, appPath, currPage);
+ }
+
+ internal bool OnSaveStateCompleteForPortlet ()
+ {
+ if (PortletNamespace != null) {
+ ClientScript.RegisterHiddenField (PageNamespaceKey, PortletNamespace);
+ ClientScript.RegisterHiddenField (NextActionPageKey, "");
+ ClientScript.RegisterHiddenField (NextRenderPageKey, "");
+ }
+
IPortletActionResponse resp = Context.ServletResponse as IPortletActionResponse;
IPortletActionRequest req = Context.ServletRequest as IPortletActionRequest;
if (req == null)
{
MyPage p = new MyPage ();
ClientScriptManager cs = p.ClientScript;
- StringBuilder context1 = new StringBuilder ();
- context1.Append ("function ReceiveServerData1(arg, context)");
- context1.Append ("{");
- context1.Append ("Message1.innerText = arg;");
- context1.Append ("value1 = arg;");
- context1.Append ("}");
+ StringBuilder func = new StringBuilder ();
+ func.Append ("function ReceiveServerData1(arg, context)");
+ func.Append ("{");
+ func.Append ("Message1.innerText = arg;");
+ func.Append ("value1 = arg;");
+ func.Append ("}");
// Define callback references.
- String cbReference = cs.GetCallbackEventReference (p, "arg",
- "ReceiveServerData1", context1.ToString ());
- Assert.AreEqual ("WebForm_DoCallback('__Page',arg,ReceiveServerData1,function ReceiveServerData1(arg, context){Message1.innerText = arg;value1 = arg;},null,false)", cbReference, "GetCallbackEventReferenceFail1");
+ String cbReference = cs.GetCallbackEventReference (p, "callArg",
+ func.ToString (), "ReceiveServerData1Ctx");
+ Assert.IsTrue (cbReference.IndexOf ("callArg") != -1, "GetCallbackEventReferenceFail1_arg");
+ Assert.IsTrue (cbReference.IndexOf (func.ToString ()) != -1, "GetCallbackEventReferenceFail1_callback");
+ Assert.IsTrue (cbReference.IndexOf ("ReceiveServerData1Ctx") != -1, "GetCallbackEventReferenceFail1_context");
}
[Test]
{
MyPage p = new MyPage ();
ClientScriptManager cs = p.ClientScript;
- StringBuilder context1 = new StringBuilder ();
- context1.Append ("function ReceiveServerData1(arg, context)");
- context1.Append ("{");
- context1.Append ("Message1.innerText = arg;");
- context1.Append ("value1 = arg;");
- context1.Append ("}");
+ StringBuilder func = new StringBuilder ();
+ func.Append ("function ReceiveServerData1(arg, context)");
+ func.Append ("{");
+ func.Append ("Message1.innerText = arg;");
+ func.Append ("value1 = arg;");
+ func.Append ("}");
// Define callback references.
- String cbReference = cs.GetCallbackEventReference (p, "arg",
- "ReceiveServerData1", context1.ToString (), true);
- Assert.AreEqual ("WebForm_DoCallback('__Page',arg,ReceiveServerData1,function ReceiveServerData1(arg, context){Message1.innerText = arg;value1 = arg;},null,true)", cbReference, "GetCallbackEventReferenceFail2");
+ String cbReference = cs.GetCallbackEventReference (p, "callArg",
+ func.ToString (), "ReceiveServerData1Ctx", true);
+ Assert.IsTrue (cbReference.IndexOf ("callArg") != -1, "GetCallbackEventReferenceFail2_arg");
+ Assert.IsTrue (cbReference.IndexOf (func.ToString ()) != -1, "GetCallbackEventReferenceFail2_callback");
+ Assert.IsTrue (cbReference.IndexOf ("ReceiveServerData1Ctx") != -1, "GetCallbackEventReferenceFail2_context");
+ String cbReference2 = cs.GetCallbackEventReference (p, "arg",
+ func.ToString (), "ReceiveServerData1Ctx", false);
+ // Check that we get different results when useAsync differs.
+ Assert.IsTrue (cbReference != cbReference2, "GetCallbackEventReferenceFail2_useAsync");
}
[Test]
{
MyPage p = new MyPage ();
ClientScriptManager cs = p.ClientScript;
- StringBuilder context1 = new StringBuilder ();
- context1.Append ("function ReceiveServerData1(arg, context)");
- context1.Append ("{");
- context1.Append ("Message1.innerText = arg;");
- context1.Append ("value1 = arg;");
- context1.Append ("}");
+ StringBuilder func = new StringBuilder ();
+ func.Append ("function ReceiveServerData1(arg, context)");
+ func.Append ("{");
+ func.Append ("Message1.innerText = arg;");
+ func.Append ("value1 = arg;");
+ func.Append ("}");
// Define callback references.
- String cbReference = cs.GetCallbackEventReference (p, "arg",
- "ReceiveServerData1", context1.ToString (), "ErrorCallback", false);
- Assert.AreEqual ("WebForm_DoCallback('__Page',arg,ReceiveServerData1,function ReceiveServerData1(arg, context){Message1.innerText = arg;value1 = arg;},ErrorCallback,false)", cbReference, "GetCallbackEventReferenceFail3");
+ String cbReference = cs.GetCallbackEventReference (p, "callArg",
+ func.ToString (), "ReceiveServerData1Ctx", "ErrorCallback", false);
+ Assert.IsTrue (cbReference.IndexOf ("callArg") != -1, "GetCallbackEventReferenceFail3_arg");
+ Assert.IsTrue (cbReference.IndexOf (func.ToString ()) != -1, "GetCallbackEventReferenceFail3_callback");
+ Assert.IsTrue (cbReference.IndexOf ("ReceiveServerData1Ctx") != -1, "GetCallbackEventReferenceFail3_context");
+ Assert.IsTrue (cbReference.IndexOf ("ErrorCallback") != -1, "GetCallbackEventReferenceFail3_errorCallback");
}
[Test]
{
MyPage p = new MyPage ();
ClientScriptManager cs = p.ClientScript;
- String result = cs.GetPostBackEventReference (new PostBackOptions (p, "args"));
- Assert.AreEqual ("__doPostBack('__Page','args')", result, "GetPostBackEventReference#1");
+ String result = cs.GetPostBackEventReference (new PostBackOptions (p, "args1"));
+ Assert.IsTrue (result.IndexOf(p.ClientID) != -1, "GetPostBackEventReference#1_targetEvent");
+ Assert.IsTrue (result.IndexOf("args1") != -1, "GetPostBackEventReference#1_targetArgs");
}
[Test]
{
MyPage p = new MyPage ();
ClientScriptManager cs = p.ClientScript;
- String result = cs.GetPostBackEventReference (p, "args");
- Assert.AreEqual ("__doPostBack('__Page','args')", result, "GetPostBackEventReference#2");
+ String result = cs.GetPostBackEventReference (p, "args1");
+ Assert.IsTrue (result.IndexOf(p.ClientID) != -1, "GetPostBackEventReference#2_targetEvent");
+ Assert.IsTrue (result.IndexOf("args1") != -1, "GetPostBackEventReference#2_targetArgs");
}
[Test]
{
MyPage p = new MyPage ();
ClientScriptManager cs = p.ClientScript;
- String hyperlink = cs.GetPostBackClientHyperlink (p, "args");
- Assert.AreEqual ("javascript:__doPostBack('__Page','args')", hyperlink, "GetPostBackClientHyperlink");
+ String hyperlink = cs.GetPostBackClientHyperlink (p, "args1");
+ Assert.IsTrue (hyperlink.IndexOf("javascript:") != -1, "GetPostBackClientHyperlink_javaScript");
+ Assert.IsTrue (hyperlink.IndexOf(p.ClientID) != -1, "GetPostBackClientHyperlink_targetEvent");
+ Assert.IsTrue (hyperlink.IndexOf("args1") != -1, "GetPostBackClientHyperlink_targetArgs");
}
[Test]
+2007-02-18 Eyal Alaluf <eyala@mainsoft.com>
+
+ * webform.js: Adding an optional parameter for passing the form to all JS
+ methods. This is needed to support Http callbacks for J2EE portlets.
+
2007-02-18 Igor Zelmanovich <igorz@mainsoft.com>
* WebUIValidation_2.0.js:
}
}
-function WebForm_DoPostback (id, par, url, apb, pval, tf, csubm, vg)
+// This function is only used in the context of TARGET_J2EE for portlets
+function PortalWebForm_DoPostback (id, par, url, apb, pval, tf, csubm, vg, currForm)
{
- var currForm = WebForm_GetFormFromCtrl (id);
-
+ if (url != null) {
+ currForm = WebForm_GetFormFromCtrl (id, currForm);
+ if (url.indexOf ("vmw.action.page=") == 0) {
+ currForm.__NEXTVMWACTIONPAGE.value = url.substring ("vmw.action.page=".length);
+ url = currForm.action;
+ }
+ else if (url.indexOf ("vmw.render.page=") == 0)
+ {
+ currForm.__NEXTVMWRENDERPAGE.value = url.substring ("vmw.render.page=".length);
+ currForm.submit ();
+ return;
+ }
+ }
+ return WebForm_DoPostback (id, par, url, apb, pval, tf, csubm, vg, currForm);
+}
+function WebForm_DoPostback (id, par, url, apb, pval, tf, csubm, vg, currForm)
+{
+ currForm = WebForm_GetFormFromCtrl (id, currForm);
+
if (typeof(SetValidatorContext) == "function")
SetValidatorContext (currForm);
if (pval && typeof(Page_ClientValidate) == "function")
validationResult = Page_ClientValidate(vg);
- if (validationResult) {
- if (url != null)
- currForm.action = url;
- }
+ if (validationResult && url != null)
+ currForm.action = url;
if (csubm)
currForm.__doPostBack (id, par);
}
-function WebForm_DoCallback (id, arg, callback, ctx, errorCallback)
+function WebForm_DoCallback (id, arg, callback, ctx, errorCallback, currForm)
{
- var currForm = WebForm_GetFormFromCtrl (id);
+ currForm = WebForm_GetFormFromCtrl (id, currForm);
var qs = WebForm_getFormData (currForm) + "__CALLBACKTARGET=" + id + "&__CALLBACKARGUMENT=" + encodeURIComponent(arg);
if (currForm["__EVENTVALIDATION"]) qs += "&__EVENTVALIDATION=" + encodeURIComponent(currForm["__EVENTVALIDATION"].value);
- WebForm_httpPost (document.URL, qs, function (httpPost) { WebForm_ClientCallback (httpPost, ctx, callback, errorCallback); });
+ WebForm_httpPost (currForm.serverURL || document.URL, qs, function (httpPost) { WebForm_ClientCallback (httpPost, ctx, callback, errorCallback, currForm); });
}
-function WebForm_ClientCallback (httpPost, ctx, callback, errorCallback)
+function WebForm_ClientCallback (httpPost, ctx, callback, errorCallback, currForm)
{
var doc = httpPost.responseText;
if (doc.charAt(0) == "e") {
if (!isNaN(validationFieldLength)) {
var validationField = doc.substring(separatorIndex + 1, separatorIndex + validationFieldLength + 1);
if (validationField != "") {
- var validationFieldElement = theForm["__EVENTVALIDATION"];
+ var validationFieldElement = currForm["__EVENTVALIDATION"];
if (!validationFieldElement) {
validationFieldElement = document.createElement("INPUT");
validationFieldElement.type = "hidden";
validationFieldElement.name = "__EVENTVALIDATION";
- theForm.appendChild(validationFieldElement);
+ currForm.appendChild(validationFieldElement);
}
validationFieldElement.value = validationField;
}
setTimeout (function () { httpPost.send (data); }, 10);
}
-function WebForm_GetFormFromCtrl (id)
+function WebForm_GetFormFromCtrl (id, currForm)
{
+ if (currForm)
+ return currForm;
+
// We need to translate the id from ASPX UniqueID to its ClientID.
var ctrl = WebForm_GetElementById (id.replace(/\$/g, "_"));
while (ctrl != null) {