Author: husted Date: Fri Jan 5 17:03:09 2007 New Revision: 493264 URL: http://svn.apache.org/viewvc?view=rev&rev=493264 Log: PhoneBook2 - Add formatting test, conform AppEntry with latest Nexus, refine workflow.
Modified: struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.sln struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntry.cs struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Commands/BaseEntry.cs struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/TelephoneProcessor.cs struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Objects.xml struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.html Modified: struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.sln URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.sln?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.sln (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.sln Fri Jan 5 17:03:09 2007 @@ -27,6 +27,11 @@ VWDPort = "3594" EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F5B697F2-0FFC-4459-BCBB-5F6F4DB01D64}" + ProjectSection(SolutionItems) = preProject + ..\Nexus\Core\Validators\DateTimeProcessor.cs = ..\Nexus\Core\Validators\DateTimeProcessor.cs + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntry.cs URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntry.cs?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntry.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntry.cs Fri Jan 5 17:03:09 2007 @@ -15,6 +15,7 @@ */ using System; using System.Collections; +using Nexus.Core; namespace PhoneBook.Core { @@ -23,73 +24,41 @@ /// </summary> /// [Serializable] - public class AppEntry + public class AppEntry : EntryDictionary { - /// <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) + public AppEntry() { - ICollection keys = sources.Keys; - foreach (string key in keys) - { - Add(key, sources[key] as string); - } + // Default contstructor } - /// <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) + public AppEntry(IDictionary sources) { - _Value.Add(key, value); + AddAll(sources); } - /// <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) + public AppEntry(AppEntry row) { - return _Value[key] as string; + AddAll(row); } /// <summary> - /// Set an entry to the internal store, overwriting any existing entry. + /// Add each source entry to our internal store. /// </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. + /// 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"></param> - /// <param name="value"></param> - protected void Set(string key, string value) + /// <param name="row">Entries to add</param> + /// + public void AddAll(AppEntry row) { - _Value[key] = value; + ICollection keys = row.Keys; + foreach (string key in keys) + { + Add(key, row.Get(key)); + } } - /* public string Property Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs Fri Jan 5 17:03:09 2007 @@ -1,3 +1,4 @@ +using System; using System.Collections; using Nexus.Core; @@ -21,7 +22,11 @@ { AppEntry entry = new AppEntry(); foreach (DictionaryEntry col in row) - entry.Add(col.Key.ToString(), col.Value.ToString()); + { + string key = Convert.ToString(col.Key); + string value = Convert.ToString(col.Value); + entry.Add(key, value); + } Add(entry); } @@ -30,4 +35,4 @@ return (AppEntry[])ToArray(typeof(AppEntry)); } } -} \ No newline at end of file +} Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Commands/BaseEntry.cs URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Commands/BaseEntry.cs?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Commands/BaseEntry.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Commands/BaseEntry.cs Fri Jan 5 17:03:09 2007 @@ -29,13 +29,18 @@ public override bool RequestExecute(IRequestContext context) { object o = Mapper.QueryForObject(QueryID, context); - context[ID] = o; - IDictionary entry = o as IDictionary; - foreach (DictionaryEntry e in entry) - { - context[e.Key] = e.Value; - } - return CONTINUE; + IDictionary result = o as IDictionary; + + ICollection keys = result.Keys; + foreach (string key in keys) + { + context[key] = result[key]; + } + + AppEntry entry = new AppEntry(result); + context[ID] = entry; + + return CONTINUE; } } } Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/TelephoneProcessor.cs URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/TelephoneProcessor.cs?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/TelephoneProcessor.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/TelephoneProcessor.cs Fri Jan 5 17:03:09 2007 @@ -43,7 +43,7 @@ string mark = "-"; if (output == null) return false; - string buffer = null; + string buffer; if (output.Length == 10) { Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Objects.xml URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Objects.xml?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Objects.xml (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Objects.xml Fri Jan 5 17:03:09 2007 @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd"> - <import resource="web://~/Resources/AppBase.xml"/> - <import resource="web://~/Resources/AppConfig.xml"/> - <import resource="web://~/Resources/AppFields.xml"/> - <import resource="web://~/Resources/Catalog.xml"/> + <import resource="Resources/AppBase.xml"/> + <import resource="Resources/AppConfig.xml"/> + <import resource="Resources/AppFields.xml"/> + <import resource="Resources/Catalog.xml"/> </objects> Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj Fri Jan 5 17:03:09 2007 @@ -73,6 +73,7 @@ <Compile Include="BaseTest.cs" /> <Compile Include="Commands\DirectoryViewTest.cs" /> <Compile Include="Commands\FilterLists.cs" /> + <Compile Include="Commands\FormatEntry.cs" /> <Compile Include="Commands\SelectAllTest.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx Fri Jan 5 17:03:09 2007 @@ -48,13 +48,13 @@ [JsonRpcMethod(App.ENTRY_LIST, Idempotent = true)] [JsonRpcHelp("Returns the complete directory as an array of formatted IDictionary objects.")] - public AppEntry[] entry_list() + public AppEntryList entry_list() { IViewHelper helper = GetCatalog().GetHelperFor(App.ENTRY_LIST); helper.Execute(); // if helper.IsNominal ... AppEntryList list = helper.Outcome as AppEntryList; - return list.ToAppEntryArray(); + return list; } [JsonRpcMethod(App.ENTRY, Idempotent = true)] @@ -65,18 +65,20 @@ helper.Criteria[App.ENTRY_KEY] = key; helper.Execute(); // if helper.IsNominal ... - return helper.Outcome[0] as AppEntry; + AppEntry entry = new AppEntry(helper.Criteria); + return entry; } [JsonRpcMethod(App.ENTRY_SAVE, Idempotent = true)] [JsonRpcHelp("Saves the entry, insert or updating as appropriate.")] - public IDictionary entry_save(IDictionary input) + public AppEntry entry_save(IDictionary input) { IViewHelper helper = GetCatalog().GetHelperFor(App.ENTRY_SAVE); helper.Read(input,true); helper.Execute(); // if helper.IsNominal ... - return helper.Outcome[0] as IDictionary; + AppEntry entry = new AppEntry(helper.Criteria); + return entry; } } Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.html URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.html?view=diff&rev=493264&r1=493263&r2=493264 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.html (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.html Fri Jan 5 17:03:09 2007 @@ -21,7 +21,7 @@ { var bindArgs = { url: call.url+'?rpc', - error: function(type, data, evt){alert("Error Communicating with Server: " + data);}, + error: function(type, data, evt){alert("Error Communicating with Server: " + data.result);}, method: "POST", mimetype: "text/json", handle: call.callback, @@ -47,10 +47,7 @@ function entry_list_select_result(evt) { var table = dojo.widget.byId("entry_list"); - var row = table.getSelectedData(); - var user_name = row.user_name; - var entry_key = row.entry_key; - alert(user_name + " (" + entry_key + ") is selected."); + entry_edit(table.getSelectedData().entry_key); } function entry_list_select() { dojo.event.connect(dojo.byId("entry_list"), "onSelect", entry_list_select_result); @@ -83,6 +80,17 @@ /* editor */ + function entry_edit_result(type, data, evt) + { + var w = dojo.widget.byId("entry_form"); + w.setValues(data.result); + + } + function entry_edit(entry_key) + { + PhoneBook.rpc.entry(entry_key,entry_edit_result).call(server); + } + function entry_save_result(type, data, evt) { alert ( "Added: " + data.result.user_name + " (" + data.result.entry_key + ")" ); @@ -158,29 +166,8 @@ </style> </head> <body> - - <div id="editor"> - <form id="entry_form" dojoType="Form"> - <table><tr> - <td>First Name</td><td><input name="first_name" /></td> - </tr><tr> - <td>Last Name</td><td><input name="last_name" /></td> - </tr><tr> - <td>Extension</td><td><input name="extension" /></td> - </tr><tr> - <td>User Name</td><td><input name="user_name" /></td> - </tr><tr> - <td>Hired</td><td><input type="text" name="hired" dojoType="dropdowndatepicker" displayFormat="dd/MM/yyyy" /></td> - </tr><tr> - <td>Hours</td><td><input name="hours" /></td> - </tr><tr> - <td rowspan="2"><input type="button" onClick="entry_save();" value="SAVE" /> - <input type="hidden" name="editor" value="1" /> - <input type="hidden" name="entry_key" /> - </td> - </tr></table> - </form> - </div> + + <div id="finder" /> <div id="lister"> <table id="entry_list" @@ -203,9 +190,34 @@ <input type="button" onclick="applyName('entry_list');" value="Show only names between M and Z" /> <input type="button" value="Show All Entries" onclick="clearFilters('entry_list');" /> <input type="button" value="Reload Data" onclick="reloadData('entry_list');" /> - <input type="button" value="Select Row" onclick="entry_list_select_result('entry_list');" /> + <input type="button" value="Edit Row" onclick="entry_list_select_result('entry_list');" /> </p> </div> + <div id="viewer" /> + + <div id="editor"> + <form id="entry_form" dojoType="Form"> + <table><tr> + <td>First Name</td><td><input name="first_name" /></td> + </tr><tr> + <td>Last Name</td><td><input name="last_name" /></td> + </tr><tr> + <td>Extension</td><td><input name="extension" /></td> + </tr><tr> + <td>User Name</td><td><input name="user_name" /></td> + </tr><tr> + <td>Hired</td><td><input name="hired" dojoType="dropdowndatepicker" displayFormat="dd/MM/yyyy" /></td> + </tr><tr> + <td>Hours</td><td><input name="hours" /></td> + </tr><tr> + <td rowspan="2"><input type="button" onClick="entry_save();" value="SAVE" /> + <input type="hidden" name="editor" value="1" /> + <input type="hidden" name="entry_key" /> + </td> + </tr></table> + </form> + </div> + </body> </html>