Add portal support
authorEyal Alalouf <eyala@mainsoft.com>
Sun, 14 Jan 2007 17:10:38 +0000 (17:10 -0000)
committerEyal Alalouf <eyala@mainsoft.com>
Sun, 14 Jan 2007 17:10:38 +0000 (17:10 -0000)
svn path=/trunk/mcs/; revision=70988

28 files changed:
mcs/class/System.Web/ChangeLog
mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs
mcs/class/System.Web/System.Web.SessionState/HttpSessionState.jvm.cs [deleted file]
mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.jvm.cs [deleted file]
mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs
mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs
mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs
mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs
mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs
mcs/class/System.Web/System.Web.UI/Control.cs
mcs/class/System.Web/System.Web.UI/Control.jvm.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI/Page.cs
mcs/class/System.Web/System.Web.UI/Page.jvm.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/HttpContext.cs
mcs/class/System.Web/System.Web/HttpContext.jvm.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web/HttpCookie.cs
mcs/class/System.Web/System.Web/HttpRequest.cs
mcs/class/System.Web/System.Web/HttpRequest.jvm.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web/HttpResponse.cs
mcs/class/System.Web/System.Web20.vmwcsproj

index 3aeb73656f615132bf944a7a73645f87fd53dd5e..74ba723e07443efe412acaaa52120c77d97a09e7 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-14  Eyal Alaluf  <eyala@mainsoft.com>
+
+       * System.Web20.vmwcsproj: added .jvm files for Control.cs, Page.cs,
+         HttpRequest.cs & HttpContext.cs
+
 2007-01-07  Vladimir Krasnov  <vladimirk@mainsoft.com>
 
        * System.Web20.vmwcsproj: added ProfileParameter.cs
