You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2005/09/13 21:33:13 UTC

svn commit: r280631 - in /struts/sandbox/trunk/overdrive/Nexus: Test/bin/Debug/ Web/

Author: husted
Date: Tue Sep 13 12:33:00 2005
New Revision: 280631

URL: http://svn.apache.org/viewcvs?rev=280631&view=rev
Log:
OVR-21
* Continue refactorings for user controls.

Added:
    struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs
Modified:
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb
    struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs Tue Sep 13 12:33:00 2005
@@ -207,10 +207,12 @@
 			set { _HasItemColumn = value; }
 		}
 
+		private bool _HasEditColumn = false;
+
 		public virtual bool HasEditColumn
 		{
-			get { return (SaveCommand != null); }
-			set { throw new NotImplementedException(); }
+			get { return _HasEditColumn; }
+			set { _HasEditColumn = value; }
 		}
 
 		#endregion		
@@ -306,6 +308,50 @@
 
 		#endregion 
 
+		#region Special ReadControls method 
+
+		private void ReadGridControls(ControlCollection controls, IDictionary dictionary, string[] keys, bool nullIfEmpty)
+		{
+			int i = 0;
+			foreach (Control t in controls)
+			{
+				string key = keys[i];
+				if (IsTextBox(t))
+				{
+					TextBox x = (TextBox) t;
+					string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
+					dictionary.Add(key, value);
+				}
+				if (IsLabel(t))
+				{
+					Label x = (Label) t;
+					string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
+					dictionary.Add(key, value);
+				}
+				if (IsListControl(t))
+				{
+					ListControl x = (ListControl) t;
+					string value = (nullIfEmpty) ? NullIfEmpty(x.SelectedValue) : x.SelectedValue;
+					dictionary.Add(key, value);
+				}
+				if (IsCheckBox(t))
+				{
+					CheckBox x = (CheckBox) t;
+					string value = (x.Checked) ? key : null;
+					dictionary.Add(key, value);
+				}
+				if (IsRadioButton(t))
+				{
+					RadioButton x = (RadioButton) t;
+					string value = (x.Checked) ? key : null;
+					dictionary.Add(key, value);
+				}
+				i++;
+			}
+		}
+
+		#endregion
+
 		#region Command methods
 
 		/// <summary>
@@ -355,7 +401,7 @@
 				// append our field names to the array of keys
 				for (int i = 0; i < cols; i++)
 					keys[index++] = DataFields[i] as string;
-				ReadControls(h.Criteria, keys, true);
+				ReadGridControls(controls,h.Criteria, keys, true);
 				h.Execute();
 			}
 			return h;
@@ -369,16 +415,15 @@
 		{
 			IViewHelper helper = Execute(ListCommand);
 			bool okay = helper.IsNominal;
-			if (okay) BindGrid(helper);
+			if (okay) BindGrid(helper); // DoBindGrid = helper;
 			return helper;
 		}
 
 		public virtual IViewHelper ExecuteList(IDictionary criteria)
 		{
-			IViewHelper helper = GetHelperFor(ListCommand);
-			helper.ReadExecute(criteria);
+			IViewHelper helper = ReadExecute(ListCommand);
 			bool okay = helper.IsNominal;
-			if (okay) BindGrid(helper);
+			if (okay) BindGrid(helper); // DoBindGrid = helper;
 			return helper;
 		}
 
@@ -461,6 +506,20 @@
 			DataBind();
 		}
 
+		/// <summary>
+		/// Set the selected index to 0. 
+		/// </summary>
+		/// <remarks><p>
+		/// When changing the find set, also call List_ResetIndex;
+		/// otherwise, the DataGrid may try to select an item 
+		/// that is outside the new found set.
+		/// </p></remarks>
+		protected void list_ResetIndex()
+		{
+			Grid.SelectedIndex = 0;
+			Grid.CurrentPageIndex = 0; // sic
+		}
+
 		protected virtual void list_Add_Load()
 		{
 			IViewHelper helper = DataInsert();
@@ -531,7 +590,7 @@
 				list_ItemIndex = -1;
 				list_Refresh();
 			}
