Author: igorz
Date: 2007-12-11 05:21:21 -0500 (Tue, 11 Dec 2007)
New Revision: 91080

Modified:
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.cs
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jsf.cs
Log:
make Callback works with JSF

Modified: branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.cs
===================================================================
--- branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.cs    
2007-12-11 10:14:57 UTC (rev 91079)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.cs    
2007-12-11 10:21:21 UTC (rev 91080)
@@ -1366,7 +1366,8 @@
                ProcessPostData ();
                ProcessRaiseChangedEvents ();
                ProcessRaisePostBackEvents ();
-               ProcessLoadComplete ();
+               if (ProcessLoadComplete ())
+                       return;
 #if TARGET_J2EE
                if (getFacesContext () != null)
                        return;
@@ -1473,7 +1474,7 @@
                }
        }
 
-       void ProcessLoadComplete() {
+       bool ProcessLoadComplete() {
                
 #if NET_2_0
                _lifeCycle = PageLifeCycle.LoadComplete;
@@ -1482,14 +1483,21 @@
                Trace.Write ("aspx.page", "End LoadComplete");
 
                if (IsCrossPagePostBack)
-                       return;
+                       return true;
 
                if (IsCallback) {
+#if TARGET_J2EE
+                       if (getFacesContext () != null) {
+                               _callbackTarget = GetCallbackTarget ();
+                               ProcessRaiseCallbackEvent (_callbackTarget, ref 
_callbackEventError);
+                               return true;
+                       }
+#endif
                        string result = ProcessCallbackData ();
                        HtmlTextWriter callbackOutput = new HtmlTextWriter 
(Response.Output);
                        callbackOutput.Write (result);
                        callbackOutput.Flush ();
-                       return;
+                       return true;
                }
 
                _lifeCycle = PageLifeCycle.PreRender;
@@ -1518,7 +1526,7 @@
                OnSaveStateComplete (EventArgs.Empty);
                Trace.Write ("aspx.page", "End SaveStateComplete");
 #endif // NET_2_0
-       
+               return false;
        }
 
        internal void RenderPage () {
@@ -2111,6 +2119,13 @@
        
        string ProcessCallbackData ()
        {
+               ICallbackEventHandler target = GetCallbackTarget ();
+               string callbackEventError = String.Empty;
+               ProcessRaiseCallbackEvent (target, ref callbackEventError);
+               return ProcessGetCallbackResult (target, callbackEventError);
+       }
+
+       ICallbackEventHandler GetCallbackTarget () {
                string callbackTarget = _requestValueCollection 
[CallbackSourceID];
                if (callbackTarget == null || callbackTarget.Length == 0)
                        throw new HttpException ("Callback target not 
provided.");
@@ -2119,9 +2134,10 @@
                ICallbackEventHandler target = targetControl as 
ICallbackEventHandler;
                if (target == null)
                        throw new HttpException (string.Format ("Invalid 
callback target '{0}'.", callbackTarget));
+               return target;
+       }
 
-               string callbackEventError = String.Empty;
-               string callBackResult;
+       void ProcessRaiseCallbackEvent (ICallbackEventHandler target, ref 
string callbackEventError) {
                string callbackArgument = _requestValueCollection 
[CallbackArgumentID];
 
                try {
@@ -2130,7 +2146,10 @@
                catch (Exception ex) {
                        callbackEventError = String.Format ("e{0}", ex.Message);
                }
-               
+       }
+
+       string ProcessGetCallbackResult (ICallbackEventHandler target, string 
callbackEventError) {
+               string callBackResult;
                try {
                        callBackResult = target.GetCallbackResult ();
                }

Modified: branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jsf.cs
===================================================================
--- branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jsf.cs        
2007-12-11 10:14:57 UTC (rev 91079)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jsf.cs        
2007-12-11 10:21:21 UTC (rev 91080)
@@ -88,6 +88,8 @@
                bool _immediate;
                Pair _state;
                bool [] _validatorsState;
+               ICallbackEventHandler _callbackTarget;
+               string _callbackEventError = String.Empty;
 
                void EnterThread (FacesContext context) {
                        if (_lifeCycle == PageLifeCycle.Unknown)
@@ -113,6 +115,18 @@
                        EnterThread (context);
                        try {
                                if (!context.getResponseComplete ()) {
+
+                                       if (IsCrossPagePostBack)
+                                               return;
+
+                                       if (IsCallback) {
+                                               string result = 
ProcessGetCallbackResult (_callbackTarget, _callbackEventError);
+                                               HtmlTextWriter callbackOutput = 
new HtmlTextWriter (Response.Output);
+                                               callbackOutput.Write (result);
+                                               callbackOutput.Flush ();
+                                               return;
+                                       }
+
                                        // ensure lifecycle complete.
                                        if (!IsLoaded) {
                                                ProcessLoad ();

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to