index deb055fe31c773972e429b65d64495ed363bb425..aac898cb5b2581e7971072cef14f8ca70a023531 100644 (file)
@@ -31,12 +31,8 @@ using vmw.common;
 
 namespace System.Web.J2EE
 {
-       internal sealed class J2EEUtils
+       internal static class J2EEUtils
        {
-               public J2EEUtils()
-               {
-               }
-
                public static int RunProc(string[] cmd)
                {       
                        java.lang.Runtime rt = java.lang.Runtime.getRuntime();
diff --git a/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.jvm.cs b/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.jvm.cs
deleted file mode 100644 (file)
index b5d91c2..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-//
-// System.Web.SessionState.HttpSessionState.jvm.cs
-//
-// Authors:
-//  Ilya Kharmatsky (ilyak@mainsoft.com)
-//  Alon Gazit
-//  Pavel Sandler
-//
-// (C) 2005 Mainsoft Corporation (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;
-using System.Collections.Specialized;
-using System.Globalization;
-using System.Text;
-using System.Threading;
-using System.Web;
-using System.Web.J2EE;
-using System.Web.Hosting;
-
-namespace System.Web.SessionState 
-{
-public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externalizable
-{
-       private string _id;
-       private SessionDictionary _dict;
-       private HttpStaticObjectsCollection _staticObjects;
-       private int _timeout;
-       private bool _newSession;
-       private bool _isCookieless;
-       private SessionStateMode _mode;
-       private bool _isReadonly;
-       internal bool _abandoned;
-
-       private bool _needSessionPersistence = false;
-
-       internal HttpSessionState (string id,
-                                  SessionDictionary dict,
-                                  HttpStaticObjectsCollection staticObjects,
-                                  int timeout,
-                                  bool newSession,
-                                  bool isCookieless,
-                                  SessionStateMode mode,
-                                  bool isReadonly)
-       {
-               _id = id;
-               _dict = dict;
-               _staticObjects = staticObjects.Clone ();
-               _timeout = timeout;
-               _newSession = newSession;
-               _isCookieless = isCookieless;
-               _mode = mode;
-               _isReadonly = isReadonly;
-
-               _needSessionPersistence = false;
-               javax.servlet.ServletConfig config = (javax.servlet.ServletConfig)AppDomain.CurrentDomain.GetData(J2EEConsts.SERVLET_CONFIG);
-               string sessionPersistance = config.getInitParameter(J2EEConsts.Enable_Session_Persistency);
-               if (sessionPersistance!= null)
-               {
-                       try
-                       {
-                               _needSessionPersistence = Boolean.Parse(sessionPersistance);
-                       }
-                       catch (Exception)
-                       {
-                               Console.WriteLine("EnableSessionPersistency init param's value is invalid. the value is " + sessionPersistance);
-                       }
-               }
-       }
-
-       public HttpSessionState ()
-       {
-               _id = null;
-               _dict = new SessionDictionary();
-               _staticObjects = new HttpStaticObjectsCollection();
-               _timeout = 0;
-               _newSession = false;
-               _isCookieless = false;
-               _mode = SessionStateMode.Off;
-               _isReadonly = false;
-       }
-
-       public void writeExternal(java.io.ObjectOutput output)
-       {
-               lock (this)
-               {
-                       output.writeBoolean(_needSessionPersistence);
-                       if (!_needSessionPersistence)
-                               //indicates that there is nothing to serialize for this object
-                               return;
-
-                       System.Web.J2EE.ObjectOutputStream ms = new System.Web.J2EE.ObjectOutputStream(output);
-                       System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);
-                       bw.Write(_id);
-                       _dict.Serialize(bw);
-                       _staticObjects.Serialize(bw);
-                       bw.Write(_timeout);
-                       bw.Write(_newSession);
-                       bw.Write(_isCookieless);
-                       if (_mode == SessionStateMode.Off)
-                               bw.Write(0);
-                       else if (_mode == SessionStateMode.InProc)
-                               bw.Write(1);
-                       else if (_mode == SessionStateMode.StateServer)
-                               bw.Write(2);
-                       else 
-                               bw.Write(3);
-                       bw.Write(_isReadonly);
-               }
-       }
-
-       public void readExternal(java.io.ObjectInput input)
-       {
-               lock(this)
-               {
-                       _needSessionPersistence = input.readBoolean();
-                       if(!_needSessionPersistence) //noting has been written 
-                               return;
-
-                       System.Web.J2EE.ObjectInputStream ms = new System.Web.J2EE.ObjectInputStream( input );
-                       System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
-                       _id = br.ReadString();
-                       _dict =  SessionDictionary.Deserialize(br);
-                       _staticObjects = HttpStaticObjectsCollection.Deserialize(br);
-                       _timeout = br.ReadInt32();
-                       _newSession = br.ReadBoolean();
-                       _isCookieless = br.ReadBoolean();
-                       int mode = br.ReadInt32();
-                       if (mode == 0)
-                               _mode = SessionStateMode.Off;
-                       else if (mode == 1)
-                               _mode = SessionStateMode.InProc;
-                       else if (mode == 2)
-                               _mode = SessionStateMode.StateServer;
-                       else 
-                               _mode = SessionStateMode.SQLServer;
-                       _isReadonly = br.ReadBoolean();
-               }
-       }
-
-       internal HttpSessionState Clone ()
-       {
-               return new HttpSessionState (_id, _dict.Clone (), _staticObjects, _timeout, _newSession,
-                                            _isCookieless, _mode, _isReadonly);
-
-       }
-
-       public int CodePage {
-               get {
-                       HttpContext current = HttpContext.Current;
-                       if (current == null)
-                               return Encoding.Default.CodePage;
-
-                       return current.Response.ContentEncoding.CodePage;
-               }
-               
-               set {
-                       HttpContext current = HttpContext.Current;
-                       if (current != null)
-                               current.Response.ContentEncoding = Encoding.GetEncoding (value);
-               }
-       }
-
-       public HttpSessionState Contents {
-               get { return this; }
-       }
-
-       public int Count {
-               get { return _dict.Count; }
-       }
-
-       internal bool IsAbandoned {
-               get { return _abandoned; }
-       }
-
-       public bool IsCookieless {
-               get { 
-                       ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest;
-                       return worker.ServletRequest.isRequestedSessionIdFromURL();     
-               }
-       }
-
-       public bool IsNewSession {
-               get { return _newSession; }
-       }
-
-       public bool IsReadOnly {
-               get { return _isReadonly; }
-       }
-
-       public bool IsSynchronized {
-               get { return false; }
-       }
-
-       public object this [string key] {
-               get { return _dict [key]; }
-               set { 
-                       _dict [key] = value; 
-
-                       _newSession = false;
-                       SetJavaSessionAttribute();
-               }
-       }
-
-       public object this [int index] {
-               get { return _dict [index]; }
-               set { 
-                       _dict [index] = value; 
-
-                       _newSession = false;
-                       SetJavaSessionAttribute();
-               }
-       }
-
-       public NameObjectCollectionBase.KeysCollection Keys {
-               get { return _dict.Keys; }
-       }
-
-       public int LCID {
-               get { return Thread.CurrentThread.CurrentCulture.LCID; }
-               set { Thread.CurrentThread.CurrentCulture = new CultureInfo(value); }
-       }
-
-       public SessionStateMode Mode {
-               get { return _mode; }
-       }
-
-       public string SessionID {
-               get { return _id; }
-       }
-
-       public HttpStaticObjectsCollection StaticObjects {
-               get { return _staticObjects; }
-       }
-
-       public object SyncRoot {
-               get { return this; }
-       }
-
-       public int Timeout {
-               get { 
-                       ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest;
-                       javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false);
-                       if (javaSession != null)
-                        return javaSession.getMaxInactiveInterval()/60;                        
-                       else
-                        throw new NotSupportedException();
-               }
-               set {
-            if (value < 1)
-                 throw new ArgumentException ("The argument to SetTimeout must be greater than 0.");
-                       ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest;
-                       javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false);
-                       if (javaSession != null)
-                               javaSession.setMaxInactiveInterval(value*60);                   
-                       else
-                               throw new NotSupportedException();
-        }
-       }
-
-       internal SessionDictionary SessionDictionary {
-               get { return _dict; }
-       }
-
-       internal void SetNewSession (bool value)
-       {
-               _newSession = value;
-       }
-
-       public void Abandon ()
-       {
-               _abandoned = true;
-
-               SessionDictionary.Clear();
-               ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest;
-//             worker.Servlet.getServletContext().removeAttribute("GH_SESSION_STATE");
-               javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false);
-
-               if (javaSession != null)
-               {
-                       javaSession.setAttribute("GH_SESSION_STATE",this);      
-                       javaSession.invalidate();
-               }
-       }
-
-       public void Add (string name, object value)
-       {
-               _dict [name] = value;
-
-               _newSession = false;
-               SetJavaSessionAttribute();
-       }
-
-       public void Clear ()
-       {
-               if (_dict != null)
-                       _dict.Clear ();
-
-               SetJavaSessionAttribute();
-       }
-       
-       public void CopyTo (Array array, int index)
-       {
-               NameObjectCollectionBase.KeysCollection all = Keys;
-               for (int i = 0; i < all.Count; i++)
-                       array.SetValue (all.Get(i), i + index);
-       }
-
-       public IEnumerator GetEnumerator ()
-       {
-               return _dict.GetEnumerator ();
-       }
-       
-       public void Remove (string name)
-       {
-               _dict.Remove (name);
-
-               SetJavaSessionAttribute();
-       }
-
-       public void RemoveAll ()
-       {
-               _dict.Clear ();
-
-               SetJavaSessionAttribute();
-       }
-
-       public void RemoveAt (int index)
-       {
-               _dict.RemoveAt (index);
-
-               SetJavaSessionAttribute();
-       }
-       
-       public void SetJavaSessionAttribute ()
-       {
-               ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest;
-               javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false);
-               if (javaSession != null)
-                       javaSession.setAttribute("GH_SESSION_STATE",this);      
-       }       
-}
-}
-
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.jvm.cs b/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.jvm.cs
deleted file mode 100644 (file)
index 1fedb45..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// System.Web.SessionState.SesionInProchandler.jvm.cs
-//
-// Authors:
-//  Ilya Kharmatsky (ilyak@mainsoft.com)
-//  Alon Gazit
-//  Pavel Sandler
-//
-// (C) 2005 Mainsoft Corporation (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.
-//
-#if !NET_2_0
-using System;
-using System.IO;
-using System.Collections;
-using System.Web;
-using System.Web.Hosting;
-using System.Web.Configuration;
-
-namespace System.Web.SessionState
-{
-
-       class SessionInProcHandler : ISessionHandler
-       {
-
-#if NET_2_0
-               SessionStateSection config;
-#else
-               SessionConfig config;
-#endif
-
-               public void Dispose () { }
-
-               public void Init (SessionStateModule module, HttpApplication context,
-#if NET_2_0
-                       SessionStateSection config
-#else
-                       SessionConfig config
-#endif
-)
-               {
-                       this.config = config;
-               }
-
-               public void UpdateHandler (HttpContext context, SessionStateModule module) { }
-
-               public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module,
-                                                       bool required, bool read_only, ref bool isNew)
-               {
-
-                       if (!required)
-                               return null;
-
-                       ServletWorkerRequest worker = (ServletWorkerRequest)context.Request.WorkerRequest;
-                       javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false);
-                       HttpSessionState state;
-                       if (javaSession != null) 
-                       {
-                               state = (HttpSessionState) javaSession.getAttribute("GH_SESSION_STATE");
-                           return state;
-                       }
-                       
-                       // We create a new session.
-                       javaSession = worker.ServletRequest.getSession(true);
-                       string sessionID = javaSession.getId();
-                       state = new HttpSessionState (sessionID, // unique identifier
-                                       new SessionDictionary(), // dictionary
-                                       HttpApplicationFactory.ApplicationState.SessionObjects,
-#if NET_2_0
-                                       (int)config.Timeout.TotalMinutes, // XXX is this right?  we lose some precision here, but since the timeout is in minutes *anyway*...
-#else
-                                       config.Timeout, //lifetime before death.
-#endif
-                                       true, //new session
-                                       false, // is cookieless
-                                       SessionStateMode.J2ee,
-                                       read_only); //readonly
-                                       
-                       javaSession.setAttribute("GH_SESSION_STATE", state);
-                       
-                       isNew = true;
-                       return state;
-               }
-       }
-}
-
-#endif
index ef5c741bae82c5d12eab63950625d7244c67cd9d..93a854a616d8309ce6c877e3dd11a07087b50cc5 100644 (file)
@@ -1,4 +1,8 @@
-2007-01-07  Eyal Alaluf  <eyala@mainsoft.com>
+2007-01-14  Eyal Alaluf  <eyala@mainsoft.com>
+
+       * HtmlForm.cs, HtmlAnchor.cs: Added H2EE Portal support for TARGET_J2EE.
+
+2007-01-14  Eyal Alaluf  <eyala@mainsoft.com>
 
        * HtmlInputImage.cs: to handle correctly relative URLs to the image.
 