-			// ISSUE: Event? if (!okay) Page_Error = Helper;
+			if (!okay) Page_Error = helper;
 		}
 
 		protected void list_Quit(object source, DataGridCommandEventArgs e)

Added: struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs?rev=280631&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs Tue Sep 13 12:33:00 2005
@@ -0,0 +1,44 @@
+using System;
+using System.Collections;
+using System.Web.UI;
+using Nexus.Core.Helpers;
+
+namespace Nexus.Web
+{
+	public interface IViewControl
+	{
+
+		/// <summary>
+		/// Set Labels and TextBoxes to an empty string 
+		/// to ensure inappropriate values are not carried over.
+		/// </summary>
+		/// 
+		void ResetControls();
+		
+		IViewHelper GetHelperFor(string command);
+		IViewHelper Execute(string command);
+
+		void Bind(ControlCollection controls, IDictionary dictionary);
+		void Bind(IDictionary dictionary);
+
+		void ExecuteBind(ControlCollection controls, IViewHelper helper);
+		void ExecuteBind(IViewHelper helper);
+
+		IViewHelper ExecuteBind(ControlCollection controls, string command);
+		IViewHelper ExecuteBind(string command);
+		
+		IViewHelper Read(string command, bool nullIfEmpty);
+		IViewHelper Read(string command);
+		
+		IViewHelper ReadExecute(string command, bool nullIfEmpty);
+		IViewHelper ReadExecute(string command);
+
+		IViewHelper ReadExecute(ControlCollection collection, string command, bool nullIfEmpty);
+		IViewHelper ReadExecute(ControlCollection collection, string command);
+
+		IViewHelper Read(string command, IDictionary criteria, bool nullIfEmpty);
+		IViewHelper ReadExecute(string command, IDictionary criteria, bool nullIfEmpty);
+		IViewHelper ReadExecute(string command, IDictionary criteria);
+
+	}
+}

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs Tue Sep 13 12:33:00 2005
@@ -11,31 +11,8 @@
 	/// <summary>
 	/// Base class for view controls (sub forms).
 	/// </summary>
-	public class ViewControl : UserControl
+	public class ViewControl : UserControl, IViewControl
 	{
-		private string _TitleText;
-
-		public virtual string TitleText
-		{
-			get { return _TitleText; }
-			set { _TitleText = value; }
-		}
-
-		private string _HeadingText;
-
-		public virtual string HeadingText
-		{
-			get { return _HeadingText; }
-			set { _HeadingText = value; }
-		}
-
-		private string _PromptText;
-
-		public virtual string PromptText
-		{
-			get { return _PromptText; }
-			set { _PromptText = value; }
-		}
 
 		private IRequestCatalog _Catalog;
 
@@ -62,11 +39,10 @@
 			set { View_Error_Send(this, new ViewArgs(value)); }
 		}
 
-		#region Control utilities
 
 		#region String utilities 
 
-		private string NullIfEmpty(string input)
+		protected string NullIfEmpty(string input)
 		{
 			return (string.Empty.Equals(input)) ? null : input;
 		}
@@ -121,6 +97,8 @@
 
 		#endregion
 
+		#region Control utilities
+
 		/// <summary>
 		/// Return true if control is a Label.
 		/// </summary>
@@ -206,12 +184,11 @@
 			}
 		}
 
-		/// <summary>
-		/// Set Labels and TextBoxes to an empty string 
-		/// to ensure inappropriate values are not carried over.
-		/// </summary>
-		/// 
-		protected void ResetControls()
+		#endregion 
+
+		#region IViewControl methods
+
+		public void ResetControls()
 		{
 			ControlCollection controls = this.Controls;
 			foreach (Control control in controls)
@@ -234,22 +211,21 @@
 			}
 		}
 
