Author: igorz
Date: 2007-11-19 10:22:55 -0500 (Mon, 19 Nov 2007)
New Revision: 89931

Added:
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Control.jsf.cs
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jsf.cs
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web/IHttpExtendedHandler.cs
Modified:
   
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
   
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.cs
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jvm.cs
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web/HttpContext.jvm.cs
   branches/mainsoft/JSF/mcs/class/System.Web/System.Web20.csproj
Log:
implement JSF life cycle on the page
added IHttpExtendedHandler interface

Modified: 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web/HttpContext.jvm.cs
===================================================================
--- branches/mainsoft/JSF/mcs/class/System.Web/System.Web/HttpContext.jvm.cs    
2007-11-19 14:53:16 UTC (rev 89930)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web/HttpContext.jvm.cs    
2007-11-19 15:22:55 UTC (rev 89931)
@@ -33,11 +33,16 @@
 using System.Threading;
 using javax.servlet.http;
 using [EMAIL PROTECTED];
+using javax.faces.context;
+using System.Web.J2EE;
+using System.Web.UI;
+using javax.servlet;
 
 namespace System.Web {
        
        public sealed partial class HttpContext {
-               static LocalDataStoreSlot _ContextSlot = 
Thread.GetNamedDataSlot ("Context");
+               static readonly LocalDataStoreSlot _ContextSlot = 
Thread.GetNamedDataSlot ("Context");
+               string _PortletNamespace;
                // No remoting support (CallContext) yet in Grasshopper
                [MonoInternalNote("Context - Use 
System.Remoting.Messaging.CallContext instead of Thread storage")]
                public static HttpContext Current
@@ -66,6 +71,14 @@
                        get { return 
(HttpServletResponse)GetWorkerService(typeof(HttpServletResponse)); }
                }
 
+               static readonly Type typeOfFacesContext = typeof (FacesContext);
+               internal FacesContext FacesContext {
+                       get {
+                               FacesContext faces = (FacesContext) 
GetWorkerService (typeOfFacesContext);
+                               return faces ?? 
javax.faces.context.FacesContext.getCurrentInstance ();
+                       }
+               }
+
                HttpRuntime _httpRuntime = null;
                internal HttpRuntime HttpRuntimeInstance {
                        get
@@ -87,8 +100,48 @@
                        get { return true; }
                }
 
-               internal bool IsPortletRequest { get { return ServletRequest is 
IPortletRequest; } }
+               internal bool IsActionRequest {
+                       get {
+                               FacesContext faces = FacesContext;
+                               return faces != null && 
!faces.getRenderResponse ();
+                       }
+               }
+               internal bool IsPortletRequest {
+                       get {
+                               FacesContext faces = FacesContext;
+                               return faces != null && 
!(faces.getExternalContext ().getContext () is ServletContext);
+                       }
+               }
 
+               internal bool IsFacesRequest {
+                       get {
+                               return FacesContext != null;
+                       }
+               }
+
+               internal string PortletNamespace
+               {
+                       get {
+                               if (_PortletNamespace == null) {
+                                       FacesContext faces = null;
+
+                                       //kostat: BUGBUG: complete
+                                       //string usePortletNamespace = 
J2EEUtils.GetInitParameterByHierarchy (Context.Servlet.getServletConfig (), 
"mainsoft.use.portlet.namespace");
+                                       //if (usePortletNamespace == null || 
Boolean.Parse (usePortletNamespace))
+                                               faces = FacesContext;
+
+                                       if (faces != null) {
+                                               _PortletNamespace = 
faces.getRenderResponse () ?
+                                                       
faces.getExternalContext ().encodeNamespace (String.Empty) :
+                                                       Request.Form 
[Page.NamespaceKey];
+                                       }
+                                       
+                                       _PortletNamespace = _PortletNamespace 
?? String.Empty;
+                               }
+                               return _PortletNamespace;
+                       }
+               }
+
                internal void BeginTimeoutPossible ()
                {
                }

Added: 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web/IHttpExtendedHandler.cs
===================================================================
--- 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web/IHttpExtendedHandler.cs   
    2007-11-19 14:53:16 UTC (rev 89930)
+++ 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web/IHttpExtendedHandler.cs   
    2007-11-19 15:22:55 UTC (rev 89931)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace System.Web
+{
+       public interface IHttpExtendedHandler
+       {
+               bool IsCompleted { get;}
+       }
+}

Modified: 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs
===================================================================
--- 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs 
    2007-11-19 14:53:16 UTC (rev 89930)
+++ 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs 
    2007-11-19 15:22:55 UTC (rev 89931)
@@ -160,7 +160,7 @@
                                prefix += page.theForm + ".";
 #if TARGET_J2EE
                        // Allow the page to transform ActionUrl to a portlet 
action url
-                       if (actionUrl != null && page.PortletNamespace != null) 
{
+                       if (actionUrl != null) {
                                actionUrl = page.CreateActionUrl(actionUrl);
                                prefix += "Portal";
                        }

Added: branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Control.jsf.cs
===================================================================
--- branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Control.jsf.cs     
2007-11-19 14:53:16 UTC (rev 89930)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Control.jsf.cs     
2007-11-19 15:22:55 UTC (rev 89931)
@@ -0,0 +1,174 @@
+//
+// System.Web.UI.Page.jsf.cs
+//
+// Authors:
+//   Igor Zelmanovich ([EMAIL PROTECTED])
+//
+// (C) 2007 Mainsoft Co. (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using javax.faces.component;
+using java.util;
+using javax.faces.el;
+using [EMAIL PROTECTED];
+using javax.faces.context;
+
+namespace System.Web.UI
+{
+       public partial class Control : UIComponentBase
+       {
+
+               #region Forward to base
+
+               public override Map getAttributes () {
+                       return base.getAttributes ();
+               }
+
+               public override ValueBinding getValueBinding (string name) {
+                       return base.getValueBinding (name);
+               }
+
+               public override void setValueBinding (string name, ValueBinding 
binding) {
+                       base.setValueBinding (name, binding);
+               }
+
+               public override Map getFacets () {
+                       return base.getFacets ();
+               }
+
+               public override UIComponent getFacet (string name) {
+                       return base.getFacet (name);
+               }
+
+               public override void broadcast (FacesEvent @event) {
+                       base.broadcast (@event);
+               }
+
+               [MonoTODO ("is this correct")]
+               public override void decode (FacesContext context) {
+                       base.decode (context);
+               }
+
+               [MonoTODO ("should integrate this")]
+               public override void encodeBegin (FacesContext context) {
+                       base.encodeBegin (context);
+               }
+
+               [MonoTODO ("should integrate this")]
+               public override void encodeEnd (FacesContext context) {
+                       base.encodeEnd (context);
+               }
+
+               [MonoTODO ("should integrate this")]
+               public override object saveState (FacesContext context) {
+                       return base.saveState (context);
+               }
+
+               [MonoTODO ("should integrate this")]
+               public override void restoreState (FacesContext context, object 
state) {
+                       base.restoreState (context, state);
+               }
+
+               #endregion
+
+               //kostat should use set
+               public override bool isTransient () {
+                       return true;
+               }
+
+
+
+               //public Control () {
+               //}
+
+               [MonoTODO ("shouldn't be the reverse?")]
+               public override string getClientId (FacesContext context) {
+                       return ClientID;
+               }
+
+               [MonoTODO ("shouldn't be the reverse?")]
+               public override string getId () {
+                       return ID;
+               }
+
+               [MonoTODO ("shouldn't be the reverse?")]
+               public override void setId (string id) {
+                       ID = id;
+               }
+
+               [MonoTODO ("shouldn't be the reverse?")]
+               public override UIComponent getParent () {
+                       //return Parent;
+                       return base.getParent ();
+               }
+
+               [MonoTODO ("shouldn't be the reverse?")]
+               public override void setParent (UIComponent parent) {
+                       Control p = parent as Control;
+                       if (p != null)
+                               p.Controls.Add (this);
+                       //throw new NotImplementedException("parent is not a 
Control"); //need to write a wrapper
+
+                       //Wrong, wrong code!!
+                       base.setParent (parent);
+               }
+
+               public override bool getRendersChildren () {
+                       return true; //see Control.Render
+               }
+
+               public override List getChildren () {
+                       //throw new NotImplementedException (); //should 
actually return Controls collection
+                       return base.getChildren ();
+               }
+
+               public override int getChildCount () {
+                       //throw new NotImplementedException (); //should 
actually return Controls.Count
+                       return base.getChildCount ();
+               }
+
+               public override UIComponent findComponent (string expr) {
+                       return FindControl (expr);
+               }
+
+               public override Iterator getFacetsAndChildren () {
+                       //throw new NotImplementedException (); //should 
actually return Controls collection
+                       return base.getFacetsAndChildren ();
+               }
+
+               [MonoTODO ("should integrate this, i.e. reverse call")]
+               public override void encodeChildren (FacesContext context) {
+
+                       RenderControl (new HtmlTextWriter 
(Context.Response.Output));
+                       //throw new NotImplementedException (); //should 
actually get the writer
+                       //context.
+                       //base.encodeChildren (context.getResponseWriter);
+               }
+
+               public override string getFamily () {
+                       return null;
+               }
+       }
+}

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-11-19 14:53:16 UTC (rev 89930)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.cs    
2007-11-19 15:22:55 UTC (rev 89931)
@@ -779,6 +779,11 @@
                else
                        allow_load = (c.ID == GetTypeHashCode ());
 
+#if TARGET_J2EE
+               if (Context.IsActionRequest)
+                       return coll;
+#endif
+
                if (coll != null && coll ["__VIEWSTATE"] == null && coll 
["__EVENTTARGET"] == null)
                        return null;
 
@@ -1014,7 +1019,7 @@
                writer.WriteLine ("\telse {{ {0} = document.{1}; }}", theForm, 
formUniqueID);
                writer.WriteLine ("\t{0}._instanceVariableName = '{0}';", 
theForm);
 #if TARGET_J2EE
-               string serverUrl = Context.ServletResponse.encodeURL 
(Request.RawUrl);
+               string serverUrl = EncodeURL (Request.RawUrl);
                writer.WriteLine ("\t{0}.serverURL = {1};", theForm, 
ClientScriptManager.GetScriptLiteral (serverUrl));
                writer.WriteLine ("\twindow.TARGET_J2EE = true;");
                writer.WriteLine ("\twindow.IsMultiForm = {0};", IsMultiForm ? 
"true" : "false");
@@ -1036,6 +1041,13 @@
 #endif
 
                if (handleViewState)
+#if TARGET_J2EE
+                       if (getFacesContext () != null) {
+                               javax.faces.application.StateManager manager = 
getFacesContext ().getApplication ().getStateManager ();
+                               manager.writeState (getFacesContext (), 
_facesSerializedView);
+                       }
+                       else
+#endif
                        scriptManager.RegisterHiddenField ("__VIEWSTATE", 
_savedViewState);
 
                scriptManager.WriteHiddenFields (writer);
@@ -1159,12 +1171,7 @@
 #if NET_2_0
                _lifeCycle = PageLifeCycle.Unknown;
 #endif
-               _context = context;
-
-               _application = context.Application;
-               _response = context.Response;
-               _request = context.Request;
-               _cache = context.Cache;
+               SetContext (context);
                
                if (clientTarget != null)
                        Request.ClientTarget = clientTarget;
@@ -1183,12 +1190,7 @@
                } catch (ThreadAbortException) {
                        // Do nothing, just ignore it by now.
                } catch (Exception e) {
-                       context.AddError (e); // OnError might access LastError
-                       OnError (EventArgs.Empty);
-                       context.ClearError (e);
-                       // We want to remove that error, as we're rethrowing to 
stop
-                       // further processing.
-                       Trace.Warn ("Unhandled Exception", e.ToString (), e);
+                       ProcessException (e);
                        throw;
                } finally {
                        try {
@@ -1208,6 +1210,15 @@
                                Thread.CurrentThread.CurrentUICulture = 
uiculture;
                }
        }
+
+       void ProcessException (Exception ex) {
+               _context.AddError (ex); // OnError might access LastError
+               OnError (EventArgs.Empty);
+               _context.ClearError (ex);
+               // We want to remove that error, as we're rethrowing to stop
+               // further processing.
+               Trace.Warn ("Unhandled Exception", ex.ToString (), ex);
+       }
        
 #if NET_2_0
        delegate void ProcessRequestDelegate (HttpContext context);
@@ -1326,22 +1337,50 @@
 #endif
                        
                renderingForm = false;  
+
+#if TARGET_J2EE
+               //kostat
+               if (Context.IsActionRequest || IsGetBack)
+                       return;
+#endif
+
+               RestorePageState ();
+               ProcessLoadPage ();
+               ProcessRaiseChangedEvents ();
+               ProcessRaisePostBackEvents ();
+               ProcessLoadComplete ();
+               RenderPage ();
+       }
+
+       void RestorePageState () {
 #if NET_2_0
                if (IsPostBack || IsCallback) {
+#else
+               if (IsPostBack) {
+#endif
+#if NET_2_0
                        _lifeCycle = PageLifeCycle.PreLoad;
                        if (_requestValueCollection != null)
                                scriptManager.RestoreEventValidationState (
                                        _requestValueCollection 
[ClientScriptManager.EventStateFieldName]);
-#else
-               if (IsPostBack) {
 #endif
                        Trace.Write ("aspx.page", "Begin LoadViewState");
                        LoadPageViewState ();
                        Trace.Write ("aspx.page", "End LoadViewState");
-                       Trace.Write ("aspx.page", "Begin ProcessPostData");
+               }
+       }
+
+       void ProcessLoadPage () {
+
+#if NET_2_0
 #if TARGET_J2EE
-                       if (!IsGetBack)
+               if (!IsGetBack)
 #endif
+               if (IsPostBack || IsCallback) {
+#else
+               if (IsPostBack) {
+#endif
+                       Trace.Write ("aspx.page", "Begin ProcessPostData");
                        ProcessPostData (_requestValueCollection, false);
                        Trace.Write ("aspx.page", "End ProcessPostData");
                }
@@ -1363,20 +1402,51 @@
                else
 #endif
                if (IsPostBack || IsCallback) {
-                       _lifeCycle = PageLifeCycle.ControlEvents;
 #else
                if (IsPostBack) {
 #endif
+#if NET_2_0
+                       _lifeCycle = PageLifeCycle.ControlEvents;
+#endif
                        Trace.Write ("aspx.page", "Begin ProcessPostData Second 
Try");
                        ProcessPostData (secondPostData, true);
                        Trace.Write ("aspx.page", "End ProcessPostData Second 
Try");
+               }
+       }
+
+       void ProcessRaiseChangedEvents () {
+
+#if NET_2_0
+#if TARGET_J2EE
+               if (!IsGetBack)
+#endif
+               if (IsPostBack || IsCallback) {
+#else
+               if (IsPostBack) {
+#endif
                        Trace.Write ("aspx.page", "Begin Raise ChangedEvents");
                        RaiseChangedEvents ();
                        Trace.Write ("aspx.page", "End Raise ChangedEvents");
+               }
+       }
+
+       void ProcessRaisePostBackEvents () {
+
+#if NET_2_0
+#if TARGET_J2EE
+               if (!IsGetBack)
+#endif
+               if (IsPostBack || IsCallback) {
+#else
+               if (IsPostBack) {
+#endif
                        Trace.Write ("aspx.page", "Begin Raise PostBackEvent");
                        RaisePostBackEvents ();
                        Trace.Write ("aspx.page", "End Raise PostBackEvent");
                }
+       }
+
+       void ProcessLoadComplete() {
                
 #if NET_2_0
                _lifeCycle = PageLifeCycle.LoadComplete;
@@ -1421,11 +1491,16 @@
                OnSaveStateComplete (EventArgs.Empty);
                Trace.Write ("aspx.page", "End SaveStateComplete");
 #if TARGET_J2EE
-               if (OnSaveStateCompleteForPortlet ())
-                       return;
+               if (getFacesContext () != null) {
+                       javax.faces.application.StateManager manager = 
getFacesContext ().getApplication ().getStateManager ();
+                       _facesSerializedView = manager.saveSerializedView 
(getFacesContext ());
+               }
 #endif // TARGET_J2EE
 #endif // NET_2_0
+       
+       }
 
+       internal void RenderPage () {
 #if NET_2_0
                _lifeCycle = PageLifeCycle.Render;
                scriptManager.ResetEventValidationState ();
@@ -1434,10 +1509,20 @@
                //--
                Trace.Write ("aspx.page", "Begin Render");
                HtmlTextWriter output = new HtmlTextWriter (Response.Output);
+               SetupResponseWriter (output);
                RenderControl (output);
                Trace.Write ("aspx.page", "End Render");
        }
 
+       void SetContext (HttpContext context) {
+               _context = context;
+
+               _application = context.Application;
+               _response = context.Response;
+               _request = context.Request;
+               _cache = context.Cache;
+       }
+
        private void RenderTrace ()
        {
                TraceManager traceManager = HttpRuntime.TraceManager;
@@ -1628,6 +1713,8 @@
 
        internal string RawViewState {
                get {
+                       if (_savedViewState != null)
+                               return _savedViewState;
                        NameValueCollection postdata = _requestValueCollection;
                        string view_state;
                        if (postdata == null || (view_state = postdata 
["__VIEWSTATE"]) == null)

Added: 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-11-19 14:53:16 UTC (rev 89930)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jsf.cs        
2007-11-19 15:22:55 UTC (rev 89931)
@@ -0,0 +1,379 @@
+//
+// System.Web.UI.Page.jsf.cs
+//
+// Authors:
+//   Igor Zelmanovich ([EMAIL PROTECTED])
+//
+// (C) 2007 Mainsoft Co. (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using javax.faces.el;
+using java.lang;
+using javax.faces.context;
+using javax.faces.component;
+using [EMAIL PROTECTED];
+using javax.servlet;
+using System.Collections;
+using javax.faces.application;
+using javax.faces.render;
+using javax.faces;
+using System.IO;
+using System.Threading;
+
+namespace System.Web.UI
+{
+       public partial class Page : ActionSource
+       {
+               private sealed class AspNetResponseWriter : java.io.Writer
+               {
+                       readonly TextWriter _writer;
+                       public AspNetResponseWriter (TextWriter writer) {
+                               _writer = writer;
+                       }
+                       public override void close () {
+                               _writer.Close ();
+                       }
+
+                       public override void flush () {
+                               _writer.Flush ();
+                       }
+
+                       public override void write (char [] __p1, int __p2, int 
__p3) {
+                               _writer.Write (__p1, __p2, __p3);
+                       }
+
+                       public override void write (int __p1) {
+                               _writer.Write ((char) __p1);
+                       }
+
+                       public override void write (char [] __p1) {
+                               _writer.Write (__p1);
+                       }
+
+                       public override void write (string __p1) {
+                               _writer.Write (__p1);
+                       }
+
+                       public override void write (string __p1, int __p2, int 
__p3) {
+                               _writer.Write (__p1, __p2, __p3);
+                       }
+               }
+
+               static Class StringClass { get { return 
vmw.common.TypeUtils.ToClass (String.Empty); } }
+               //kostat
+               // this is what it should be.
+               sealed class PostBackEventMethodBinding : MethodBinding
+               {
+                       readonly IPostBackEventHandler _handler;
+
+                       public PostBackEventMethodBinding 
(IPostBackEventHandler handler) {
+                               _handler = handler;
+                       }
+
+                       public override object invoke (FacesContext context, 
object [] pars) {
+                               _handler.RaisePostBackEvent ((string) pars [0]);
+                               return null;
+                       }
+
+                       public override Class getType (FacesContext context) {
+                               return Page.StringClass;
+                       }
+               }
+
+               sealed class EventRaiserMethodBinding : MethodBinding
+               {
+                       readonly Page _handler;
+                       static readonly Class StringClass = Class.forName 
("java.lang.String");
+
+                       public EventRaiserMethodBinding (Page handler) {
+                               _handler = handler;
+                       }
+
+                       public override object invoke (FacesContext context, 
object [] pars) {
+                               _handler.EnterThread (context);
+                               try {
+                                       _handler.ProcessRaisePostBackEvents ();
+                                       _handler.ProcessLoadComplete ();
+                                       //#if NET_2_0
+                                       //                    
_handler._lifeCycle = PageLifeCycle.LoadComplete;
+                                       //                    
_handler.OnLoadComplete (EventArgs.Empty);
+
+                                       //                    if 
(_handler.IsCallback) {
+                                       //                        string result 
= _handler.ProcessCallbackData ();
+                                       //                        
HtmlTextWriter callbackOutput = new HtmlTextWriter 
(_handler._context.Response.Output);
+                                       //                        
callbackOutput.Write (result);
+                                       //                        
callbackOutput.Flush ();
+                                       //                        return null; 
// will be redirected!
+                                       //                    }
+
+                                       //                    
_handler._lifeCycle = PageLifeCycle.PreRender;
+                                       //#endif
+                                       //                    
_handler.Trace.Write ("aspx.page", "Begin PreRender");
+                                       //                    
_handler.PreRenderRecursiveInternal ();
+                                       //                    
_handler.Trace.Write ("aspx.page", "End PreRender");
+
+                                       //#if NET_2_0
+                                       //                    
_handler.ExecuteRegisteredAsyncTasks ();
+
+                                       //                    
_handler._lifeCycle = PageLifeCycle.PreRenderComplete;
+                                       //                    
_handler.OnPreRenderComplete (EventArgs.Empty);
+                                       //#endif
+
+                                       //                    
_handler.Trace.Write ("aspx.page", "Begin SaveViewState");
+                                       //                    
_handler.SavePageViewState ();
+                                       //                    
_handler.Trace.Write ("aspx.page", "End SaveViewState");
+
+                                       //#if NET_2_0
+                                       //                    
_handler._lifeCycle = PageLifeCycle.SaveStateComplete;
+                                       //                    
_handler.OnSaveStateComplete (EventArgs.Empty);
+                                       //#endif // NET_2_0
+
+                                       //                    
javax.faces.application.StateManager manager = _handler.getFacesContext 
().getApplication ().getStateManager ();
+                                       //                    
_handler._facesSerializedView = manager.saveSerializedView 
(_handler.getFacesContext ());
+
+                                       //                    if 
(_handler.Context.IsActionRequest)
+                                       //                        
manager.writeState (_handler.getFacesContext (), _handler._facesSerializedView);
+
+                                       //try {
+                                       //    _handler.RenderTrace ();
+                                       //    _handler.UnloadRecursive (true);
+                                       //}
+                                       //catch { }
+
+                                       //return null;
+                               }
+                               catch (ThreadAbortException) {
+                                       context.responseComplete ();
+                               }
+                               catch (Exception ex) {
+                                       _handler.ProcessException (ex);
+                                       context.renderResponse ();
+                               }
+                               finally {
+                                       //_handler.Response.Flush ();
+                                       _handler.ExitThread (context);
+                               }
+                               return null;
+                       }
+
+                       public override Class getType (FacesContext context) {
+                               return StringClass;
+                       }
+               }
+
+               MethodBinding _action;
+               MethodBinding _actionListener;
+               bool _immediate;
+
+               public void EnterThread (FacesContext context) {
+                       if (_lifeCycle == PageLifeCycle.Unknown)
+                               ProcessRequest (HttpContext.Current);
+                       else
+                               SetContext (HttpContext.Current);
+               }
+
+               public void ExitThread (FacesContext context) {
+               }
+
+               public override bool isTransient () {
+                       //kostat
+                       return false;
+               }
+
+               public override void encodeBegin (FacesContext context) {
+               }
+
+               public override void encodeChildren (FacesContext context) {
+                       EnterThread (context);
+                       try {
+                               Trace.Write ("aspx.page", "Begin Render");
+                               RenderPage ();
+                               //base.encodeChildren (context);
+                               Trace.Write ("aspx.page", "End Render");
+                       }
+                       finally {
+                               ExitThread (context);
+                       }
+               }
+
+               public override void encodeEnd (FacesContext context) {
+               }
+
+               public override void setParent (UIComponent parent) {
+                       //base.setParent (parent);
+                       //ignore: parent is root
+               }
+
+               public override object saveState (FacesContext context) {
+                       //return base.saveState (context);
+                       return _savedViewState;
+               }
+
+               public override void restoreState (FacesContext context, object 
state) {
+                       EnterThread (context);
+                       try {
+                               _savedViewState = state as string;
+                               RestorePageState ();
+                       }
+                       finally {
+                               ExitThread (context);
+                       }
+               }
+
+               public override void decode (FacesContext context) {
+                       EnterThread (context);
+                       try {
+                               //base.decode (context);
+                               //Map requestParameterMap = 
context.getExternalContext ().getRequestParameterMap ();
+                               ProcessLoadPage ();
+
+                               ((ActionSource) this).setAction (new 
EventRaiserMethodBinding (this));
+
+                               ActionEvent action = new ActionEvent (this);
+                               action.setPhaseId (PhaseId.INVOKE_APPLICATION);
+                               context.getViewRoot ().queueEvent (action);
+                               //queueEvent (new ActionEvent (this));
+                       }
+                       finally {
+                               ExitThread (context);
+                       }
+               }
+
+               public override void processValidators (FacesContext context) {
+                       Console.WriteLine ("processValidators");
+                       EnterThread (context);
+                       try {
+                               base.processValidators (context);
+                       }
+                       finally {
+                               ExitThread (context);
+                       }
+               }
+
+               public override void processUpdates (FacesContext context) {
+                       Console.WriteLine ("processUpdates");
+                       base.processUpdates (context);
+                       EnterThread (context);
+                       try {
+                               ProcessRaiseChangedEvents ();
+                       }
+                       finally {
+                               ExitThread (context);
+                       }
+               }
+
+               public override void broadcast (FacesEvent e) {
+                       Console.WriteLine ("broadcast {0},{1},{2}", e.getSource 
(), e.getComponent (), e.ToString ());
+                       //Console.WriteLine (Environment.StackTrace);
+                       base.broadcast (e);
+
+                       if (e is ActionEvent) {
+                               FacesContext context = getFacesContext ();
+
+                               //ActionSource source = (ActionSource) this;
+
+                               //MethodBinding actionListenerBinding = 
source.getActionListener ();
+                               //if (actionListenerBinding != null) {
+                               //try
+                               //{
+                               //    actionListenerBinding.invoke (context, 
new Object [] { e });
+                               //}
+                               //catch (EvaluationException e)
+                               //{
+                               //    Throwable cause = e.getCause();
+                               //    if (cause != null && cause instanceof 
AbortProcessingException)
+                               //    {
+                               //        throw (AbortProcessingException)cause;
+                               //    }
+                               //    else
+                               //    {
+                               //        throw e;
+                               //    }
+                               //}
+                               //}
+
+                               ActionListener defaultActionListener
+                                       = context.getApplication 
().getActionListener ();
+                               if (defaultActionListener != null) {
+                                       defaultActionListener.processAction 
((ActionEvent) e);
+                               }
+                       }
+
+
+               }
+
+               #region ActionSource Members
+
+               void ActionSource.addActionListener (ActionListener listener) {
+                       Console.WriteLine ("addActionListener");
+                       addFacesListener (listener);
+               }
+
+               MethodBinding ActionSource.getAction () {
+                       Console.WriteLine ("getAction");
+                       return _action;
+               }
+
+               MethodBinding ActionSource.getActionListener () {
+                       Console.WriteLine ("getActionListener");
+                       return _actionListener;
+               }
+
+               static readonly Class ActionListenerClass = Class.forName 
("javax.faces.event.ActionListener");
+
+               ActionListener [] ActionSource.getActionListeners () {
+                       Console.WriteLine ("getActionListeners");
+                       return (ActionListener []) getFacesListeners 
(ActionListenerClass);
+               }
+
+               bool ActionSource.isImmediate () {
+                       Console.WriteLine ("isImmediate");
+                       return _immediate;
+               }
+
+               void ActionSource.removeActionListener (ActionListener 
actionListener) {
+                       Console.WriteLine ("removeActionListener");
+                       removeFacesListener (actionListener);
+               }
+
+               void ActionSource.setAction (MethodBinding action) {
+                       Console.WriteLine ("setAction");
+                       _action = action;
+               }
+
+               void ActionSource.setActionListener (MethodBinding 
actionListener) {
+                       Console.WriteLine ("setActionListener");
+                       _actionListener = actionListener;
+               }
+
+               void ActionSource.setImmediate (bool immediate) {
+                       Console.WriteLine ("setImmediate");
+                       _immediate = immediate;
+               }
+
+               #endregion
+
+       }
+}

Modified: branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jvm.cs
===================================================================
--- branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jvm.cs        
2007-11-19 14:53:16 UTC (rev 89930)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI/Page.jvm.cs        
2007-11-19 15:22:55 UTC (rev 89931)
@@ -32,12 +32,19 @@
 using System.Globalization;
 using System.Web.Hosting;
 using System.Web.J2EE;
-using System.ComponentModel;
+using System.ComponentModel;
+using System.IO;
+using javax.faces.context;
+using javax.faces.render;
+using javax.servlet;
+using javax.faces;
+using javax.faces.application;
 
 namespace System.Web.UI
 {
        public partial class Page
-       {
+       {
+               internal const string NamespaceKey = "__NAMESPACE";
                const string PageNamespaceKey = "__PAGENAMESPACE";
                const string RenderPageMark = "vmw.render.page=";
                const string ActionPageMark = "vmw.action.page=";
@@ -47,29 +54,14 @@
                bool _emptyPortletNamespace = false;
                string _PortletNamespace = null;
                bool _renderResponseInit = false;
-               IPortletRenderResponse _renderResponse = null;
+               IPortletRenderResponse _renderResponse = null;
+               StateManager.SerializedView _facesSerializedView;
+
 
                internal string PortletNamespace
                {
                        get {
-                               if (_emptyPortletNamespace)
-                                       return null;
-
-                               if (_PortletNamespace == null) {
-                                       IPortletResponse portletResponse = null;
-                                       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)
-                                               _PortletNamespace = 
_requestValueCollection [PageNamespaceKey];
-                                               
-                                       _emptyPortletNamespace = 
_PortletNamespace == null;
-                               }
-                               return _PortletNamespace;
+                               return Context.PortletNamespace;
                        }
                }
 
@@ -104,8 +96,7 @@
 
                internal bool IsGetBack {
                        get {
-                               return IsPostBack && IsPortletRender &&
-                                       (0 == String.Compare 
(Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase));
+                               return IsPostBack && Context.IsPortletRequest 
&& !Context.IsActionRequest;
                        }
                }
 
@@ -123,37 +114,21 @@
 
                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);
+                       FacesContext faces = getFacesContext ();
+                       return faces != null ? faces.getExternalContext 
().encodeResourceURL (url) : url;
                }
 
                public string CreateActionUrl (string url)
                {
-                       if (url.StartsWith (RenderPageMark, 
StringComparison.Ordinal) || url.StartsWith (ActionPageMark, 
StringComparison.Ordinal))
+                       FacesContext faces = getFacesContext ();
+                       if (faces == null)
                                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;
+                       //kostat: handle QueryString!
+                       Application application = faces.getApplication ();
+                       ViewHandler viewHandler = application.getViewHandler ();
+                       String viewId = faces.getViewRoot ().getViewId ();
+                       return viewHandler.getActionURL (faces, viewId);
                }
 
                private string RemoveAppPathIfInternal (string url)
@@ -232,5 +207,30 @@
                                val.IsValid = validatorsState [i];
                        }
                }
+
+               void SetupResponseWriter (TextWriter httpWriter) {
+                       FacesContext facesContext = getFacesContext ();
+                       if (facesContext == null)
+                               return;
+                       ResponseWriter writer = facesContext.getResponseWriter 
();
+                       if (writer == null) {
+                               RenderKitFactory renderFactory = 
(RenderKitFactory) FactoryFinder.getFactory (FactoryFinder.RENDER_KIT_FACTORY);
+                               RenderKit renderKit = 
renderFactory.getRenderKit (facesContext,
+                                                                               
                                                 facesContext.getViewRoot 
().getRenderKitId ());
+
+                               ServletResponse response = (ServletResponse) 
facesContext.getExternalContext ().getResponse ();
+
+                               writer = renderKit.createResponseWriter (new 
AspNetResponseWriter (httpWriter),
+                                                                               
                                 response.getContentType (), //TODO: is this 
the correct content type?
+                                                                               
                                 response.getCharacterEncoding ());
+                               facesContext.setResponseWriter (writer);
+                       }
+               }
+
+               internal string EncodeURL (string raw) {
+                       //kostat: BUGBUG: complete
+                       return raw;
+               }
+
        }
 }

Modified: 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
===================================================================
--- 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
   2007-11-19 14:53:16 UTC (rev 89930)
+++ 
branches/mainsoft/JSF/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
   2007-11-19 15:22:55 UTC (rev 89931)
@@ -258,13 +258,12 @@
                        action += Page.Request.QueryStringRaw;
 #if TARGET_J2EE
                        // Allow the page to transform action to a portlet 
action url
-                       if (Page.IsPortletRender) {
-                               string customAction = Attributes ["action"];
-                               if (customAction != null && customAction.Length 
> 0)
-                                       action = customAction;
-                               else
-                                       action = 
Page.RenderResponse.createActionURL (action);
-                       }
+                       string customAction = Attributes ["action"];
+                       if (String.IsNullOrEmpty(customAction))
+                               action = Page.CreateActionUrl (action);
+                       else
+                               action = customAction;
+
 #endif
 
 #if NET_2_0

Modified: branches/mainsoft/JSF/mcs/class/System.Web/System.Web20.csproj
===================================================================
--- branches/mainsoft/JSF/mcs/class/System.Web/System.Web20.csproj      
2007-11-19 14:53:16 UTC (rev 89930)
+++ branches/mainsoft/JSF/mcs/class/System.Web/System.Web20.csproj      
2007-11-19 15:22:55 UTC (rev 89931)
@@ -1193,6 +1193,7 @@
     <Compile Include="System.Web.UI.WebControls\XmlBuilder.jvm.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="System.Web.UI\Control.jsf.cs" />
     <Compile Include="System.Web.UI\ControlBuilder.jvm.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -1209,6 +1210,7 @@
     <Compile Include="System.Web.UI\Page.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="System.Web.UI\Page.jsf.cs" />
     <Compile Include="System.Web.UI\Page.jvm.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -1229,6 +1231,7 @@
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="System.Web\HttpWorkerRequest.jvm.cs" />
+    <Compile Include="System.Web\IHttpExtendedHandler.cs" />
     <Compile Include="System.Web\UplevelHelper.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -1372,6 +1375,11 @@
     <Reference Include="Mainsoft.Configuration, Version=1.0.0.0, 
Culture=neutral, processorArchitecture=MSIL">
       <HintPath>..\lib\Mainsoft.Configuration.dll</HintPath>
     </Reference>
+    <Reference Include="myfaces-api-1.1.0, Version=0.0.0.0, Culture=neutral, 
processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\lib\myfaces-api-1.1.0.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
     <Reference Include="rt">
       <HintPath>..\lib\rt.dll</HintPath>
       <Private>False</Private>
@@ -1401,7 +1409,7 @@
   -->
   <ProjectExtensions>
     <VisualStudio>
-      <UserProperties 
REFS-JarPath-system-configuration="..\..\..\..\..\Program Files\Mainsoft\Visual 
MainWin for J2EE V2\java_refs\framework\System.Configuration.jar" 
REFS-JarPath-system-data="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin 
for J2EE V2\java_refs\framework\System.Data.jar" 
REFS-JarPath-system-drawing="..\..\..\..\..\Program Files\Mainsoft\Visual 
MainWin for J2EE 
V2\java_refs\framework\System.Drawing.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\jai_imageio.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\jai_core.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\jai_codec.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\clibwrapper_jiio.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\mlibwrapper_jai.jar" 
REFS-JarPath-system-xml="..\..\..\..\..\Program Fi
 les\Mainsoft\Visual MainWin for J2EE V2\java_refs\framework\System.Xml.jar" 
REFS-JarPath-system="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for 
J2EE V2\java_refs\framework\System.jar" 
REFS-JarPath-mscorlib="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for 
J2EE 2\java_refs\framework\mscorlib.jar" REFS-JarPath-rt="..\lib\rt.jar" 
REFS-JarPath-j2ee="..\lib\j2ee.jar" 
REFS-JarPath-j2ee-helpers="..\lib\J2EE.Helpers.jar" 
REFS-JarPath-j2se-helpers="..\lib\J2SE.Helpers.jar" REFS-JarPath-javaee="" 
REFS-RefInfo-javaee="repository:JavaEE:tomcat:1.3" />
+      <UserProperties 
REFS-JarPath-system-configuration="..\..\..\..\..\Program Files\Mainsoft\Visual 
MainWin for J2EE V2\java_refs\framework\System.Configuration.jar" 
REFS-JarPath-system-data="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin 
for J2EE V2\java_refs\framework\System.Data.jar" 
REFS-JarPath-system-drawing="..\..\..\..\..\Program Files\Mainsoft\Visual 
MainWin for J2EE 
V2\java_refs\framework\System.Drawing.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\jai_imageio.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\jai_core.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\jai_codec.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\clibwrapper_jiio.jar;..\..\..\..\..\Program 
Files\Mainsoft\Visual MainWin for J2EE 
V2\java_refs\framework\mlibwrapper_jai.jar" 
REFS-JarPath-system-xml="..\..\..\..\..\Program Fi
 les\Mainsoft\Visual MainWin for J2EE V2\java_refs\framework\System.Xml.jar" 
REFS-JarPath-system="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for 
J2EE V2\java_refs\framework\System.jar" 
REFS-JarPath-mscorlib="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for 
J2EE 2\java_refs\framework\mscorlib.jar" REFS-JarPath-rt="..\lib\rt.jar" 
REFS-JarPath-j2ee="..\lib\j2ee.jar" 
REFS-JarPath-j2ee-helpers="..\lib\J2EE.Helpers.jar" 
REFS-JarPath-j2se-helpers="..\lib\J2SE.Helpers.jar" REFS-JarPath-javaee="" 
REFS-RefInfo-javaee="repository:JavaEE:tomcat:1.3" 
REFS-JarPath-myfaces-api-1-1-0="..\lib\myfaces-api-1.1.0.jar" 
REFS-RefInfo-myfaces-api-1-1-0="j2il:" />
     </VisualStudio>
   </ProjectExtensions>
   <PropertyGroup>

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

Reply via email to