index 8b9116d2fc8f301564ee42f64ba0213d01b0df94..304de1ed9eb86aca0c40908f5a72a7d27be9bc8f 100644 (file)
@@ -165,8 +165,11 @@ namespace System.Web.UI.HtmlControls {
 
                protected override void RenderAttributes (HtmlTextWriter writer)
                {
-                       // we don't want to render the "user" URL, so we either render:
+                       string target = Attributes ["target"];
+                       if ((target == null) || (target.Length == 0))
+                               Attributes.Remove("target");
 
+                       // we don't want to render the "user" URL, so we either render:
                        EventHandler serverClick = (EventHandler) Events [serverClickEvent];
                        if (serverClick != null) {
 #if NET_2_0
@@ -181,13 +184,14 @@ namespace System.Web.UI.HtmlControls {
                        } else {
                                string hr = HRef;
                                if (hr != "")
+#if TARGET_J2EE
+                                       // For J2EE portlets we need to genreate a render URL.
+                                       HRef = ResolveUrl (hr, String.Compare(target, "_blank", true) != 0);
+#else
                                        HRef = ResolveUrl (hr);
+#endif
                        }
 
-                       string target = Attributes ["target"];
-                       if ((target == null) || (target.Length == 0))
-                               Attributes.Remove("target");
-
                        base.RenderAttributes (writer);
 
                        // but we never set back the href attribute after the rendering
index 5493e0714c4f3e84c0a7748dd0a82ad61a7e2056..e5661da62ed2d037d714efeb4570c043be128eb7 100644 (file)
@@ -250,6 +250,11 @@ namespace System.Web.UI.HtmlControls
                        }
 
                        action += Page.Request.QueryStringRaw;
+#if TARGET_J2EE
+                       vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse();
+                       if (resp != null)
+                               action = resp.createActionURL(action);
+#endif
 
                        w.WriteAttribute ("name", Name);
 
index 3b4311379e3f83ead61a15cd4ba82f0a12caf041..1b47d3332b5f773e3307753f6129810db3c542a4 100644 (file)
@@ -213,6 +213,11 @@ namespace System.Web.UI.WebControls {
                {
                        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;
index 403c55cd180e7f3244e3e5d6b003fbb1e6aca589..059206a48fcc84c83703b5bf096d44fdf1e8bdcc 100644 (file)
@@ -1,3 +1,7 @@
+2007-01-14 Eyal Alaluf <eyala@mainsoft.com>
+       * Button.cs, HyperLink.cs, DataGrid.cs, ImageButton.cs, LinkButton.cs,
+         PagedDataSource.cs: Added J2EE Portal support for TARGET_J2EE.
+
 2007-01-14  Ilya Kharmatsky <ilyak-at-mainsoft.com>
        * BaseCompareValidator
        * CompareValidator
index dd5768e3a6ab100c2d27dddbcf45a26bae0754b7..db501d5a69d0d91e2bf0d2915072d8aebbe61414 100644 (file)
@@ -865,29 +865,6 @@ namespace System.Web.UI.WebControls {
 
                class NCollection : ICollection {
                        int n;
-#if TARGET_JVM
-                       class SequenceEnumerator : IEnumerator {
-                               readonly int _max;
-                               object _current;
-                               public SequenceEnumerator(int max) {
-                                       _max = max;
-                                       Reset();
-                               }
-
-                               public bool MoveNext() {
-                                       _current = (int)_current + 1;
-                                       return (int)_current >= 0 && (int)_current < _max;
-                               }
-
-                               public void Reset() {
-                                       _current = -1;
-                               }
-
-                               public object Current {
-                                       get { return _current; }
-                               }
-                       }
-#endif
 
                        public NCollection (int n)
                        {
@@ -896,12 +873,8 @@ namespace System.Web.UI.WebControls {
 
                        public IEnumerator GetEnumerator ()
                        {
-#if TARGET_JVM
-                               return new SequenceEnumerator(n);
-#else
                                for (int i = 0; i < n; i++)
                                        yield return i;
-#endif
                        }
 
                        public int Count {
index 2031bf662708a2567da5eef1c51f0491c723ad37..750a1fc026d42103f83ffee39d63ef13b5d6c128 100644 (file)
@@ -59,12 +59,16 @@ namespace System.Web.UI.WebControls {
                        if (!Enabled)
                                return;
                        // add attributes - only if they're not empty
+                       string t = Target;
                        string s = NavigateUrl;
                        if (s.Length > 0)
+#if TARGET_J2EE
+                               w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s, String.Compare (t, "_blank", true) != 0));
+#else
                                w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s));
-                       s = Target;
-                       if (s.Length > 0)
-                               w.AddAttribute (HtmlTextWriterAttribute.Target, s);
+#endif
+                       if (t.Length > 0)
+                               w.AddAttribute (HtmlTextWriterAttribute.Target, t);
                }
                
                protected override void AddParsedSubObject (object obj)
index 11c96c2b3262f022e74158917d927def6f61ef4f..79e2d4bf1b0cd9f5ea02614ef325c160c5b258a9 100644 (file)
@@ -239,6 +239,11 @@ namespace System.Web.UI.WebControls {
                {
                        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;
index da58ecc38bef55718e2f6d11fd347aeb610b580f..fdee9dc79ce827444628c01d0e4f78f9570356f1 100644 (file)
@@ -143,6 +143,11 @@ namespace System.Web.UI.WebControls {
                {
                        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;
index d3cd36a46c7c5d1afc0622d2a2fb74cb3ccb294b..71f73d246143650c577b4260dc375d9b3ff1c1fb 100644 (file)
@@ -241,77 +241,6 @@ namespace System.Web.UI.WebControls {
                        return String.Empty; // as documented
                }
 
-#if TARGET_JVM
-               internal class ListEnum : IEnumerator
-               {
-                       int start;
-                       int end;
-                       int ind;
-                       IList list;
-
-                       internal ListEnum(IList list, int start, int end)
-                       {
-                               this.list = list;
-                               this.start = start;
-                               this.end = end;
-                               this.ind = start - 1;
-                       }
-
-                       public bool MoveNext()
-                       {
-                               ind++;
-                               return (ind < end);
-                       }
-
-                       public void Reset() { ind = start - 1; }
-                       public object Current { get { return list[ind]; }}
-               }
-
-               private IEnumerator GetListEnum (IList list, int start, int end)
-               {
-                       if (!allow_paging)
-                               end = list.Count;
-                       return new ListEnum(list, start, end);
-               }
-
-               internal class EnumeratorEnum : IEnumerator
-               {
-                       int start;
-                       int end;
-                       int ind;
-                       IEnumerator en;
-                       PagedDataSource parent;
-
-                       internal EnumeratorEnum(PagedDataSource parent, IEnumerator en, int start, int end)
-                       {
-                               this.parent = parent;
-                               this.en = en;
-                               this.start = start;
-                               this.end = end;
-                               this.ind = start - 1;
-                               for (int i = 0; i < start; i++)
-                                       en.MoveNext ();
-                       }
-
-                       public bool MoveNext()
-                       {
-                               ind++;
-                               return (!parent.allow_paging || ind < end) && en.MoveNext ();
-                       }
-
-                       public void Reset()
-                       {
-                               throw new NotSupportedException();
-                       }
-
-                       public object Current { get { return en.Current; }}
-               }
-
-               private IEnumerator GetEnumeratorEnum (IEnumerator e, int start, int end)
-               {
-                       return new EnumeratorEnum(this, e, start, end);
-               }
-#else
                private IEnumerator GetListEnum (IList list, int start, int end)
                {
                        if (!AllowPaging)
@@ -330,7 +259,6 @@ namespace System.Web.UI.WebControls {
                        for (int i = start; (!allow_paging || i < end) && e.MoveNext (); i++)
                                yield return e.Current;
                }
-#endif
        }
 }
 
index 444c8d05c37018e28a3f3b9b287379ac898e307e..d2f7cbb9af4b0474e3618c02bb30a5cbc5e6bc69 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-14  Eya; Alaluf <eyala@mainsoft.com>
+
+       * Control.jvm.cs, Page.jvm.cs: Added TARGET_J2EE specific files.
+       * Page.cs, ClientScriptManager.cs, Control.cs: Added J2EE portal
+         support for TARGET_J2EE.
+
 2007-01-12  Miguel de Icaza  <miguel@novell.com>
 
        * Control.cs: Remove comment, it provides no information about
index af12cc894e01db008a71e09c82b52ee601840c9a..b5335db651f22b82ad012fee1127ba6c1e9aa1a6 100644 (file)
@@ -99,7 +99,7 @@ namespace System.Web.UI
                                throw new ArgumentNullException ("control");
                        
                        page.RequiresPostBackScript ();
-                       return String.Format ("__doPostBack('{0}','{1}')", control.UniqueID, argument);
+                       return String.Format ("{0}('{1}','{2}')", page.PostBackFunctionName, control.UniqueID, argument);
                }
 
 #if NET_2_0
index 7f476664a284d4a67daef3b064b1b109dc01186f..2c36b5967c93df131fe9d3e2c023ae881b7a8605 100644 (file)
@@ -66,7 +66,7 @@ namespace System.Web.UI
        [DesignerSerializer ("Microsoft.VSDesigner.WebForms.ControlCodeDomSerializer, " + Consts.AssemblyMicrosoft_VSDesigner,
                                "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
 #endif         
-        public class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor
+        public partial class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor
 #if NET_2_0
         , IUrlResolutionService, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor
 #endif
@@ -532,6 +532,7 @@ namespace System.Web.UI
                        defaultNumberID = 0;
                }
 
+#if !TARGET_J2EE
                string GetDefaultName ()
                {
                        string defaultName;
@@ -542,6 +543,7 @@ namespace System.Web.UI
                        }
                        return defaultName;
                }
+#endif
 
                void NullifyUniqueID ()
                {
@@ -1149,6 +1151,11 @@ namespace System.Web.UI
                string ResolveClientUrl (string relativeUrl)
                {
                        string absoluteUrl = ResolveUrl (relativeUrl);
+#if TARGET_J2EE
+                       // There are no relative paths when rendering a J2EE portlet
+                       if (IsPortletRender)
+                               return absoluteUrl;
+#endif
                        if (Context != null && Context.Request != null) {
                                string baseUrl = Context.Request.BaseVirtualDir;
                                if (absoluteUrl.StartsWith (baseUrl + "/"))
diff --git a/mcs/class/System.Web/System.Web.UI/Control.jvm.cs b/mcs/class/System.Web/System.Web.UI/Control.jvm.cs
new file mode 100644 (file)
index 0000000..fa106e4
--- /dev/null
@@ -0,0 +1,99 @@
+//\r
+// System.Web.UI.ControlS.jvm.cs\r
+//\r
+// Authors:\r
+//   Eyal Alaluf (eyala@mainsoft.com)\r
+//\r
+// (C) 2006 Mainsoft Co. (http://www.mainsoft.com)\r
+//\r
+\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using vmw.@internal.j2ee;\r
+using System.Web.Hosting;\r
+\r
+namespace System.Web.UI\r
+{\r
+       public partial class Control\r
+       {\r
+               bool _emptyPortletNamespace = false;\r
+               string _PortletNamespace = null;\r
+\r
+               internal bool IsPortletRender\r
+               {\r
+                       get {\r
+                               return GetRenderResponse() != null;\r
+                       }\r
+               }\r
+\r
+               // For J2EE Portal we need to use the portlet namespace when we generate control IDs.\r
+               string GetDefaultName ()\r
+               {\r
+                       string defaultName;\r
+                       if (defaultNumberID > 99) {\r
+                               defaultName = "_ctl" + defaultNumberID++;\r
+                       } else {\r
+                               defaultName = defaultNameArray [defaultNumberID++];\r
+                       }\r
+\r
+                       if (this != _page || _emptyPortletNamespace)\r
+                               return defaultName;\r
+\r
+                       if (_PortletNamespace == null) {\r
+                               IPortletResponse portletResponse = GetRenderResponse ();\r
+                               if (portletResponse != null)\r
+                                       _PortletNamespace = portletResponse.getNamespace ();\r
+                               _emptyPortletNamespace = _PortletNamespace == null;\r
+                       }\r
+\r
+                       return _PortletNamespace + defaultName;\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
+                       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
+                       return relativeUrl;\r
+               }\r
+\r
+               internal IPortletRenderResponse GetRenderResponse ()\r
+               {\r
+                       return Context.ServletResponse as IPortletRenderResponse;\r
+               }\r
+       }\r
+}\r
index a967ec1e4f81c6141a8a3bc47d76e1d0301f9f91..d56367b4770e3c485a5ad996f9da2d680e25b8a9 100644 (file)
@@ -68,7 +68,7 @@ namespace System.Web.UI
 #else
 [Designer ("Microsoft.VSDesigner.WebForms.WebFormDesigner, " + Consts.AssemblyMicrosoft_VSDesigner, typeof (IRootDesigner))]
 #endif
-public class Page : TemplateControl, IHttpHandler
+public partial class Page : TemplateControl, IHttpHandler
 {
 #if NET_2_0
        private PageLifeCycle _lifeCycle = PageLifeCycle.Unknown;
@@ -439,6 +439,14 @@ public class Page : TemplateControl, IHttpHandler
        }
 #endif
 
+#if !TARGET_J2EE
+       internal string PostBackFunctionName {
+               get {
+                       return "__doPostBack";
+               }
+       }
+#endif
+
        [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
        [Browsable (false)]
        public HttpRequest Request
@@ -754,6 +762,10 @@ public class Page : TemplateControl, IHttpHandler
                        coll = req.QueryString;
                }
 
+#if TARGET_J2EE
+               coll = LoadViewStateForPortlet((WebROCollection)coll);
+#endif
+
                if (coll != null && coll ["__VIEWSTATE"] == null && coll ["__EVENTTARGET"] == null)
                        return null;
 
@@ -955,7 +967,7 @@ public class Page : TemplateControl, IHttpHandler
 
                writer.WriteLine ("\tvar theForm;\n\tif (document.getElementById) {{ theForm = document.getElementById ('{0}'); }}", formUniqueID);
                writer.WriteLine ("\telse {{ theForm = document.{0}; }}", formUniqueID);
-               writer.WriteLine ("\tfunction __doPostBack(eventTarget, eventArgument) {");
+               writer.WriteLine ("\tfunction " + PostBackFunctionName + "(eventTarget, eventArgument) {");
                writer.WriteLine ("\t\tif(document.ValidatorOnSubmit && !ValidatorOnSubmit()) return;");
                writer.WriteLine ("\t\ttheForm.{0}.value = eventTarget;", postEventSourceID);
                writer.WriteLine ("\t\ttheForm.{0}.value = eventArgument;", postEventArgumentID);
@@ -989,7 +1001,7 @@ public class Page : TemplateControl, IHttpHandler
                return new ObjectStateFormatter (this);
        }
 
-       internal object GetSavedViewState ()
+       internal string GetSavedViewState ()
        {
                return _savedViewState;
        }
@@ -1257,6 +1269,14 @@ public class Page : TemplateControl, IHttpHandler
 #if NET_2_0
                _lifeCycle = PageLifeCycle.SaveStateComplete;
                OnSaveStateComplete (EventArgs.Empty);
+#endif
+
+#if TARGET_J2EE
+               if (SaveViewStateForNextPortletRender())
+                       return;
+#endif
+
+#if NET_2_0
                _lifeCycle = PageLifeCycle.Render;
 #endif
                
diff --git a/mcs/class/System.Web/System.Web.UI/Page.jvm.cs b/mcs/class/System.Web/System.Web.UI/Page.jvm.cs
new file mode 100644 (file)
index 0000000..e9ecfb8
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// System.Web.UI.Page.jvm.cs
+//
+// Authors:
+//   Eyal Alaluf (eyala@mainsoft.com)
+//
+// (C) 2006 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 vmw.@internal.j2ee;
+using javax.servlet.http;\r
+using System.Collections.Specialized;\r
+using System.Web.Hosting;
+
+namespace System.Web.UI
+{
+       public partial class Page
+       {
+               internal string PostBackFunctionName {
+                       get {
+#if LATER // Enable when we fix the jscripts not to reference __doPostBack.
+                               IPortletRenderResponse resp = GetRenderResponse();
+                               if (resp != null)
+                                       return "__doPostBack_" + resp.getNamespace();
+#endif
+                               return "__doPostBack";
+                       }
+               }
+
+               // For J2EE portlets we load the view state from the render parameters
+               WebROCollection LoadViewStateForPortlet(WebROCollection coll)
+               {
+                       IPortletRenderRequest renderRequest = Context.ServletRequest as IPortletRenderRequest;
+                       if (renderRequest != null && (coll == null || coll ["__VIEWSTATE"] == null)) {
+                               string mode = renderRequest.getPortletMode();
+                               string viewstate = Context.ServletRequest.getParameter("vmw.viewstate." + mode);
+                               if (viewstate != null) {
+                                       if (coll == null)
+                                               coll = new WebROCollection();
+                                       else 
+                                               coll.Unprotect();
+                                       coll["__VIEWSTATE"] = viewstate;
+                                       coll.Protect();
+                               }
+                       }
+                       return coll;
+               }
+
+               internal bool SaveViewStateForNextPortletRender()
+               {
+                       IPortletActionResponse resp = Context.ServletResponse as IPortletActionResponse;
+                       IPortletActionRequest req = Context.ServletRequest as IPortletActionRequest;
+                       if (req == null)
+                               return false;
+
+                       if (IsPostBack && String.Compare (Request.HttpMethod, "POST", true) == 0 && !resp.isRedirected())
+                               resp.setRenderParameter("vmw.viewstate." + req.getPortletMode(), GetSavedViewState());
+
+                       // Stop processing only if we are handling processAction. If we
+                       // are handling a postback from render then fall through.
+                       return req.processActionOnly() || resp.isRedirected();
+               }
+       }
+}
index 21f8d9365ec0fa787552442199036c64b3de4f2b..a7e60cd68a39502b9d0acae9dc884eaa5cbe6ff0 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-14  Eyal Alaluf  <eyala@mainsoft.com>
+
+       * HttpRequest.jvm.cs, HttpContext.jvm.cs: Added TARGET_J2EE specific files.
+       * HttpContext.cs, HttpResponse.cs, HttpRequest.cs, HttpCookie.cs:
+         Add J2EE Portal support for TARGET_J2EE.
+
 2007-01-04  Vladimir Krasnov  <vladimirk@mainsoft.com>
 
        * HttpRequest.cs: fixed IsLocal, should check all ip addresses of host
index 2cd58be74ab9b9bd19c5155721d61cbd80b9b284..bc9341995c64dc7c2c417d0758b60916f3a646a2 100644 (file)
@@ -55,7 +55,7 @@ namespace System.Web {
        
        // CAS - no InheritanceDemand here as the class is sealed
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
-       public sealed class HttpContext : IServiceProvider {
+       public sealed partial class HttpContext : IServiceProvider {
                internal HttpWorkerRequest WorkerRequest;
                HttpApplication app_instance;
                HttpRequest request;
@@ -77,10 +77,7 @@ namespace System.Web {
                ProfileBase profile = null;
                LinkedList<IHttpHandler> handlers;
 #endif
-#if TARGET_JVM // No remoting support (CallContext) yet in Grasshopper
-               static LocalDataStoreSlot _ContextSlot = Thread.GetNamedDataSlot ("Context");
-#endif
-               
+
                public HttpContext (HttpWorkerRequest wr)
                {
                        WorkerRequest = wr;
@@ -136,14 +133,7 @@ namespace System.Web {
                // The "Current" property is set just after we have constructed it with 
                // the 'HttpContext (HttpWorkerRequest)' constructor.
                //
-#if TARGET_JVM // No remoting support (CallContext) yet in Grasshopper
-               [MonoTODO("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")]
-               public static HttpContext Current
-               {
-                       get { return (HttpContext) Thread.GetData (_ContextSlot); }
-                       set { Thread.SetData (_ContextSlot, value); }
-               }
-#else
+#if !TARGET_JVM // No remoting CallContext support in Grasshopper
                public static HttpContext Current {
                        get {
                                return (HttpContext) CallContext.GetData ("c");
@@ -195,9 +185,7 @@ namespace System.Web {
                                        (Request.WorkerRequest.GetLocalAddress () != Request.UserHostAddress);
                        }
                }
-#if TARGET_JVM
-               public bool IsDebuggingEnabled { get { return false; } }
-#else
+#if !TARGET_JVM
                public bool IsDebuggingEnabled {
                        get {
 #if NET_2_0
diff --git a/mcs/class/System.Web/System.Web/HttpContext.jvm.cs b/mcs/class/System.Web/System.Web/HttpContext.jvm.cs
new file mode 100644 (file)
index 0000000..d59f834
--- /dev/null
@@ -0,0 +1,67 @@
+//\r
+// System.Web.HttpContext.cs \r
+//\r
+// Author:\r
+//     Eyal Alaluf (eyala@mainsoft.com)\r
+//\r
+\r
+//\r
+// Copyright (C) 2005 Mainsoft Co. (http://www.mainsoft.com)\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System.Collections;\r
+using System.Configuration;\r
+using System.Threading;\r
+using javax.servlet.http;\r
+\r
+namespace System.Web {\r
+       \r
+       public sealed partial class HttpContext {\r
+               static LocalDataStoreSlot _ContextSlot = Thread.GetNamedDataSlot ("Context");\r
+               // No remoting support (CallContext) yet in Grasshopper\r
+               [MonoInternalNote("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")]\r
+               public static HttpContext Current\r
+               {\r
+                       get { return (HttpContext) Thread.GetData (_ContextSlot); }\r
+                       set { Thread.SetData (_ContextSlot, value); }\r
+               }\r
+\r
+               public bool IsDebuggingEnabled { get { return false; } }\r
+\r
+               internal object GetWorkerService(Type t)\r
+               {\r
+                       return ((IServiceProvider) WorkerRequest).GetService(t);\r
+               }\r
+\r
+               internal HttpServlet Servlet {\r
+                       get { return (HttpServlet)GetWorkerService(typeof(HttpServlet)); }\r
+               }\r
+\r
+               internal HttpServletRequest ServletRequest {\r
+                       get { return (HttpServletRequest)GetWorkerService(typeof(HttpServletRequest)); }\r
+               }\r
+\r
+               internal HttpServletResponse ServletResponse {\r
+                       get { return (HttpServletResponse)GetWorkerService(typeof(HttpServletResponse)); }\r
+               }\r
+       }\r
+}\r
index f7e61e084fd9992a703d3ab6276ab479489b31ce..1010cf098eaed0df907c3e68889e240eac20b158 100644 (file)
@@ -42,6 +42,10 @@ namespace System.Web {
        
        // CAS - no InheritanceDemand here as the class is sealed
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if TARGET_J2EE
+       // Cookies must be serializable to be saved in the session for J2EE portal
+       [Serializable]
+#endif
        public sealed class HttpCookie {
 
                string path = "/";
index 72e761f7e8747124c785dfb8f3cd4507277a2b4a..b4b7309bc3d00686fdc3d58090396823436cb130 100644 (file)
@@ -45,7 +45,7 @@ namespace System.Web {
        
        // CAS - no InheritanceDemand here as the class is sealed
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
-       public sealed class HttpRequest {
+       public sealed partial class HttpRequest {
                HttpWorkerRequest worker_request;
                HttpContext context;
                WebROCollection query_string_nvc;
@@ -306,6 +306,10 @@ namespace System.Web {
                                        }
                                }
 
+#if TARGET_J2EE
+                               // For J2EE portal support we emulate cookies using the session.
+                               GetSessionCookiesForPortal (cookies);
+#endif
                                if (validate_cookies && !checked_cookies){
                                        ValidateCookieCollection (cookies);
                                        checked_cookies = true;
@@ -443,6 +447,7 @@ namespace System.Web {
                        EndSubStream (input);
                }
 
+#if !TARGET_J2EE
                //
                // Adds the key/value to the form, and sets the argumets to empty
                //
@@ -491,7 +496,8 @@ namespace System.Web {
 
                        EndSubStream (input);
                }
-               
+#endif
+
                bool IsContentType (string ct, bool starts_with)
                {
                        if (starts_with)
@@ -569,63 +575,7 @@ namespace System.Web {
                        }
                }
 
-
-#if TARGET_JVM 
-               const int INPUT_BUFFER_SIZE = 1024;
-
-               void MakeInputStream ()
-               {
-                       if (worker_request == null)
-                               throw new HttpException ("No HttpWorkerRequest");
-
-                       // consider for perf:
-                       //    return ((ServletWorkerRequest)worker_request).InputStream();
-
-                       //
-                       // Use an unmanaged memory block as this might be a large
-                       // upload
-                       //
-                       int content_length = ContentLength;
-
-#if NET_2_0
-                       HttpRuntimeSection config = (HttpRuntimeSection) WebConfigurationManager.GetSection ("system.web/httpRuntime");
-#else
-                       HttpRuntimeConfig config = (HttpRuntimeConfig) HttpContext.GetAppConfig ("system.web/httpRuntime");
-#endif
-                       if (content_length > (config.MaxRequestLength * 1024))
-                               throw new HttpException ("File exceeds httpRuntime limit");
-                       
-                       byte[] content = new byte[content_length];
-                       if (content == null)
-                               throw new HttpException (String.Format ("Not enough memory to allocate {0} bytes", content_length));
-
-                       int total;
-                       byte [] buffer;
-                       buffer = worker_request.GetPreloadedEntityBody ();
-                       if (buffer != null){
-                               total = buffer.Length;
-                               if (content_length > 0)
-                                       total = Math.Min (content_length, total);
-                               Array.Copy (buffer, content, total);
-                       } else
-                               total = 0;
-                       
-                       
-                       buffer = new byte [INPUT_BUFFER_SIZE];
-                       while (total < content_length){
-                               int n;
-                               n = worker_request.ReadEntityBody (buffer, Math.Min (content_length-total, INPUT_BUFFER_SIZE));
-                               if (n <= 0)
-                                       break;
-                               Array.Copy (buffer, 0, content, total, n);
-                               total += n;
-                       } 
-                       if (total < content_length)
-                               throw new HttpException (411, "The uploaded file is incomplete");
-                                                        
-                       input_stream = new MemoryStream (content, 0, content.Length, false, true);
-               }
-#else
+#if !TARGET_JVM
                const int INPUT_BUFFER_SIZE = 32*1024;
 
                TempFileStream GetTempStream ()
@@ -804,6 +754,7 @@ namespace System.Web {
                                throw new HttpException (411, "The request body is incomplete.");
                }
 #endif
+
                internal void ReleaseResources ()
                {
                        Stream stream;
diff --git a/mcs/class/System.Web/System.Web/HttpRequest.jvm.cs b/mcs/class/System.Web/System.Web/HttpRequest.jvm.cs
new file mode 100644 (file)
index 0000000..133f3da
--- /dev/null
@@ -0,0 +1,203 @@
+//\r
+// System.Web.HttpRequest.jvm.cs \r
+//\r
+// \r
+// Author:\r
+//     Eyal Alaluf <eyala@mainsoft.com>\r
+//\r
+\r
+//\r
+// Copyright (C) 2006 Mainsoft, Co. (http://www.mainsoft.com)\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+using System.Web.Hosting;\r
+using javax.servlet.http;\r
+using System.Web.Configuration;\r
+using System.IO;\r
+using System.Collections;\r
+using vmw.@internal.j2ee;\r
+\r
+namespace System.Web\r
+{\r
+       public sealed partial class HttpRequest\r
+       {\r
+               private const string SessionLock = "vmw.session.lock";\r
+               private const string SessionCookies = "vmw.session.cookies";\r
+\r
+               private static object GetJavaSessionLock (HttpSession javaSession)\r
+               {\r
+                       lock (SessionLock) {\r
+                               object sessionLock = javaSession.getAttribute (SessionLock);\r
+                               if (sessionLock == null) {                              \r
+                                       sessionLock = String.Copy (SessionLock);\r
+                                       javaSession.setAttribute (SessionLock, sessionLock);\r
+                               }\r
+                               return sessionLock;\r
+                       }\r
+               }\r
+\r
+               void LoadWwwForm ()\r
+               {\r
+                       HttpServletRequest servletReq = context.ServletRequest;\r
+\r
+                       for (java.util.Enumeration e = servletReq.getParameterNames(); e.hasMoreElements() ;) {\r
+                               string key = (string) e.nextElement();\r
+                               form.Add(key, servletReq.getParameter(key));\r
+                       }\r
+               }\r
+\r
+               const int INPUT_BUFFER_SIZE = 1024;\r
+\r
+               void MakeInputStream ()\r
+               {\r
+                       if (worker_request == null)\r
+                               throw new HttpException ("No HttpWorkerRequest");\r
+\r
+                       // consider for perf:\r
+                       //    return ((ServletWorkerRequest)worker_request).InputStream();\r
+\r
+                       //\r
+                       // Use an unmanaged memory block as this might be a large\r
+                       // upload\r
+                       //\r
+                       int content_length = ContentLength;\r
+#if NET_2_0\r
+                       HttpRuntimeSection config = (HttpRuntimeSection) WebConfigurationManager.GetSection ("system.web/httpRuntime");\r
+#else\r
+                       HttpRuntimeConfig config = (HttpRuntimeConfig) HttpContext.GetAppConfig ("system.web/httpRuntime");\r
+#endif\r
+                       if (content_length > (config.MaxRequestLength * 1024))\r
+                               throw new HttpException ("File exceeds httpRuntime limit");\r
+                       \r
+                       byte[] content = new byte[content_length];\r
+                       if (content == null)\r
+                               throw new HttpException (String.Format ("Not enough memory to allocate {0} bytes", content_length));\r
+\r
+                       int total;\r
+                       byte [] buffer;\r
+                       buffer = worker_request.GetPreloadedEntityBody ();\r
+                       if (buffer != null){\r
+                               total = buffer.Length;\r
+                               if (content_length > 0)\r
+                                       total = Math.Min (content_length, total);\r
+                               Array.Copy (buffer, content, total);\r
+                       }\r
+                       else\r
+                               total = 0;\r
+\r
+                       buffer = new byte [INPUT_BUFFER_SIZE];\r
+                       while (total < content_length) {\r
+                               int n;\r
+                               n = worker_request.ReadEntityBody (buffer, Math.Min (content_length-total, INPUT_BUFFER_SIZE));\r
+                               if (n <= 0)\r
+                                       break;\r
+                               Array.Copy (buffer, 0, content, total, n);\r
+                               total += n;\r
+                       } \r
+                       if (total < content_length)\r
+                               throw new HttpException (411, "The uploaded file is incomplete");\r
+                                                        \r
+                       input_stream = new MemoryStream (content, 0, content.Length, false, true);\r
+               }\r
+\r
+               internal void GetSessionCookiesForPortal (HttpCookieCollection cookies)\r
+               {\r
+                       HttpSession javaSession = context.ServletRequest.getSession(false);\r
+                       if (javaSession == null)\r
+                               return;\r
+\r
+                       object sessionLock = GetJavaSessionLock (javaSession);\r
+                       lock (sessionLock) {\r
+                               Hashtable sessionCookies = (Hashtable) javaSession.getAttribute (SessionCookies);\r
+                               if (sessionCookies == null)\r
+                                       return;\r
+\r
+                               ArrayList expiredCookies = null;\r
+                               foreach (string key in sessionCookies.Keys) {\r
+                                       HttpCookie sessionCookie = (HttpCookie) sessionCookies [key];\r
+                                       if (sessionCookie.Expires.Ticks != 0 &&\r
+                                               sessionCookie.Expires.Ticks < DateTime.Now.Ticks) {\r
+                                               if (cookies [key] != null)\r
+                                                       cookies.Remove (key);\r
+                                               else {\r
+                                                       if (expiredCookies == null)\r
+                                                               expiredCookies = new ArrayList();\r
+                                                       expiredCookies.Add (key);\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                               cookies.Set (sessionCookie);\r
+                               }\r
+\r
+                               if (expiredCookies != null)\r
+                                       foreach (object key in expiredCookies)\r
+                                               sessionCookies.Remove (key);\r
+                       }\r
+               }\r
+\r
+               internal void SetSessionCookiesForPortal (HttpCookieCollection cookies)\r
+               {\r
+                       if (cookies == null || cookies.Count == 0)\r
+                               return;\r
+\r
+                       HttpServletRequest servletReq = context.ServletRequest;\r
+                       bool inPortletMode = servletReq is IPortletRequest;\r
+                       bool shouldStoreCookiesCollection = false;\r
+                       HttpSession javaSession = servletReq.getSession(false);\r
+\r
+                       if (javaSession == null && inPortletMode)\r
+                               javaSession = servletReq.getSession(true);\r
+\r
+                       if (javaSession == null)\r
+                               return;\r
+\r
+                       object sessionLock = GetJavaSessionLock (javaSession);\r
+                       lock (sessionLock) {\r
+                               Hashtable sessionCookies = (Hashtable)javaSession.getAttribute (SessionCookies);                        \r
+                               if (sessionCookies == null)\r
+                                       if (inPortletMode) {\r
+                                               sessionCookies = new Hashtable ();\r
+                                               shouldStoreCookiesCollection = true;\r
+                                       }\r
+                                       else\r
+                                               return;\r
+\r
+                               ArrayList sessionStoredCookies = null;\r
+                               for (int i=0; i < cookies.Count; i++) {\r
+                                       HttpCookie cookie = cookies[i];\r
+                                       if (sessionCookies [cookie.Name] != null || inPortletMode) {\r
+                                               sessionCookies [cookie.Name] = cookie;\r
+                                               if (sessionStoredCookies == null)\r
+                                                       sessionStoredCookies = new ArrayList();\r
+                                               sessionStoredCookies. Add (cookie.Name);\r
+                                       }\r
+                               }\r
+\r
+                               if (sessionStoredCookies != null)\r
+                                       foreach (object key in sessionStoredCookies)\r
+                                               cookies.Remove ((string) key);\r
+\r
+                               if (shouldStoreCookiesCollection)\r
+                                       javaSession.setAttribute (SessionCookies, sessionCookies);\r
+                       }\r
+               }\r
+       }\r
+}\r
index e31e5ced5b564af5d34e1fcfd23ec26f375be7e1..e1029ecf690cfc4ef5e5a67e86539dfe8ab74230 100644 (file)
@@ -39,6 +39,9 @@ using System.Web.Util;
 using System.Web.Configuration;
 using System.Globalization;
 using System.Security.Permissions;
+#if TARGET_J2EE
+using vmw.@internal.j2ee;
+#endif
 
 namespace System.Web {
        
@@ -382,6 +385,7 @@ namespace System.Web {
                                suppress_content = value;
                        }
                }
+
 #if NET_2_0
                [MonoTODO ("Not implemented")]
                public void AddCacheDependency (CacheDependency[] dependencies)
@@ -657,8 +661,11 @@ namespace System.Web {
                                int n = cookies.Count;
                                for (int i = 0; i < n; i++)
                                        write_headers.Add (cookies.Get (i).GetCookieHeader ());
+#if TARGET_J2EE
+                               // For J2EE Portal support emulate cookies by storing them in the session.
+                               context.Request.SetSessionCookiesForPortal (cookies);
+#endif
                        }
-                       
                }
 
                internal void WriteHeaders (bool final_flush)
@@ -758,6 +765,19 @@ namespace System.Web {
                {
                        if (headers_sent)
                                throw new HttpException ("header have been already sent");
+
+#if TARGET_J2EE
+                       // In J2EE portal we need to handle Redirect at the processAction phase
+                       // using the portlet ActionResponse that will send for us the redirect header.
+                       IPortletActionResponse resp = context.ServletResponse as IPortletActionResponse;
+                       if (resp != null) {
+                               resp.sendRedirect (url);
+                               if (endResponse)
+                                       End ();
+                               return;
+                       }
+#endif
+
 #if NET_2_0
                        is_request_being_redirected = true;
 #endif
index 10c332e3b3b5445d181ac272188f1b7890c3d590..0145e34b0bfd2766da25a3c84b96008dd17c403b 100644 (file)
@@ -35,6 +35,7 @@
     <Version>2.0</Version>\r
     <JDKName>1.5.0_05</JDKName>\r
     <TargetPlatform>0</TargetPlatform>\r
+    <NoWarn>67,168,169,219,414,612,618,649</NoWarn>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_Java|AnyCPU' ">\r
     <DebugSymbols>true</DebugSymbols>\r
@@ -49,6 +50,7 @@
     <SkipValidation>True</SkipValidation>\r
     <KeepIntermediate>False</KeepIntermediate>\r
     <TargetPlatform>0</TargetPlatform>\r
+    <NoWarn>67,168,169,219,414,612,618,649</NoWarn>\r
     <AdditionalClassPath>\r
     </AdditionalClassPath>\r
   </PropertyGroup>\r
@@ -64,6 +66,7 @@
     <SkipValidation>false</SkipValidation>\r
     <KeepIntermediate>false</KeepIntermediate>\r
     <TargetPlatform>0</TargetPlatform>\r
+    <NoWarn>67,168,169,219,414,612,618,649</NoWarn>\r
     <AdditionalClassPath>\r
     </AdditionalClassPath>\r
   </PropertyGroup>\r
@@ -87,6 +90,7 @@
     <Version>2.0</Version>\r
     <JDKName>1.5.0_05</JDKName>\r
     <TargetPlatform>0</TargetPlatform>\r
+    <NoWarn>67,168,169,219,414,612,618,649</NoWarn>\r
   </PropertyGroup>\r
   <ItemGroup>\r
     <Compile Include="..\..\build\common\Locale.cs">\r
     <Compile Include="System.Web.UI\ConflictOptions.cs" />\r
     <Compile Include="System.Web.UI\ConstructorNeedsTagAttribute.cs" />\r
     <Compile Include="System.Web.UI\Control.cs" />\r
+    <Compile Include="System.Web.UI\Control.jvm.cs" />\r
     <Compile Include="System.Web.UI\ControlBuilderAttribute.cs" />\r
     <Compile Include="System.Web.UI\ControlCachePolicy.cs" />\r
     <Compile Include="System.Web.UI\ControlCollection.cs" />\r
     <Compile Include="System.Web\HttpContext.cs">\r
       <SubType>Code</SubType>\r
     </Compile>\r
+    <Compile Include="System.Web\HttpContext.jvm.cs">\r
+      <SubType>Code</SubType>\r
+    </Compile>\r
     <Compile Include="System.Web\HttpCookie.cs">\r
       <SubType>Code</SubType>\r
     </Compile>\r
     <Compile Include="System.Web\HttpParseException.cs" />\r
     <Compile Include="System.Web\HttpPostedFile.cs" />\r
     <Compile Include="System.Web\HttpRequest.cs" />\r
+    <Compile Include="System.Web\HttpRequest.jvm.cs" />\r
     <Compile Include="System.Web\HttpRequestValidationException.cs" />\r
     <Compile Include="System.Web\HttpResponse.cs" />\r
     <Compile Include="System.Web\HttpResponseHeader.cs" />\r
     <Compile Include="System.Web.UI\Page.cs">\r
       <SubType>Code</SubType>\r
     </Compile>\r
+    <Compile Include="System.Web.UI\Page.jvm.cs">\r
+      <SubType>Code</SubType>\r
+    </Compile>\r
     <Compile Include="System.Web.UI\PageParser.jvm.cs" />\r
     <Compile Include="System.Web.UI\TemplateControl.jvm.cs" />\r
     <Compile Include="System.Web.UI\UserControlControlBuilder.cs">\r
     </EmbeddedResource>\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Reference Include="j2ee">\r
+      <Private>False</Private>\r
+      <HintPath>..\lib\j2ee.dll</HintPath>\r
+    </Reference>\r
+    <Reference Include="J2EE.Helpers">\r
+      <Private>False</Private>\r
+      <HintPath>..\lib\J2EE.Helpers.dll</HintPath>\r
+    </Reference>\r
     <Reference Include="J2SE.Helpers">\r
       <Private>False</Private>\r
       <HintPath>..\lib\J2SE.Helpers.dll</HintPath>\r
   -->\r
   <ProjectExtensions>\r
     <VisualStudio>\r
-      <UserProperties REFS-JarPath-system-configuration="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Configuration.jar" REFS-JarPath-system-data="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Data.jar" REFS-JarPath-system-drawing="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Drawing.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\jai_imageio.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\jai_core.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\jai_codec.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\clibwrapper_jiio.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\mlibwrapper_jai.jar" REFS-JarPath-system-xml="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Xml.jar" REFS-JarPath-system="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.jar" REFS-JarPath-mscorlib="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE 2\jgac\vmw4j2ee_110\mscorlib.jar" REFS-JarPath-rt="..\lib\rt.jar" REFS-JarPath-j2se-helpers="..\lib\J2SE.Helpers.jar" />\r
+      <UserProperties REFS-JarPath-system-configuration="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Configuration.jar" REFS-JarPath-system-data="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Data.jar" REFS-JarPath-system-drawing="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Drawing.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\jai_imageio.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\jai_core.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\jai_codec.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\clibwrapper_jiio.jar;..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\mlibwrapper_jai.jar" REFS-JarPath-system-xml="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.Xml.jar" REFS-JarPath-system="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE V2\jgac\vmw4j2ee_110\System.jar" REFS-JarPath-mscorlib="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE 2\jgac\vmw4j2ee_110\mscorlib.jar" REFS-JarPath-rt="..\lib\rt.jar" REFS-JarPath-j2ee="..\llib\j2ee.jar" REFS-JarPath-j2ee-helpers="..\lib\J2EE.Helpers.jar" REFS-JarPath-j2se-helpers="..\lib\J2SE.Helpers.jar" />\r
     </VisualStudio>\r
   </ProjectExtensions>\r
 </Project>\r