Author: husted Date: Sat Oct 15 09:05:36 2005 New Revision: 321362 URL: http://svn.apache.org/viewcvs?rev=321362&view=rev Log: OVR-5 * Extend XML docs. Minor code refactorings.
Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntry.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryList.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryListProcessor.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs struts/sandbox/trunk/overdrive/PhoneBook/Test/BaseTest.cs struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/DirectoryViewTest.cs struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs struts/sandbox/trunk/overdrive/PhoneBook/Test/Forms/DirectoryTest.cs struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder.ascx.cs struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder2.ascx.cs struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister.ascx.cs struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs Sat Oct 15 09:05:36 2005 @@ -112,12 +112,6 @@ public const string ENTRY_LIST = "entry_list"; /// <summary> - /// Token for the count of a select all command. - /// </summary> - /// - public const string ENTRY_LIST_COUNT = "entry_list_count"; - - /// <summary> /// Token for List Last Names command. /// </summary> /// Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntry.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntry.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntry.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntry.cs Sat Oct 15 09:05:36 2005 @@ -23,8 +23,22 @@ /// public class AppEntry { + + /// <summary> + /// Internal storage. + /// </summary> + /// private IDictionary _Value = new Hashtable(5); + /// <summary> + /// Add each source entry to our internal store. + /// </summary> + /// <remarks><p> + /// Entries with keys that match the property names will be exposed. + /// Other entries may be added, but can only be retrieved via Get. + /// </p></remarks> + /// <param name="sources">Entries to add</param> + /// public void AddAll(IDictionary sources) { ICollection keys = sources.Keys; @@ -34,17 +48,43 @@ } } + /// <summary> + /// Add a single entry to our internal store. + /// </summary> + /// <remarks><p> + /// Entries with keys that match the property names will be exposed. + /// Other entries may be added, but can only be retrieved via Get. + /// </p></remarks> + /// <param name="key">ID for entry</param> + /// <param name="value">Content for entry</param> + /// public void Add(string key, string value) { _Value.Add(key, value); } - private string Get(string key) + /// <summary> + /// Provide the value corresponding to key from the internal store. + /// </summary> + /// <param name="key">ID for entry</param> + /// <returns>Content for entry</returns> + /// + public string Get(string key) { return _Value[key] as string; } - private void Set(string key, string value) + /// <summary> + /// Set an entry to the internal store, overwriting any existing entry. + /// </summary> + /// <remarks><p> + /// This is a protected method used by the Properties. + /// Use an existing Property to set values, + /// or extend the class to include other Properties. + /// </p></remarks> + /// <param name="key"></param> + /// <param name="value"></param> + protected void Set(string key, string value) { _Value[key] = value; } Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryList.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryList.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryList.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryList.cs Sat Oct 15 09:05:36 2005 @@ -4,7 +4,7 @@ namespace PhoneBook.Core { /// <summary> - /// Implement IEntryList for AppEntry objects. + /// Implement Nexus.Core.IEntryList for AppEntry objects. /// </summary> /// public class AppEntryList : ArrayList, IEntryList Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryListProcessor.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryListProcessor.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryListProcessor.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppEntryListProcessor.cs Sat Oct 15 09:05:36 2005 @@ -3,6 +3,10 @@ namespace PhoneBook.Core { + /// <summary> + /// Implement Nexus.Core.Validators.EntryListProcess for AppEntryList. + /// </summary> + /// public class AppEntryListProcessor : EntryListProcessor { public override IEntryList NewEntryList() Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs Sat Oct 15 09:05:36 2005 @@ -5,20 +5,39 @@ namespace PhoneBook.Core { /// <summary> - /// Extend UserProfile to include an IsEditor property. + /// Extend UserProfile to include properties specific to this application, + /// such as IsEditor. /// </summary> + /// public class AppUserProfile : UserProfile { + + /// <summary> + /// Provide a field for IsEditor property. + /// </summary> private bool _IsEditor = false; + /// <summary> + /// Indicate whether user has editing priveleges. + /// </summary> + /// public bool IsEditor { get { return _IsEditor; } set { _IsEditor = value; } } + /// <summary> + /// Provide a field for Entry property. + /// </summary> + /// private AppEntry _Entry; + + /// <summary> + /// Record directory entry for user. + /// </summary> + /// public AppEntry Entry { get { return _Entry; } @@ -36,8 +55,16 @@ } } + /// <summary> + /// Provide a field for FullName property. + /// </summary> + /// private string _FullName; + /// <summary> + /// Record the user's full name (first and last names). + /// </summary> + /// public string FullName { get { return _FullName; } @@ -48,6 +75,7 @@ /// Instantiate from an IIdentity. /// </summary> /// <param name="id">Identity to copy for this profile.</param> + /// public AppUserProfile(IIdentity id) { Principal = new UserPrincipal(id); Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/AppCommand.cs Sat Oct 15 09:05:36 2005 @@ -20,13 +20,13 @@ namespace PhoneBook.Core.Commands { /// <summary> - /// Add data access methods to RequestCommand. + /// Extend RequestCommand with data access methods. /// </summary> /// - public abstract class AppCommand : RequestCommand + public abstract class BaseMapper : RequestCommand { /// <summary> - /// Provide a filed for Mapper property. + /// Provide a field for Mapper property. /// </summary> /// private SqlMapper _Mapper; @@ -37,7 +37,7 @@ /// <remarks><p> /// Commands use Mapper to invoke SqlMap statements, such as /// <code> - /// object row = Mapper ().QueryForObject (QueryID, context); + /// object row = Mapper.QueryForObject (QueryID, context); /// </code>. /// </p><p> /// Any SqlMapper API method may be called. Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseCount.cs Sat Oct 15 09:05:36 2005 @@ -5,7 +5,7 @@ /// <summary> /// Invoke a query that returns the count of a result set. /// </summary> - public class BaseCount: AppCommand + public class BaseCount: BaseMapper { public override bool RequestExecute(IRequestContext context) { Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs Sat Oct 15 09:05:36 2005 @@ -19,11 +19,12 @@ namespace PhoneBook.Core.Commands { /// <summary> - /// Execute database statement for QueryID for a single object, + /// Execute database statement indicated by QueryID + /// for a single object, /// returning each attribute in the main context. /// </summary> /// - public class BaseEntry : AppCommand + public class BaseEntry : BaseMapper { public override bool RequestExecute(IRequestContext context) { Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseFilterList.cs Sat Oct 15 09:05:36 2005 @@ -19,12 +19,12 @@ namespace PhoneBook.Core.Commands { /// <summary> - /// Execute database statement for QueryID + /// Execute database statement indicated by QueryID /// and wrap result in KeyValue objects /// so that lists can be displayed by standard methods. /// </summary> /// - public class BaseFilterList : AppCommand + public class BaseFilterList : BaseMapper { public override bool RequestExecute(IRequestContext context) { Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs Sat Oct 15 09:05:36 2005 @@ -1,5 +1,4 @@ -/* - * Copyright 2005 The Apache Software Foundation. +/* * Copyright 2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +18,12 @@ namespace PhoneBook.Core.Commands { /// <summary> - /// Execute database statement for QueryID, - /// convert list returned to an AppContextList, - /// and place converted list in context under ID. + /// Execute database statement indicated by QueryID, + /// for a list of objects + /// returning each attribute in the main context. /// </summary> /// - public class BaseList : AppCommand + public class BaseList : BaseMapper { public override bool RequestExecute(IRequestContext context) { Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseSave.cs Sat Oct 15 09:05:36 2005 @@ -3,37 +3,52 @@ namespace PhoneBook.Core.Commands { /// <summary> - /// Base Command for saving an Entity to the persistant store (database). + /// Store an entity for future reference. /// </summary> - public class BaseSave : AppCommand + /// + public class BaseSave : BaseMapper { + /// <summary> + /// Provide a field for KeyID property. + /// </summary> + /// private string _KeyID = null; /// <summary> - /// The name of the key field. + /// Record the unique identifier for the entity. /// </summary> + /// public string KeyID { get { return _KeyID; } set { _KeyID = value; } } + /// <summary> + /// Provide a field for InsertID property. + /// </summary> private string _InsertID = null; /// <summary> - /// The name of the "insert" mapping for the Entity. + /// Record the name of the "insert" mapping for the entity. /// </summary> + /// public string InsertID { get { return _InsertID; } set { _InsertID = value; } } + /// <summary> + /// Provide a field for UpdateID property. + /// </summary> + /// private string _UpdateID = null; /// <summary> - /// The name of the "update" mapping for the Entity. + /// Record the name of the "update" mapping for the entity. /// </summary> + /// public string UpdateID { get { return _UpdateID; } @@ -41,14 +56,18 @@ } /// <summary> + /// Insert or update an entity to the persistent store. + /// </summary> + /// <remark><p> /// If the "fieldID" is empty, use the insertID statement, /// otherwise, use the updateID statement. - /// </summary> + /// </p></remark> /// <param name="context">The INexusContext we are processing.</param> /// <param name="fieldID">The name of the key field.</param> /// <param name="insertID">The name of the "insert" mapping for the Entity.</param> /// <param name="updateID">The name of the "update" mapping for the Entity.</param> /// <returns>False</returns> + /// protected bool Save(IRequestContext context, string fieldID, string insertID, string updateID) { bool insert = IsEmpty(context[fieldID] as string); Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/BaseTest.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/BaseTest.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/BaseTest.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/BaseTest.cs Sat Oct 15 09:05:36 2005 @@ -21,7 +21,7 @@ namespace PhoneBook.Core { /// <summary> - /// Provide a base class so unit tests can share utility. + /// Provide base class so unit tests can share utility. /// </summary> /// [TestFixture] @@ -53,7 +53,8 @@ } /// <summary> - /// Demonstrate GUIDs and provide a device for generating GUIDs if needed. + /// Exercise GUID creation, + /// and provide a device for generating GUIDs if needed. /// </summary> /// [Test] Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/DirectoryViewTest.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/DirectoryViewTest.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/DirectoryViewTest.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/DirectoryViewTest.cs Sat Oct 15 09:05:36 2005 @@ -30,6 +30,7 @@ /// <summary> /// Confirm that Helper contains the expected command. /// </summary> + /// [Test] public void HelperContains() { Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs Sat Oct 15 09:05:36 2005 @@ -69,6 +69,12 @@ } } + /// <summary> + /// Excercise entry file and validate key value list. + /// </summary> + /// <param name="key">ID for list</param> + /// <returns>The validated list</returns> + /// private IKeyValueList FilterList(string key) { IViewHelper helper = catalog.GetHelperFor(App.ENTRY_FIND); @@ -78,6 +84,10 @@ return list; } + /// <summary> + /// Exercise Extension List filter. + /// </summary> + /// [Test] public void TestFilterFormat_extension() { @@ -89,6 +99,10 @@ } } + /// <summary> + /// Exercise Hired filter. + /// </summary> + /// [Test] public void TestFilterFormat_hired() { Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs Sat Oct 15 09:05:36 2005 @@ -59,6 +59,10 @@ SelectAll_Result(context); } + /// <summary> + /// Exercise Entry List and validate hired and extension string formatting. + /// </summary> + /// [Test] public void FilterHelper_Format() { @@ -79,6 +83,11 @@ Assert.IsTrue(extension.Length > "1234567890".Length, extension + ": Expected formatted extension."); } + /// <summary> + /// Exercise custom paging + /// (retrieve only visible section of the result se). + /// </summary> + /// [Test] public void SelectAll_Limit() { @@ -96,17 +105,8 @@ IList list2 = helper.Outcome; AppEntry entry2 = list2[0] as AppEntry; Assert.IsFalse(entry.entry_key.Equals(entry2.entry_key),"Expected result sets to be different"); - } - - [Test] - public void SelectAll_Count() - { - IViewHelper helper = catalog.GetHelperFor(App.ENTRY_LIST_COUNT); - helper.Execute(); - if (!helper.IsNominal) Assert.Fail(helper.ErrorsText); - IDictionary entry = helper.Criteria; - int count = Convert.ToInt32(entry[App.ITEM_COUNT]); - Assert.IsTrue(count==7); + int count = Convert.ToInt32(helper.Criteria[App.ITEM_COUNT]); + Assert.IsTrue(count>2,"Expected the overall count to be higher"); } } Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Forms/DirectoryTest.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Forms/DirectoryTest.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Forms/DirectoryTest.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Forms/DirectoryTest.cs Sat Oct 15 09:05:36 2005 @@ -24,21 +24,76 @@ /// <summary> /// Exercise the Directory page controls. /// </summary> + /// [TestFixture] public class DirectoryTest : WebFormTestCase { + /// <summary> + /// Provide finder instance for testing. + /// </summary> + /// private UserControlTester finder; + + /// <summary> + /// Provide last_name_list instance for testing. + /// </summary> + /// private DropDownListTester last_name_list; + + /// <summary> + /// Provide first_name_list instance for testing. + /// </summary> + /// private DropDownListTester first_name_list; + + /// <summary> + /// Provide extension_list instance for testing. + /// </summary> + /// private DropDownListTester extension_list; + + /// <summary> + /// Provide user_name_list instance for testing. + /// </summary> + /// private DropDownListTester user_name_list; + + /// <summary> + /// Provide finder instance for testing. + /// </summary> + /// private DropDownListTester hired_list; + + /// <summary> + /// Provide hours_list instance for testing. + /// </summary> + /// private DropDownListTester hours_list; + // TODO: private DropDownListTester editor_list; + + /// <summary> + /// Provide find instance for testing. + /// </summary> + /// private ButtonTester find; + /// <summary> + /// Provide finder lister for testing. + /// </summary> + /// private UserControlTester lister; + + /// <summary> + /// Provide list instance for testing. + /// </summary> + /// private DataGridTester list; + + /// <summary> + /// Provide add instance for testing. + /// </summary> + /// private ButtonTester add; /// <summary> Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/AppFields.xml Sat Oct 15 09:05:36 2005 @@ -5,14 +5,6 @@ <!-- FieldTable --> - <!-- Strict is not enabled, so we only need to list fields that are - (1) used by a GridViewHelper, - (2) need special formatting (via a Processor), - (3) represent a list with fields that need a Processor (fields listed because of (2))). - The default processing will apply .ToString() to any unregistered fields, - and pass through any unregistered lists verbatim - (which is cool if all the fields on the list are strings that don't need formatting). - --> <object id="FieldTable" type="Nexus.Core.Tables.FieldTable"> <property name="AddFieldContexts"> <list> @@ -68,6 +60,7 @@ <object id="editor" parent="BaseFieldContext"> <property name="ID"><value>editor</value></property> </object> + <!-- property name="ControlTypeName"><value>CheckBox</value></property --> <!-- We need to "hash" the name with "_" to avoid conflict with the filter Command --> Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder.ascx.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder.ascx.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder.ascx.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder.ascx.cs Sat Oct 15 09:05:36 2005 @@ -4,30 +4,93 @@ using Nexus.Web; using PhoneBook.Core; using PhoneBook.Web.Forms; +using WQD.Core.Controls; namespace PhoneBook.Web.Controls { + /// <summary> + /// Capture input values to filter a list of directory entries. + /// </summary> + /// public class Finder : ViewControl { + /// <summary> + /// Signal update to input filters + /// by passing FindArgs with the search critiers. + /// </summary> + /// + public event EventHandler Filter_Changed; + + /// <summary> + /// Populate the entry finder's own controls. + /// </summary> + /// + public void Open() + { + IViewHelper h = this.ExecuteBind(App.ENTRY_FIND); + bool ok = (h.IsNominal); + if (!ok) + Page_Error = h; + } + + /// <summary> + /// Provide runtime instance of last_name_list filter. + /// </summary> + /// protected DropDownList last_name_list; + + /// <summary> + /// Provide runtime instance of first_name_list filter. + /// </summary> + /// protected DropDownList first_name_list; + + /// <summary> + /// Provide runtime instance of extension_list filter. + /// </summary> + /// protected DropDownList extension_list; + + /// <summary> + /// Provide runtime instance of user_name_list filter. + /// </summary> + /// protected DropDownList user_name_list; + + /// <summary> + /// Provide runtime instance of hired_list filter. + /// </summary> + /// protected DropDownList hired_list; + + /// <summary> + /// Provide runtime instance of hours_list filter. + /// </summary> + /// protected DropDownList hours_list; - protected Button find; /// <summary> - /// Fires when search criteria is input. + /// Provide runtime instance of find filter. /// </summary> - public event EventHandler Click; + /// + protected Button find; + /// <summary> + /// Provide an array for filters so they can be handled as a group (or composite). + /// </summary> + /// <returns>Array of filter instances</returns> + /// private DropDownList[] FilterList() { DropDownList[] lists = {last_name_list, first_name_list, extension_list, user_name_list, hired_list, hours_list}; return lists; } + /// <summary> + /// Unselect all but the active filter. + /// </summary> + /// <param name="except">The active filter</param> + /// private void Filter_Reset(DropDownList except) { int exceptIndex = 0; @@ -39,7 +102,15 @@ if (except != null) except.SelectedIndex = exceptIndex; } - private void Filter_Changed(object sender, EventArgs e) + /// <summary> + /// Handle the SelectIndexChanged event for any of the filters + /// by capturing its settings + /// and raising the Filter_Changed event. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// + private void filter_SelectedIndexChanged(object sender, EventArgs e) { IViewHelper helper = Catalog.GetHelperFor(App.ENTRY_LIST); DropDownList list = sender as DropDownList; @@ -48,25 +119,32 @@ string key = id.Substring(0, v); helper.Criteria[key] = list.SelectedValue; Filter_Reset(list); - Click(this, new ViewArgs(helper)); - } - - public void Open() - { - IViewHelper h = this.ExecuteBind(App.ENTRY_FIND); - bool ok = (h.IsNominal); - if (!ok) - Page_Error = h; + Filter_Changed(this, new FindArgs(e,helper.Criteria)); } + /// <summary> + /// Handle the Click event of the Find button + /// by resetting the filters + /// and raising the Filter Changed event + /// so that the presentation will list all entries. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void find_Click(object sender, EventArgs e) { - if (Click == null) return; + if (Filter_Changed == null) return; Filter_Reset(null); IViewHelper helper = Read(App.ENTRY_FIND); - Click(this, new ViewArgs(helper)); + Filter_Changed(this, new ViewArgs(helper)); } + /// <summary> + /// Handle page's load event. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void Page_Load(object sender, EventArgs e) { find.Text = Directory.msg_LIST_ALL_CMD; @@ -75,7 +153,7 @@ foreach (DropDownList filter in FilterList()) { filter.AutoPostBack = true; - filter.SelectedIndexChanged += new EventHandler(Filter_Changed); + filter.SelectedIndexChanged += new EventHandler(filter_SelectedIndexChanged); } if (!IsPostBack) Open(); @@ -83,6 +161,12 @@ #region Web Form Designer generated code + + /// <summary> + /// Initialize components. + /// </summary> + /// <param name="e">Runtime parameters</param> + /// protected override void OnInit(EventArgs e) { // @@ -96,6 +180,7 @@ /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> + /// private void InitializeComponent() { this.Load += new EventHandler(this.Page_Load); Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder2.ascx.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder2.ascx.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder2.ascx.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Finder2.ascx.cs Sat Oct 15 09:05:36 2005 @@ -7,23 +7,60 @@ namespace PhoneBook.Web.Controls { + /// <summary> + /// Capture input values to filter a list of directory entries. + /// </summary> + /// public class Finder2 : ViewControl { - protected Button find; + /// <summary> + /// Signal update to input filters + /// by passing FindArgs with the search critiers. + /// </summary> + /// + public event EventHandler Filter_Changed; /// <summary> - /// Fires when search criteria is input. + /// Populate the entry finder's own controls. /// </summary> - public event EventHandler Click; + /// + public void Open() + { + IViewHelper h = GetHelperFor(App.ENTRY_FIND); + ExecuteBind(h); + bool ok = (h.IsNominal); + if (!ok) + Page_Error = h; + } + + /// <summary> + /// Provide runtime instance of find Button. + /// </summary> + /// + protected Button find; + /// <summary> + /// Handle the Click event of the Find button + /// by resetting the filters + /// and raising the Filter Changed event + /// so that the presentation will list all entries. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void find_Click(object sender, EventArgs e) { - if (Click == null) return; + if (Filter_Changed == null) return; Filter_Reset(null); IViewHelper helper = Read(App.ENTRY_FIND); - Click(this, new ViewArgs(helper)); + Filter_Changed(this, new ViewArgs(helper)); } + /// <summary> + /// Unselect all but the active filter. + /// </summary> + /// <param name="except">The active filter</param> + /// private void Filter_Reset(DropDownList except) { // Reset filter controls @@ -40,7 +77,15 @@ if (except != null) except.SelectedIndex = exceptIndex; } - private void Filter_Changed(object sender, EventArgs e) + /// <summary> + /// Handle the SelectIndexChanged event for any of the filters + /// by capturing its settings + /// and raising the Filter_Changed event. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// + private void filter_SelectedIndexChanged(object sender, EventArgs e) { IViewHelper helper = Catalog.GetHelperFor(App.ENTRY_LIST); DropDownList list = sender as DropDownList; @@ -49,29 +94,19 @@ string key = id.Substring(0, v); helper.Criteria[key] = list.SelectedValue; Filter_Reset(list); - Click(this, new ViewArgs(helper)); - } - - public void Open() - { - IViewHelper h = GetHelperFor(App.ENTRY_FIND); - ExecuteBind(h); - bool ok = (h.IsNominal); - if (!ok) - Page_Error = h; + Filter_Changed(this, new ViewArgs(helper)); } private void Page_Load(object sender, EventArgs e) { find.Click += new EventHandler(find_Click); - foreach (Control c in Controls) + foreach (Control control in Controls) { - if (IsListControl(c)) + if (IsListControl(control)) { - DropDownList x = (DropDownList) c; - x.SelectedIndexChanged += new EventHandler(Filter_Changed); - ; - x.AutoPostBack = true; + DropDownList filter = (DropDownList) control; + filter.SelectedIndexChanged += new EventHandler(filter_SelectedIndexChanged); + filter.AutoPostBack = true; } } Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister.ascx.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister.ascx.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister.ascx.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister.ascx.cs Sat Oct 15 09:05:36 2005 @@ -7,10 +7,18 @@ namespace PhoneBook.Web.Controls { + + /// <summary> + /// Present matching directory entries. + /// </summary> + /// public class Lister : ViewControl { - protected DataGrid list; - + /// <summary> + /// Populate the DataGrid with directory entries matching the filter settings. + /// </summary> + /// <param name="criteria">Filter settings</param> + /// public void Open(IDictionary criteria) { IViewHelper helper = ReadExecute(App.ENTRY_LIST, criteria); @@ -24,6 +32,18 @@ } } + /// <summary> + /// Provide reference to datagrid instance. + /// </summary> + /// + protected DataGrid list; + + /// <summary> + /// Handle page's load event. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; @@ -32,6 +52,11 @@ #region Web Form Designer generated code + /// <summary> + /// Initialize components. + /// </summary> + /// <param name="e">Runtime parameters</param> + /// protected override void OnInit(EventArgs e) { // @@ -45,6 +70,7 @@ /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> + /// private void InitializeComponent() { this.Load += new EventHandler(this.Page_Load); Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Controls/Lister2.ascx.cs Sat Oct 15 09:05:36 2005 @@ -6,19 +6,47 @@ namespace PhoneBook.Web.Controls { + /// <summary> + /// Present matching directory entries. + /// </summary> public class Lister2 : AppGridControl { + + /// <summary> + /// Provide instance of DataGrid control + /// </summary> + /// protected DataGrid list; + + /// <summary> + /// Provide instance of Add button. + /// </summary> + /// protected Button add; + /// <summary> + /// ID Token to indicate a Label control. + /// </summary> + /// private static string LABEL = "_label"; + /// <summary> + /// Complete loading Grid + /// after other members have initialized. + /// </summary> + /// private void Grid_Load() { AppUserProfile profile = Session[UserProfile.USER_PROFILE] as AppUserProfile; HasEditColumn = profile.IsEditor; } + /// <summary> + /// Initialize our Grid instance + /// by setting the columns, labels, + /// and other dynamic attributes. + /// </summary> + /// private void Grid_Init() { FindCommand = App.ENTRY_FIND; @@ -48,12 +76,23 @@ DataLabels = k; } + /// <summary> + /// Handle Page Init event by obtaining the user profile + /// and initalizing the controls. + /// </summary> + /// private void Page_Init() { Grid = list; Grid_Init(); } + /// <summary> + /// Handle page's load event. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void Page_Load(object sender, EventArgs e) { add.Click += new EventHandler(add_Click); @@ -63,6 +102,11 @@ #region Web Form Designer generated code + /// <summary> + /// Initialize components. + /// </summary> + /// <param name="e">Runtime parameters</param> + /// protected override void OnInit(EventArgs e) { // Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs Sat Oct 15 09:05:36 2005 @@ -11,11 +11,20 @@ /// <summary> /// Display a list of employees with their telephone extension [OVR-5]. /// </summary> + /// <remarks><p> + /// This is a starter version of the Directory page + /// that presents the list + /// without offering more advanced features. + /// </p></remarks> /// public class Directory : Page { #region Messages + /// <summary> + /// Provide a message for the List All command. + /// </summary> + /// public const string msg_LIST_ALL_CMD = "SHOW ALL"; #endregion @@ -37,10 +46,13 @@ } } + /// <summary> + /// Provide filed for Catalog property. + /// </summary> private IRequestCatalog _Catalog; /// <summary> - /// Provide reference ot the Catalog (object factory) for this application. + /// Provide reference to the Catalog (object factory) for this application. /// </summary> /// <remarks><p> /// Subclasses adding EventHandlers @@ -57,10 +69,27 @@ #region Event handlers + /// <summary> + /// Present matching directory entries. + /// </summary> + /// protected Lister lister; + + /// <summary> + /// Capture input values to filter a list of directory entries. + /// </summary> + /// protected Finder finder; - protected void finder_Click(object sender, EventArgs e) + /// <summary> + /// Handle Filter Changed event by opening the Lister control + /// and passing through the search criteria + /// provided by the event arts. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime arguements</param> + /// + protected void finder_FilterChanged(object sender, EventArgs e) { ViewArgs a = e as ViewArgs; IViewHelper helper = a.Helper; @@ -71,6 +100,13 @@ #region Page Events + /// <summary> + /// Handle View_Error event by presenting the error message + /// provided by the Helper class. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void View_Error(object sender, EventArgs e) { ViewArgs v = e as ViewArgs; @@ -80,18 +116,34 @@ else throw new ArgumentException("View_Error: (e.helper==null)"); } + /// <summary> + /// Initialize controls by registering for View Error events + /// and passing through our Catalog instance. + /// </summary> + /// <param name="c">Control to initialize</param> + /// private void View_Init(ViewControl c) { c.View_Error += new EventHandler(View_Error); c.Catalog = this.Catalog; // ISSUE: Why isn't control injection working? } + /// <summary> + /// Handle Page Init event by initalizing the controls. + /// </summary> + /// private void Page_Init() { View_Init(finder); View_Init(lister); } + /// <summary> + /// Handle page's load event. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void Page_Load(object sender, EventArgs e) { error_panel.Visible = false; @@ -101,6 +153,11 @@ #region Web Form Designer generated code + /// <summary> + /// Initialize components. + /// </summary> + /// <param name="e">Runtime parameters</param> + /// protected override void OnInit(EventArgs e) { // @@ -115,6 +172,7 @@ /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> + /// private void InitializeComponent() { this.Load += new EventHandler(this.Page_Load); Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs?rev=321362&r1=321361&r2=321362&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs Sat Oct 15 09:05:36 2005 @@ -15,16 +15,25 @@ /// <summary> /// Maintain a list of employees with their telephone extension [OVR-5]. /// </summary> + /// <remarks><p> + /// This version of the directory page supports paging and editing + /// through use of the Nexus GridControl. + /// </p></remarks> /// public class Directory2 : Page { #region Base Page members + /// <summary> + /// Provide field for AppUserProfile property. + /// </summary> + /// private AppUserProfile _Profile; /// <summary> - /// Obtain a profile for a user. + /// Expose the user's profile. /// </summary> + /// protected AppUserProfile Profile { set @@ -43,6 +52,7 @@ /// based on the client's WindowsIdentity. /// </summary> /// <returns>A new or prexisting AppUserProfile</returns> + /// protected AppUserProfile NewProfile() { WindowsIdentity id = WindowsIdentity.GetCurrent(); @@ -69,8 +79,9 @@ } /// <summary> - /// Display a list of error messagess. + /// Present a list of error messages. /// </summary> + /// protected IViewHelper Page_Error { set @@ -86,27 +97,38 @@ /// <summary> /// Display a Prompt message. /// </summary> + /// protected string Page_Prompt { set { prompt_label.Text = value; } } + /// <summary> + /// Provide a field for Catalog property. + /// </summary> + /// private IRequestCatalog _Catalog; /// <summary> - /// Provide reference ot the Catalog (object factory) for this application. + /// Expose the Catalog (object factory) for this application. /// </summary> /// <remarks><p> /// Subclasses adding EventHandlers /// should pass a reference to themselves with a ViewArgs instance, /// encapsulating the Helper. /// </p></remarks> + /// public virtual IRequestCatalog Catalog { get { return _Catalog; } set { _Catalog = value; } } + /// <summary> + /// Handle View Error + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> private void View_Error(object sender, EventArgs e) { ViewArgs v = e as ViewArgs; @@ -116,6 +138,12 @@ else throw new ArgumentException("View_Error: (e.helper==null)"); } + /// <summary> + /// Initialize User Controls by handling View Error events + /// and passing through our Catalog reference. + /// </summary> + /// <param name="c">Control to initialize</param> + /// private void View_Init(ViewControl c) { c.View_Error += new EventHandler(View_Error); @@ -131,22 +159,23 @@ #endregion - #region Page Properties - - protected HtmlGenericControl title; - protected HtmlGenericControl heading; - protected Label greeting; - protected Label profile_label; - protected Panel error_panel; - protected Label error_label; - - #endregion - #region Event handlers protected Lister2 lister; + + /// <summary> + /// Capture input values to filter a list of directory entries. + /// </summary> protected Finder2 finder; + /// <summary> + /// Handle Filter Changed event by opening the Lister control + /// and passing through the search criteria + /// provided by the event arts. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime arguements</param> + /// protected void finder_Click(object sender, EventArgs e) { ViewArgs a = e as ViewArgs; @@ -156,8 +185,24 @@ #endregion + #region Page Properties + + protected HtmlGenericControl title; + protected HtmlGenericControl heading; + protected Label greeting; + protected Label profile_label; + protected Panel error_panel; + protected Label error_label; + + #endregion + #region Page Events + /// <summary> + /// Handle Page Init event by obtaining the user profile + /// and initalizing the controls. + /// </summary> + /// private void Page_Init() { Profile = Session[UserProfile.USER_PROFILE] as AppUserProfile; @@ -165,9 +210,15 @@ View_Init(finder); View_Init(lister); - finder.Click += new EventHandler(finder_Click); + finder.Filter_Changed += new EventHandler(finder_Click); } + /// <summary> + /// Handle page's load event. + /// </summary> + /// <param name="sender">Event source</param> + /// <param name="e">Runtime parameters</param> + /// private void Page_Load(object sender, EventArgs e) { error_panel.Visible = false; @@ -188,6 +239,11 @@ #region Web Form Designer generated code + /// <summary> + /// Initialize components. + /// </summary> + /// <param name="e">Runtime parameters</param> + /// protected override void OnInit(EventArgs e) { // @@ -202,6 +258,7 @@ /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> + /// private void InitializeComponent() { this.Load += new EventHandler(this.Page_Load); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]