Author: husted
Date: Fri Jun 24 12:45:16 2005
New Revision: 201671

URL: http://svn.apache.org/viewcvs?rev=201671&view=rev
Log:
OVR-11
* Refactor and refine behavior; update comments.

Modified:
    struts/sandbox/trunk/overdrive/Agility/Core/Chain.cs
    struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx
    struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/GridViewHelper.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/IGridViewHelper.cs

Modified: struts/sandbox/trunk/overdrive/Agility/Core/Chain.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Agility/Core/Chain.cs?rev=201671&r1=201670&r2=201671&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Agility/Core/Chain.cs (original)
+++ struts/sandbox/trunk/overdrive/Agility/Core/Chain.cs Fri Jun 24 12:45:16 
2005
@@ -87,7 +87,7 @@
                public void AddCommand (ICommand command)
                {
                        if (command == null)
-                               throw new ArgumentNullException ("context", 
"Chain.AddCommand");
+                               throw new ArgumentNullException 
("command==null", "Chain.AddCommand");
                        if (frozen)
                                throw new ApplicationException 
("Chain.AddCommand: frozen==true");
                        ICommand[] results = new ICommand[commands.Length + 1];
@@ -102,7 +102,7 @@
                        set
                        {
                                if (value == null)
-                                       throw new ArgumentNullException 
("context", "Chain.AddCommands");
+                                       throw new ArgumentNullException 
("value==null", "Chain.AddCommands");
                                IEnumerator elements = value.GetEnumerator ();
                                while (elements.MoveNext ()) AddCommand 
(elements.Current as ICommand);
                        }
@@ -114,7 +114,7 @@
                {
                        // Verify our parameters
                        if (context == null)
-                               throw new ArgumentNullException ("context", 
"Chain.Execute");
+                               throw new ArgumentNullException 
("context==null", "Chain.Execute");
 
                        // Freeze the configuration of the command list
                        frozen = true;

Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs?rev=201671&r1=201670&r2=201671&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs Fri Jun 24 
12:45:16 2005
@@ -80,7 +80,7 @@
                        }
                }
 
-               public IList Outcome
+               public virtual IList Outcome
                {
                        get
                        {
@@ -128,7 +128,7 @@
                        get { return Context.HasFault; }
                }
 
-               public bool IsNominal
+               public virtual bool IsNominal
                {
                        get { return (!HasAlerts && !HasFault); }
                }
@@ -154,7 +154,7 @@
                }
 
                private IList _FieldSet;