-		protected IViewHelper GetHelperFor(string command)
+		public IViewHelper GetHelperFor(string command)
 		{
 			IViewHelper helper = Catalog.GetHelperFor(command);
 			return helper;
 		}
 
-		protected IViewHelper Execute(string command)
+		public IViewHelper Execute(string command)
 		{
 			IViewHelper helper = GetHelperFor(command);
 			helper.Execute();
 			return helper;
 		}
 
-		protected void BindControls(IDictionary dictionary, string prefix, string list_suffix)
+		private void BindControls(ControlCollection controls, IDictionary dictionary, string prefix, string list_suffix)
 		{
-			ControlCollection controls = this.Controls;
 			foreach (Control t in controls)
 			{
 				if (IsTextBox(t))
@@ -278,29 +254,39 @@
 			}
 		}
 
-		protected void BindControls(IDictionary dictionary, string prefix)
+		public void Bind(ControlCollection controls, IDictionary dictionary)
 		{
-			BindControls(dictionary, prefix, ListSuffix);
+			BindControls(controls, dictionary, null, ListSuffix);
 		}
 
-		protected void BindControls(IDictionary dictionary)
+		public void Bind(IDictionary dictionary)
 		{
-			BindControls(dictionary, null, ListSuffix);
+			BindControls(this.Controls, dictionary, null, ListSuffix);
 		}
 
-		protected IViewHelper ExecuteBind(string command)
+		public void ExecuteBind(ControlCollection controls, IViewHelper helper)
 		{
-			IViewHelper helper = GetHelperFor(command);
 			helper.Execute();
-			BindControls(helper.Criteria);
+			Bind(controls,helper.Criteria);
+		}
+
+		public IViewHelper ExecuteBind(ControlCollection controls, string command)
+		{
+			IViewHelper helper = GetHelperFor(command);
+			ExecuteBind(controls,helper);
 			return helper;
 		}
 
-		protected void ExecuteBind(IViewHelper helper)
+		public void ExecuteBind(IViewHelper helper)
 		{
-			helper.Execute();
-			BindControls(helper.Criteria);
-			if (helper.IsNominal) helper.Execute();
+			ExecuteBind(this.Controls,helper);
+		}
+
+		public IViewHelper ExecuteBind(string command)
+		{
+			IViewHelper helper = GetHelperFor(command);
+			ExecuteBind(helper);
+			return helper;
 		}
 
 		/// <summary>
@@ -319,51 +305,7 @@
 			return trimmed;
 		}
 
