Author: husted Date: Wed Jun 22 17:04:58 2005 New Revision: 193029 URL: http://svn.apache.org/viewcvs?rev=193029&view=rev Log: OVR-5 * Add a custom AppProcessor to transform a IDictionary to a AppContextList with strings formatted for display.
Added: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContextList.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj 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/Resources/Command/AppBase.xml struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/Catalog.xml struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/SelectAll.xml struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs Wed Jun 22 17:04:58 2005 @@ -73,7 +73,7 @@ /// Token for select all command. /// </summary> /// - public const string SELECT_ALL = "select_all"; + public const string FILTER = "filter"; /// <summary> /// Token for List Last Names command. Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs Wed Jun 22 17:04:58 2005 @@ -2,7 +2,7 @@ * 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. + * you may not use _Store file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 @@ -18,12 +18,10 @@ namespace PhoneBook.Core { /// <summary> - /// Adapt an IDictionary to a properties class - /// so that there is a public property for every UI attribute - /// exposed by the application. + /// Adapt a properties class to use an IDictionary for storage. /// </summary> /// - public class AppContext : Hashtable + public class AppContext { #region Constructors @@ -32,110 +30,68 @@ /// </summary> public AppContext () { + _Value = new Hashtable (); } /// <summary> /// Instantiate from a IDictionary. /// </summary> - /// <param name="dictionary">Values for new object</param> + /// <param name="dictionary">New values for properties</param> public AppContext (IDictionary dictionary) { - IEnumerator keys = dictionary.Keys.GetEnumerator (); - while (keys.MoveNext ()) - { - string key = keys.Current as string; - this.Add (key, dictionary [key].ToString ()); - } + _Value = dictionary; } - /* - /// <summary> - /// Instantiate from an IDictionary, - /// formatting each entry using the FieldTable from a INexusContext, - /// and reporting any conversion or formatting errors in the INexusContext. - /// </summary> - /// <remarks><p> - /// The result of a query will come back as a list of IDictionaries, - /// using native, unformatted data types. - /// This constructor can be used to loop through a list of IDictionaires, - /// create a AppContext for each entry, and formatting any values - /// along the way. (Dates being the best example.) - /// The result is a AppContextList that can be used as a DataGrid - /// DataSource (or whatever). - /// </p></remarks> - /// <param name="dictionary">Values for new object</param> - /// <param name="context">Context with FieldTable and error handler</param> - public AppContext (IDictionary dictionary, IRequestContext context) - { - #region Assert parameters - - if (null == dictionary) throw new ArgumentNullException ("dictionary", "AppContext(IDictionary,INexusContext"); - if (null == context) throw new ArgumentNullException ("context", "AppContext(IDictionary,INexusContext"); - IFieldTable table = context.FieldTable; - if (null == table) throw new ArgumentNullException ("FieldTable", "AppContext(IDictionary,INexusContext"); - - #endregion - - IEnumerator keys = dictionary.Keys.GetEnumerator (); - while (keys.MoveNext ()) - { - string key = keys.Current as string; - IValidatorContext input = new ValidatorContext (); // ISSUE: Spring? [WNE-63] - input.FieldKey = key; - input.Source = dictionary [key]; - bool okay = table.Format (input); - if (!okay) - // OR, do we just want to push convert/format(id) up? - context.AddAlertForField (key); - this.Add (key, input.Target); - } - } - */ - #endregion + private IDictionary _Value; + public IDictionary Value + { + get { return _Value; } + } + /* public string property { - get { return this[App.PROPERTY] as string; } - set { this[App.PROPERTY] = value; } + get { return _Store[App.PROPERTY] as string; } + set { _Store[App.PROPERTY] = value; } } */ public string first_name { - get { return this [App.FIRST_NAME] as string; } - set { this [App.FIRST_NAME] = value; } + get { return _Value [App.FIRST_NAME] as string; } + set { _Value [App.FIRST_NAME] = value; } } public string last_name { - get { return this [App.LAST_NAME] as string; } - set { this [App.LAST_NAME] = value; } + get { return _Value [App.LAST_NAME] as string; } + set { _Value [App.LAST_NAME] = value; } } public string extension { - get { return this [App.EXTENSION] as string; } - set { this [App.EXTENSION] = value; } + get { return _Value [App.EXTENSION] as string; } + set { _Value [App.EXTENSION] = value; } } public string user_name { - get { return this [App.USER_NAME] as string; } - set { this [App.USER_NAME] = value; } + get { return _Value [App.USER_NAME] as string; } + set { _Value [App.USER_NAME] = value; } } public string hired { - get { return this [App.HIRED] as string; } - set { this [App.HIRED] = value; } + get { return _Value [App.HIRED] as string; } + set { _Value [App.HIRED] = value; } } public string hours { - get { return this [App.HOURS] as string; } - set { this [App.HOURS] = value; } + get { return _Value [App.HOURS] as string; } + set { _Value [App.HOURS] = value; } } } Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContextList.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContextList.cs?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContextList.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContextList.cs Wed Jun 22 17:04:58 2005 @@ -1,16 +1,15 @@ using System.Collections; -using Nexus.Core; namespace PhoneBook.Core { /// <summary> - /// A list of AppContext objects. + /// List AppContext objects. /// </summary> /// public class AppContextList : ArrayList { /// <summary> - /// Instantiate with zero parameters. + /// Create instance with zero parameters. /// </summary> /// public AppContextList () @@ -18,7 +17,7 @@ } /// <summary> - /// Create a AppContext object for each IDictionary on a IList. + /// Create an AppContext object for each IDictionary on a IList. /// </summary> /// <param name="dictionaries">A IList of IDictionaries with data values.</param> /// @@ -31,17 +30,13 @@ } /// <summary> - /// Create a AppContext object for each IDictionary on a IList, - /// using a FieldTable to format each entry. + /// Wrap an IDictionary in an AppContext object and add it to the list. /// </summary> - /// <param name="dictionaries">A IList of IDictionaries with data values.</param> - /// - public AppContextList (IList dictionaries, IRequestContext context) + /// <param name="value">IDictionary to add as new entry</param> + public void AddEntry (IDictionary value) { - foreach (IDictionary item in dictionaries) - { - // TODO: Add (new AppContext (item, context)); - } + AppContext entry = new AppContext (value); + Add (entry); } } Added: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs?rev=193029&view=auto ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs (added) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppProcessor.cs Wed Jun 22 17:04:58 2005 @@ -0,0 +1,41 @@ +using System.Collections; +using Agility.Nexus.Validators; +using Nexus.Core; +using Nexus.Core.Validators; + +namespace PhoneBook.Core +{ + /// <summary> + /// Transform IDictionary entries into formatted AppContext properties. + /// </summary> + public class AppProcessor : Processor + { + + public override bool ConvertInput (IProcessorContext incoming) + { + incoming.Target = incoming.Source; + return true; + } + + public override bool FormatOutput (IProcessorContext outgoing) + { + ProcessorCommand formatter = new FormatOutput (); + IList source = outgoing.Source as IList; + AppContextList target = new AppContextList (); + foreach (IDictionary row in source) + { + IRequestContext context = new RequestContext (row); + context.FieldTable = outgoing.FieldTable; + ICollection keys = row.Keys; + foreach (string key in keys) + { + IProcessorContext _context = new ProcessorContext (key, context); + formatter.ExecuteProcess (_context); + } + target.AddEntry (context.Criteria); + } + outgoing.Target = target; + return true; + } + } +} \ No newline at end of file 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=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseList.cs Wed Jun 22 17:04:58 2005 @@ -29,8 +29,7 @@ public override bool RequestExecute (IRequestContext context) { IList rows = Mapper ().QueryForList (QueryID, context); - AppContextList list = new AppContextList (rows); - context [ID] = list; + context [ID] = rows; return CONTINUE; } } Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj Wed Jun 22 17:04:58 2005 @@ -114,7 +114,17 @@ BuildAction = "Compile" /> <File + RelPath = "AppProcessor.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "AssemblyInfo.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TelephoneProcessor.cs" SubType = "Code" BuildAction = "Compile" /> 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=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/DirectoryViewTest.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/DirectoryViewTest.cs Wed Jun 22 17:04:58 2005 @@ -19,10 +19,10 @@ public void ContainsFilters () { IRequestContext context = catalog.ExecuteRequest (App.DIRECTORY_VIEW); - string[] keys = {App.LAST_NAME_LIST, App.FIRST_NAME_LIST, App.EXTENSION_LIST, App.USER_NAME_LIST, App.HIRED_LIST, App.HOURS_LIST}; - foreach (string key in keys) + string[] FILTERS = {App.LAST_NAME_LIST, App.FIRST_NAME_LIST, App.EXTENSION_LIST, App.USER_NAME_LIST, App.HIRED_LIST, App.HOURS_LIST}; + foreach (string filter in FILTERS) { - Assert.IsTrue (context.Contains (key), key + ": Expected context to contain key."); + Assert.IsTrue (context.Contains (filter), filter + ": Expected context to contain key."); } } 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=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/FilterLists.cs Wed Jun 22 17:04:58 2005 @@ -53,14 +53,18 @@ } /// <summary> - /// Exercise the List Last Name command. + /// Exercise the filter commands. /// </summary> /// [Test] - public void TestLastNameFilterList () + public void TestFilterLists () { - IRequestContext context = catalog.ExecuteRequest (App.LAST_NAME_LIST); - FilterList_Result (context); + string[] FILTERS = {App.LAST_NAME_LIST, App.FIRST_NAME_LIST, App.EXTENSION_LIST, App.USER_NAME_LIST, App.HIRED_LIST, App.HOURS_LIST}; + foreach (string filter in FILTERS) + { + IRequestContext context = catalog.ExecuteRequest (filter); + FilterList_Result (context); + } } } 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=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs Wed Jun 22 17:04:58 2005 @@ -15,6 +15,7 @@ */ using System.Collections; using Nexus.Core; +using Nexus.Core.Helpers; using NUnit.Framework; namespace PhoneBook.Core.Commands @@ -35,6 +36,7 @@ { IList list = AssertListOutcome (context); IDictionary row = list [0] as IDictionary; + Assert.IsNotNull (row, "Expected list entry to be an IDictionary."); string[] KEYS = {App.FIRST_NAME, App.LAST_NAME, App.USER_NAME, App.EXTENSION, App.HIRED, App.HOURS, App.EDITOR}; bool valid = true; foreach (string key in KEYS) @@ -44,44 +46,36 @@ Assert.IsTrue (valid, "Expected row to contain all keys."); } - /// <summary> - /// SelectAll and succeed, without using Catalog. - /// </summary> - /// - [Test] - public void SelectAll_Pass_Without_Catalog () - { - BaseList command = new BaseList (); - command.ID = App.SELECT_ALL; - IRequestContext context = command.NewContext (); - command.Execute (context); - SelectAll_Result (context); - } /// <summary> - /// SelectAll and succeed, using catalog. + /// Filter all and succeed, using catalog. /// </summary> /// [Test] public void SelectAll_Pass () { - IRequestContext context = catalog.ExecuteRequest (App.SELECT_ALL); + IRequestContext context = catalog.ExecuteRequest (App.FILTER); SelectAll_Result (context); } [Test] - public void SelectAll_Format() + public void FilterHelper_Format () { - IRequestContext context = catalog.ExecuteRequest (App.SELECT_ALL); - IList list = context.Outcome as IList; + IViewHelper helper = catalog.GetHelper ("directory_find_helper"); + helper.Execute (); + AppContextList list = helper.Outcome as AppContextList; + // AppContextList list = helper.Context.Criteria["filter"] as AppContextList; + Assert.IsNotNull (list, "Expected list to be AppContextList"); AppContext row = list [0] as AppContext; - Assert.IsNotNull (row,"Expected rows to be AppContexts"); + Assert.IsNotNull (row, "Expected rows to be AppContexts"); string hired = row.hired; - Assert.IsTrue (hired.Length<"##/##/#### ".Length,hired + ": Expected short date format."); + Assert.IsNotNull (hired, "Expected each row to have a hired date."); + Assert.IsTrue (hired.Length < "##/##/#### ".Length, hired + ": Expected short date format."); string extension = row.extension; - Assert.IsTrue (extension.Length>"1234567890".Length, extension + ": Expected formatted extension."); + Assert.IsNotNull (extension, "Expected each row to have an extension."); + Assert.IsTrue (extension.Length > "1234567890".Length, extension + ": Expected formatted extension."); } } Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppBase.xml Wed Jun 22 17:04:58 2005 @@ -7,7 +7,8 @@ <object id="BaseFilterList" type="PhoneBook.Core.Commands.BaseFilterList, PhoneBook.Core"/> - <object id="BaseHelper" type="PhoneBook.Web.AppHelper, PhoneBook.Web"> + <!-- All child helpers must also specify singleton=false; otherwise, Context is shared. --> + <object id="BaseHelper" type="PhoneBook.Web.AppHelper, PhoneBook.Web" singleton="false"> <property name="Catalog"> <ref object="Catalog" /> </property> Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/AppConfig.xml Wed Jun 22 17:04:58 2005 @@ -3,42 +3,61 @@ "http://www.springframework.net/dtd/spring-objects.dtd"> <objects> - <!-- Catalog --> - - <object id="Catalog" type="Nexus.Extras.Spring.Catalog"/> - - <!-- FieldTable --> <object id="FieldTable" type="Nexus.Core.Tables.FieldTable"> - <property name="AddFields"> + <property name="AddFieldContexts"> <list> <ref object="hired"/> + <ref object="_filter"/> + </list> + </property> + <property name="AddProcessors"> + <list> + <ref object="DateTimeProcessor"/> + <ref object="AppProcessor"/> </list> </property> </object> - <!-- "d" is .NET for "short date" --> <object id="hired" type="Nexus.Core.Tables.FieldContext"> <property name="ID"><value>hired</value></property> <property name="Alert"><value>{0} must be a valid date</value></property> - <property name="DataFormat"><value>d</value></property> - <property name="DataTypeName"><value>System.DateTime</value></property> + <property name="ProcessorID"><value>DateTimeProcessor</value></property> + </object> + + <object id="_filter" type="Nexus.Core.Tables.FieldContext"> + <property name="ID"><value>filter</value></property> + <property name="ProcessorID"><value>AppProcessor</value></property> </object> -<!-- Validators --> + <!-- "d" is .NET for "short date" --> + <object id="DateTimeProcessor" type="Nexus.Core.Validators.DateTimeProcessor"> + <property name="ID"><value>DateTimeProcessor</value></property> + <property name="DataFormat"><value>d</value></property> + </object> + + <object id="AppProcessor" type="PhoneBook.Core.AppProcessor"> + <property name="ID"><value>AppProcessor</value></property> + </object> + + <!-- Catalog --> + + <object id="Catalog" type="Nexus.Extras.Spring.Catalog"/> + + +<!-- Request Processors --> <object id="convert_input" type="Nexus.Core.Validators.ConvertInput"> <property name="ID"><value>ConvertInput</value></property> - <property name="Template"><value>{0} is required.</value></property> + <property name="Required"><value>{0} is required.</value></property> </object> <object id="format_output" type="Nexus.Core.Validators.FormatOutput"> <property name="ID"><value>FormatOutput</value></property> - <property name="Template"><value>{0} is required.</value></property> + <property name="Required"><value>{0} is required.</value></property> </object> - <!-- pre-op --> <object id="pre-op" parent="BaseChain"> @@ -60,4 +79,5 @@ </property> </object> + </objects> Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/Catalog.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/Catalog.xml?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/Catalog.xml (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Command/Catalog.xml Wed Jun 22 17:04:58 2005 @@ -3,12 +3,19 @@ "http://www.springframework.net/dtd/spring-objects.dtd"> <objects> - <!-- basic commands --> - - <object id="select_all" type="PhoneBook.Core.Commands.BaseList, PhoneBook.Core"> - <property name="ID"><value>select_all</value></property> - </object> + <!-- filter command --> + <object id="filter" type="PhoneBook.Core.Commands.BaseList, PhoneBook.Core"> + <property name="RelatedIDs"> + <list> + <value>filter</value> + </list> + </property> + <property name="ID"><value>filter</value></property> + </object> + + <!-- filter list commands --> + <object id="last_name_list" parent="BaseFilterList"> <property name="ID"><value>last_name_list</value></property> </object> @@ -65,15 +72,15 @@ <!-- helpers --> - <object id="directory_view_helper" parent="BaseHelper"> + <object id="directory_view_helper" parent="BaseHelper" singleton="false"> <property name="Command"> <ref object="directory_view" /> </property> </object> - <object id="list_all_helper" parent="BaseHelper"> + <object id="directory_find_helper" parent="BaseHelper" singleton="false"> <property name="Command"> - <ref object="select_all" /> + <ref object="filter" /> </property> </object> Modified: struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/SelectAll.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/SelectAll.xml?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/SelectAll.xml (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Resources/Query/SelectAll.xml Wed Jun 22 17:04:58 2005 @@ -6,18 +6,40 @@ xsi:noNamespaceSchemaLocation="SqlMap.xsd" > <statements> - <select id="select_all" resultClass="Hashtable"> + <select id="filter" paramClass="Hashtable" resultClass="Hashtable"> SELECT pk_entry, last_name, first_name, extension, user_name, - editor, hired, - hours + hours, + editor FROM entry + <dynamic prepend="WHERE"> + <isNotNull property="last_name" prepend="AND"> + last_name=#last_name# + </isNotNull> + <isNotNull property="first_name" prepend="AND"> + first_name=#first_name# + </isNotNull> + <isNotNull property="extension" prepend="AND"> + extension=#extension# + </isNotNull> + <isNotNull property="user_name" prepend="AND"> + user_name=#user_name# + </isNotNull> + <isNotNull property="hired" prepend="AND"> + hired=#hired# + </isNotNull> + <isNotNull property="hours" prepend="AND"> + hours=#hours# + </isNotNull> + </dynamic> </select> + </statements> + </sqlMap> 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=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory.aspx.cs Wed Jun 22 17:04:58 2005 @@ -85,27 +85,27 @@ private void Find_Init () { cmdListAll.Text = msg_LIST_ALL_CMD; - cmdListAll.Click += new EventHandler(ListAll_Click); + cmdListAll.Click += new EventHandler (ListAll_Click); cmdPrint.Text = msg_PRINT_CMD; - cmdPrint.Click +=new EventHandler(Print_Click); + cmdPrint.Click += new EventHandler (Print_Click); foreach (DropDownList filter in FilterList ()) { filter.AutoPostBack = true; - filter.SelectedIndexChanged += new EventHandler(Filter_Changed); + filter.SelectedIndexChanged += new EventHandler (Filter_Changed); } } - private void Filter_Reset(DropDownList except) + private void Filter_Reset (DropDownList except) { int exceptIndex = 0; - if (except!= null ) exceptIndex = except.SelectedIndex; + if (except != null) exceptIndex = except.SelectedIndex; foreach (DropDownList filter in FilterList ()) { filter.SelectedIndex = 0; } - if (except!=null) except.SelectedIndex = exceptIndex; + if (except != null) except.SelectedIndex = exceptIndex; } private void Filter_Changed (object sender, EventArgs e) @@ -114,9 +114,9 @@ string id = list.ID; int v = id.LastIndexOf (FindHelper.ListSuffix); string key = id.Substring (0, v); - FindHelper.Context[key] = list.SelectedValue; - Filter_Reset(list); - List_Load(FindHelper); + FindHelper.Context [key] = list.SelectedValue; + Filter_Reset (list); + List_Load (FindHelper); } private void Find_Load () @@ -124,7 +124,7 @@ IViewHelper h = ViewHelper; h.ExecuteBind (pnlFind.Controls); bool ok = (h.IsNominal); - if (!ok) + if (!ok) Page_Error = h; } @@ -132,8 +132,8 @@ private void ListAll_Click (object sender, EventArgs e) { - Filter_Reset(null); - List_Load(FindHelper); + Filter_Reset (null); + List_Load (FindHelper); } private void Print_Click (object sender, EventArgs e) @@ -141,7 +141,6 @@ throw new NotImplementedException (); } - #endregion #region List @@ -160,7 +159,7 @@ private void List_Load (IViewHelper helper) { - helper.Execute(); + helper.Execute (); bool ok = helper.IsNominal; if (!ok) Page_Error = helper; else @@ -215,6 +214,5 @@ } #endregion - } } Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml?rev=193029&r1=193028&r2=193029&view=diff ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml (original) +++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml Wed Jun 22 17:04:58 2005 @@ -3,42 +3,61 @@ "http://www.springframework.net/dtd/spring-objects.dtd"> <objects> - <!-- Catalog --> - - <object id="Catalog" type="Nexus.Extras.Spring.Catalog"/> - - <!-- FieldTable --> <object id="FieldTable" type="Nexus.Core.Tables.FieldTable"> - <property name="AddFields"> + <property name="AddFieldContexts"> <list> <ref object="hired"/> + <ref object="_filter"/> + </list> + </property> + <property name="AddProcessors"> + <list> + <ref object="DateTimeProcessor"/> + <ref object="AppProcessor"/> </list> </property> </object> - <!-- "d" is .NET for "short date" --> <object id="hired" type="Nexus.Core.Tables.FieldContext"> <property name="ID"><value>hired</value></property> <property name="Alert"><value>{0} must be a valid date</value></property> - <property name="DataFormat"><value>d</value></property> - <property name="DataTypeName"><value>System.DateTime</value></property> + <property name="ProcessorID"><value>DateTimeProcessor</value></property> + </object> + + <object id="_filter" type="Nexus.Core.Tables.FieldContext"> + <property name="ID"><value>filter</value></property> + <property name="ProcessorID"><value>AppProcessor</value></property> </object> -<!-- Validators --> + <!-- "d" is .NET for "short date" --> + <object id="DateTimeProcessor" type="Nexus.Core.Validators.DateTimeProcessor"> + <property name="ID"><value>DateTimeProcessor</value></property> + <property name="DataFormat"><value>d</value></property> + </object> + + <object id="AppProcessor" type="PhoneBook.Core.AppProcessor"> + <property name="ID"><value>AppProcessor</value></property> + </object> + + <!-- Catalog --> + + <object id="Catalog" type="Nexus.Extras.Spring.Catalog"/> + + +<!-- Request Processors --> <object id="convert_input" type="Nexus.Core.Validators.ConvertInput"> <property name="ID"><value>ConvertInput</value></property> - <property name="Template"><value>{0} is required.</value></property> + <property name="Required"><value>{0} is required.</value></property> </object> <object id="format_output" type="Nexus.Core.Validators.FormatOutput"> <property name="ID"><value>FormatOutput</value></property> - <property name="Template"><value>{0} is required.</value></property> + <property name="Required"><value>{0} is required.</value></property> </object> - <!-- pre-op --> <object id="pre-op" parent="BaseChain"> @@ -60,4 +79,5 @@ </property> </object> + </objects> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]