-               public IList FieldSet
+               public virtual IList FieldSet
                {
                        get { return _FieldSet; }
                        set { _FieldSet = value; }
@@ -236,12 +236,16 @@
                /// making Context the cornerstone property.
                /// </remarks>
                /// 
-               public IRequestContext Context
+               public virtual IRequestContext Context
                {
                        get
                        {
                                if (_Context == null)
-                                       _Context = Catalog.GetRequest (Command);
+                               {
+                                       IRequestCommand rc = Command;
+                                       if (rc==null) throw new 
ArgumentNullException("Command==null","ViewHelper.Context");
+                                       _Context = Catalog.GetRequest (rc);
+                               }
                                return _Context;
                        }
                }

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx?rev=201671&r1=201670&r2=201671&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx Fri Jun 24 
12:45:16 2005
@@ -3,7 +3,7 @@
 
 <html>
   <head>
-    <title>GridBasePage</title>
+    <title>BaseGridPage</title>
     <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
     <meta name="CODE_LANGUAGE" Content="C#">
     <meta name=vs_defaultClientScript content="JavaScript">

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx.cs?rev=201671&r1=201670&r2=201671&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/BaseGridPage.aspx.cs Fri Jun 24 
12:45:16 2005
@@ -8,22 +8,57 @@
 namespace Nexus.Web
 {
        /// <summary>
-       /// Base page for using a IGridViewHelper.
+       /// Provide common functionality for page that is configured to use a 
IGridViewHelper.
        /// </summary>
+       /// <remarks><p>
+       /// The implementing code-benhind needs to 
+       /// * extend BaseGridPage, 
+       /// * inject a instance of IGridViewHelper, and
+       /// * override Page_Error and Page_Prompt (optional). 
+       /// GridViewHelper is abstract, and you need to implement your own 
NewEntryList method. 
+       /// </p><p>
+       /// The ASPX page needs to provide 
+       /// * pnlError
+       /// * pnlList
+       /// * repList
+       /// * cmdAddList
+       /// </p>
+       /// <p>
+       /// If a Find dialog is provided, the implementing code behind can 
override 
+       /// * Find_Init, 
+       /// * Find_Load, and 
+       /// * Find_Submit.
+       /// The ListHelper will use the criteria setup by Find_Submit to 
consumate the search.
+       /// </p><p>
+       /// The BasePage and Helper provide all the routine functionality need 
to display a 
+       /// datagrid with an arbitrary set of columns for inline editing. 
+       /// The remaining functionality is provided by configuring the 
GridViewHelper instance
+       /// with the FindHelper, ListHelper, and SaveHelper needed for each 
respective task. 
+       /// The Helpers do not have to be written specially, and may even be 
used elsewhere. 
+       /// The GridViewHelper and BasePage manage the Helpers, which provide 
the custom 
+       /// functionalty for the specified columns. 
+       /// </p><p>
+       /// The columns to edit are configured through the Helper's FieldSet. 
+       /// Each column must be a FieldContext. 
+       /// The FieldContext Label is used for the column heading.
+       /// </p><p>
+       /// For a working example, see Directory2 in the PhoneBook application.
+       /// </p></remarks>
        public class BaseGridPage : Page
        {
 
                #region Helper
 
-               private IGridViewHelper _Helper;
+               private IGridViewHelper _GridHelper;
                /// <summary>
-               /// Obtain dynamic data for the default view.
+               /// Encapsulate three Helpers that work together
+               /// to Find, List, and Save DataGrid entries.
                /// </summary>
                ///
-               public virtual IGridViewHelper Helper
+               public virtual IGridViewHelper GridHelper
                {
-                       get { return _Helper; }
-                       set { _Helper = value; }
+                       get { return _GridHelper; }
+                       set { _GridHelper = value; }
                }
 
                #endregion
@@ -31,9 +66,13 @@
                #region Page Properties 
 
                private IViewHelper _Page_Error;
-               /// <summary>
-               /// Set is called when an error occurs; override to provide 
functionality.
-               /// </summary>          
+               ///<summary>
+               ///Handle error messages.
+               ///</summary>
+               /// <remarks><p>
+               /// Set is called when an error occurs. 
+               /// Override to provide functionality.
+               /// </p></remarks>              
                protected virtual IViewHelper Page_Error
                {
                        set {_Page_Error = value;}
@@ -41,9 +80,12 @@
                }
 
                private string _Page_Prompt;
-               /// <summary>
+               ///<summary>
+               ///Handle page prompts.
+               ///</summary>
+               /// <remarks><p>
                /// Set is called when the prompt changes; override to provide 
functionality.
-               /// </summary>          
+               /// </p></remarks>              
                protected virtual string Page_Prompt
                {
                        set {_Page_Prompt = value;}
@@ -68,32 +110,14 @@
                #region Page Properties
 
                /// <summary>
-               /// Attribute token for List_Criteria.
-               /// </summary>
-               private string LIST_CRITERIA_KEY = "__LIST_CRITERIA_KEY";
-
-               /// <summary>
-               /// Values to use with a query statement.
-               /// </summary>
-               public virtual IDictionary List_Criteria
-               {
-                       get
-                       {
-                               IDictionary criteria = ViewState 
[LIST_CRITERIA_KEY] as IDictionary;
-                               return criteria;
-                       }
-                       set { ViewState [LIST_CRITERIA_KEY] = value; }
-               }
-
-               /// <summary>
-               /// Attribute token for List_ItemIndex
+               /// Identify the attribute token for List_ItemIndex
                /// </summary>
                private const string LIST_ITEM_INDEX = "__LIST_ITEM_INDEX";
 
                /// <summary>
-               /// Current item index, used mainly to signal editing. 
+               /// Store the current item index, mainly to signal edit mode. 
                /// </summary>
-               public virtual int List_ItemIndex
+               protected virtual int List_ItemIndex
                {
                        get
                        {
@@ -109,28 +133,28 @@
                }
 
                /// <summary>
-               /// Attribute token for List_ItemKey.
+               /// Identify the attribute token for List_ItemKey.
                /// </summary>
                private const string LIST_ITEM_KEY = "__LIST_ITEM_KEY";
 
                /// <summary>
-               /// The data key for the selected item.
+               /// Store the data key for the selected item.
                /// </summary>
-               public virtual string List_ItemKey
+               protected virtual string List_ItemKey
                {
                        get { return ViewState [LIST_ITEM_KEY] as string; }
                        set { ViewState [LIST_ITEM_KEY] = value; }
                }
 
                /// <summary>
-               /// Attribute token for List_Insert.
+               /// Identify the attribute token for List_Insert.
                /// </summary>
                private const string LIST_INSERT_KEY = "__LIST_INSERT_KEY";
 
                /// <summary>
-               /// Insert mode - are we adding or modifying?
+               /// Store insert mode (are we adding or modifying?).
                /// </summary>
-               public virtual bool List_Insert
+               protected virtual bool List_Insert
                {
                        get
                        {
@@ -151,12 +175,21 @@
 
                protected Panel pnlFind;
 
-               protected virtual bool Find_Submit (string prefix)
+               protected virtual void Find_Init ()
+               {
+                       // override to provide functionality
+               }
+
+               protected virtual void Find_Load () 
                {
-                       IViewHelper h = Helper;
+                       // override to provide functionality
+               }
+
+               protected virtual void Find_Submit (object sender, EventArgs e)
+               {
+                       IViewHelper h = GridHelper;
                        h.Read (pnlFind.Controls);
-                       List_Criteria = h.Criteria;
-                       return List_Load ();
+                       List_Load ();
                }
 
                #endregion
@@ -175,8 +208,8 @@
 
                protected virtual bool List_Load ()
                {
-                       IGridViewHelper h = Helper;
-                       bool okay = h.Load (repList, List_Criteria);
+                       IGridViewHelper h = GridHelper;
+                       bool okay = h.Load (repList, h.FindHelper.Criteria);
                        if (okay)
                        {
                                // 
Template_Load(h.TitleText,h.HeadingText,h.PromptText);
@@ -186,7 +219,7 @@
                        else
                        {
                                pnlList.Visible = false;
-                               Page_Error = h;
+                               Page_Error = h.ListHelper;
                        }
                        return okay;
                }
@@ -227,7 +260,7 @@
 
                protected virtual void List_Save (string key, ICollection 
controls)
                {
-                       IGridViewHelper h = Helper;
+                       IGridViewHelper h = GridHelper; 
                        bool okay = h.Save (key, controls);
                        if (okay)
                        {
@@ -237,19 +270,19 @@
                                List_ItemIndex = -1;
                                List_Refresh ();
                        }
-                       if (!okay) Page_Error = h;
+                       if (!okay) Page_Error = h.SaveHelper; 
                }
 
                protected virtual void List_Refresh ()
                {
-                       IGridViewHelper h = Helper;
+                       IGridViewHelper h = GridHelper;
                        h.DataBind (repList);
                        pnlList.Visible = true;
                }
 
                protected virtual void List_Add_Load ()
                {
-                       IGridViewHelper h = Helper;
+                       IGridViewHelper h = GridHelper;
                        bool okay = h.DataInsert (repList);
                        if (okay)
                        {
@@ -258,7 +291,7 @@
                                List_ItemIndex = 0;
                                pnlList.Visible = true;
                        }
-                       else Page_Error = h;
+                       else Page_Error = h.ListHelper;
                }
 
                #endregion
@@ -288,7 +321,7 @@
 
                protected void List_Save (object source, 
DataGridCommandEventArgs e)
                {
-                       IGridViewHelper h = Helper;
+                       IGridViewHelper h = GridHelper;
                        string key = (List_Insert) ? null : h.GetDataKey (e, 
repList);
                        ICollection controls = h.GetControls (e, repList);
                        List_Save (key, controls);
@@ -322,21 +355,29 @@
 
                #region Page events
 
-               protected void Page_Init ()
+               protected virtual void Page_Init ()
                {
+                       Find_Init ();
                        List_Init ();
-                       bool isFirstView = !IsPostBack;
-                       if (isFirstView)
-                               pnlList.Visible = false;
+
+                       if (!IsPostBack)
+                       {
+                               pnlList.Visible = false;                        
        
+                       }
                }
 
-               protected void Page_Load (object sender, EventArgs e)
+               protected virtual void Page_Load (object sender, EventArgs e)
                {
+
+                       if (!IsPostBack)
+                       {
+                               Find_Load ();
+                       }
+
                        if (pnlList.Visible)
                                List_Load ();
                }
 
                #endregion
-
        }
 }

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/GridViewHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/GridViewHelper.cs?rev=201671&r1=201670&r2=201671&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridViewHelper.cs Fri Jun 24 
12:45:16 2005
@@ -15,6 +15,18 @@
        /// </summary>
        public abstract class GridViewHelper : WebViewHelper, IGridViewHelper
        {
+               #region IViewHelper 
+
+               /// <remarks><p>
+               /// Check to see if the Helpers are all good; 
+               /// though, most often an individual Helper is checked instead. 
+               /// </p></remarks>
+               public override bool IsNominal
+               {
+                       get { return FindHelper.IsNominal && 
ListHelper.IsNominal && SaveHelper.IsNominal;  }
+               }
+
+               #endregion
 
                #region IListViewHelper
 
@@ -117,7 +129,7 @@
                                ExecuteList (grid, criteria);
                        else
                                ExecuteList (grid);
-                       return IsNominal;
+                       return ListHelper.IsNominal;
                }
 
                public virtual bool Find (ICollection controls)
@@ -136,7 +148,7 @@
                public virtual bool List (DataGrid grid)
                {
                        ListHelper.Execute();
-                       bool okay = IsNominal ;
+                       bool okay = ListHelper.IsNominal ;
                        if (okay)
                        {
                                DataSource (grid);
@@ -165,8 +177,9 @@
                                }
 
                                ReadGridControls (controls, 
SaveHelper.Criteria, keys, SaveHelper.NullIfEmpty);
+                               SaveHelper.Execute();
                        }
-                       return IsNominal ;
+                       return SaveHelper.IsNominal ;
                }
 
                public virtual int BindItemColumn (DataGrid grid, int i)
@@ -223,7 +236,7 @@
                        grid.CurrentPageIndex = 0;
                        grid.EditItemIndex = 0;
                        DataBind (grid);
-                       return IsNominal ;
+                       return ListHelper.IsNominal ;
                }
 
                public virtual void DataBind (DataGrid grid)
@@ -260,10 +273,12 @@
 
                public virtual bool ExecuteList (DataGrid grid, IDictionary 
criteria)
                {
-                       ListHelper.ReadExecute(criteria);
-                       bool okay = ListHelper.IsNominal ;
-                       if (okay) BindGrid (grid);
-                       return okay;
+                       IDictionary target = ListHelper.Criteria;
+                       foreach (DictionaryEntry e in criteria)
+                       {
+                               target[e.Key] = e.Value;
+                       }
+                       return ExecuteList(grid);
                }
 
                public string GetDataKey (DataGridCommandEventArgs e, DataGrid 
grid)

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/IGridViewHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/IGridViewHelper.cs?rev=201671&r1=201670&r2=201671&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/IGridViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/IGridViewHelper.cs Fri Jun 24 
12:45:16 2005
@@ -11,15 +11,50 @@
        {
                #region IListViewHelper
 
+               /// <summary>
+               /// Collect search criteria to use with List command. 
+               /// </summary>
+               /// 
                IViewHelper FindHelper { get; set; }
+
+               /// <summary>
+               /// Filter matching entries for display.
+               /// </summary>
+               /// 
                IViewHelper ListHelper { get; set; }
+
+               /// <summary>
+               /// Update persistent store.
+               /// </summary>
+               /// 
                IViewHelper SaveHelper { get; set; }
 
+               /// <summary>
+               /// Label the EDIT control.
+               /// </summary>
+               /// 
                string EditText { get; set; }
+
+               /// <summary>
+               /// Label the QUIT control.
+               /// </summary>
+               /// 
                string QuitText { get; set; }
+
+               /// <summary>
+               /// Label the SAVE control.
+               /// </summary>
+               /// 
                string SaveText { get; set; }
 
+               /// <summary>
+               /// Label the custom ITEM control
+               /// </summary>
                string ItemText { get; set; }
+
+               /// <summary>
+               /// Identify the command for the custom ITEM control.
+               /// </summary>
                string ItemCommandName { get; set; }
 
                /// <summary>
@@ -61,7 +96,7 @@
                bool Load (DataGrid grid, IDictionary criteria);
 
                /// <summary>
-               /// Execute find command (enter search criteria).
+               /// Execute find (what?) command (enter search criteria).
                /// </summary>
                /// <param name="controls">The list of controls to which to 
bind values.</param>
                bool Find (ICollection controls);
@@ -120,17 +155,17 @@
                void DataSource (DataGrid grid);
 
                /// <summary>
-               /// Use the DataFields property to create a blank row.
+               /// Ccreate a blank row in the datagrid.
                /// </summary>
                /// <param name="grid">Our datagrid instance</param>
                bool DataInsert (DataGrid grid);
 
                /// <summary>
-               /// Convenience method to bind our datagrid.
+               /// Bind our datagrid to the datasource.
                /// </summary>
-               /// <comment>
+               /// <remarks><p>
                /// Usually called just after DataSource.
-               /// </comment>
+               /// </p></remarks>
                /// <param name="grid">Our datagrid instance</param>
                void DataBind (DataGrid grid);
 
@@ -141,14 +176,14 @@
                void BindGrid (DataGrid grid);
 
                /// <summary>
-               /// Run ExecuteContext using the ListCommand and bind the 
result.
+               /// Run ExecuteContext using the ListHelper, and bind the 
result.
                /// </summary>
                /// <param name="grid">A DataGrid instance</param>
                /// <returns>True if the Context is nominal.</returns>
                bool ExecuteList (DataGrid grid);
 
                /// <summary>
-               /// Run Execute using the ListCommand and supplied criteria and 
bind the result.
+               /// Run Execute using the ListHelper and supplied criteria, and 
bind the result.
                /// </summary>
                /// <param name="grid">A DataGrid instance</param>
                /// <param name="criteria">Criteria values</param>
@@ -164,7 +199,7 @@
                string GetDataKey (DataGridCommandEventArgs e, DataGrid grid);
 
                /// <summary>
-               /// Create a collection of the controls in the current DataGrid 
cell.
+               /// Create a collection of the controls based on the current 
DataGrid cell.
                /// </summary>
                /// <param name="e">Current event</param>
                /// <param name="grid">The DataGrid</param>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to