-
-		protected void ReadControls(IDictionary dictionary, string[] keys, bool nullIfEmpty)
-		{
-			ControlCollection controls = this.Controls;
-			int i = 0;
-			foreach (Control t in controls)
-			{
-				string key = keys[i];
-				if (IsTextBox(t))
-				{
-					TextBox x = (TextBox) t;
-					string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
-					dictionary.Add(key, value);
-				}
-				if (IsLabel(t))
-				{
-					Label x = (Label) t;
-					string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
-					dictionary.Add(key, value);
-				}
-				if (IsListControl(t))
-				{
-					ListControl x = (ListControl) t;
-					string value = (nullIfEmpty) ? NullIfEmpty(x.SelectedValue) : x.SelectedValue;
-					dictionary.Add(key, value);
-				}
-				if (IsCheckBox(t))
-				{
-					CheckBox x = (CheckBox) t;
-					string value = (x.Checked) ? key : null;
-					dictionary.Add(key, value);
-				}
-				if (IsRadioButton(t))
-				{
-					RadioButton x = (RadioButton) t;
-					string value = (x.Checked) ? key : null;
-					dictionary.Add(key, value);
-				}
-				i++;
-			}
-		}
-
-		protected void ReadControls(IDictionary dictionary, string prefix, string list_suffix, bool nullIfEmpty)
-		{
-			ControlCollection controls = this.Controls;
+		private void ReadControls(ControlCollection controls, IDictionary dictionary, string prefix, string list_suffix, bool nullIfEmpty) {
 			foreach (Control t in controls)
 			{
 				if (IsTextBox(t))
@@ -402,53 +344,66 @@
 			}
 		}
 
-		protected void ReadControls(IDictionary dictionary, bool nullIfEmpty)
+		public IViewHelper Read(ControlCollection controls, string command, bool nullIfEmpty)
 		{
-			ReadControls(dictionary, null, ListSuffix, nullIfEmpty);
+			IViewHelper helper = GetHelperFor(command);
+			ReadControls(controls,helper.Criteria,null,ListSuffix,nullIfEmpty);
+			return helper;			
 		}
 
-		protected IViewHelper Read(string command, bool nullIfEmpty)
+		public IViewHelper Read(string command, bool nullIfEmpty)
 		{
-			IViewHelper helper = GetHelperFor(command);
-			ReadControls(helper.Criteria, nullIfEmpty);
+			return Read(this.Controls, command, nullIfEmpty);
+		}
+		
+		public IViewHelper Read(string command)
+		{
+			return Read(this.Controls,  command, true);
+		}
+
+		public IViewHelper ReadExecute(ControlCollection collection, string command, bool nullIfEmpty)
+		{			
+			IViewHelper helper = Read(collection, command, nullIfEmpty);
+			helper.Execute();
 			return helper;
 		}
 
-		protected IViewHelper Read(string command)
+		public IViewHelper ReadExecute(ControlCollection collection, string command)
 		{
-			return Read(command, true);
+			return ReadExecute(collection, command, true);
 		}
 
-		protected IViewHelper ReadExecute(string command, bool nullIfEmpty)
+
+		public IViewHelper ReadExecute(string command, bool nullIfEmpty)
 		{
-			IViewHelper helper = Read(command, nullIfEmpty);
-			helper.Execute();
-			return helper;
+			return ReadExecute(this.Controls, command, nullIfEmpty);
 		}
 
-		protected IViewHelper ReadExecute(string command)
+		public IViewHelper ReadExecute(string command)
 		{
-			return ReadExecute(command, true);
+			return ReadExecute(this.Controls, command, true);
 		}
 
-		protected IViewHelper Read(string command, IDictionary criteria, bool nullIfEmpty)
+
+		public IViewHelper Read(string command, IDictionary criteria, bool nullIfEmpty)
 		{
 			IViewHelper helper = GetHelperFor(command);
 			helper.Read(criteria, nullIfEmpty);
 			return helper;
 		}
 
-		protected IViewHelper ReadExecute(string command, IDictionary criteria, bool nullIfEmpty)
+		public IViewHelper ReadExecute(string command, IDictionary criteria)
 		{
-			IViewHelper helper = Read(command, criteria, nullIfEmpty);
-			helper.Execute();
-			return helper;
+			return ReadExecute(command, criteria, true);
 		}
 
-		protected IViewHelper ReadExecute(string command, IDictionary criteria)
+		public IViewHelper ReadExecute(string command, IDictionary criteria, bool nullIfEmpty)
 		{
-			return ReadExecute(command, criteria, true);
+			IViewHelper helper = Read(command, criteria, nullIfEmpty);
+			helper.Execute();
+			return helper;
 		}
+		#endregion
 
 		#region ListControl methods 
 
@@ -517,8 +472,6 @@
 			if (insertKey) list.Insert(0, NullKey);
 			BindListControl(control, list, null);
 		}
-
-		#endregion
 
 		#endregion
 

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj?rev=280631&r1=280630&r2=280631&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj Tue Sep 13 12:33:00 2005
@@ -175,6 +175,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "IViewControl.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Messages.resx"
                     BuildAction = "EmbeddedResource"
                 />



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org