Author: husted Date: Wed Jan 3 09:34:00 2007 New Revision: 492228 URL: http://svn.apache.org/viewvc?view=rev&rev=492228 Log: PhoneBook2 - Use FilteringTable widget to display phone book entries.
Added: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoService.ashx - copied unchanged from r491821, struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Demo.ashx struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoService.html - copied, changed from r491822, struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoDojo.html struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Objects.xml Removed: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Demo.ashx struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoDojo.html Modified: struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.csproj struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/App.cs struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Core.csproj struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Default.aspx struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/HelloWorld.html 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.csproj URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.csproj?view=diff&rev=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.csproj (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/PhoneBook2.csproj Wed Jan 3 09:34:00 2007 @@ -27,6 +27,22 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/App.cs URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/App.cs?view=diff&rev=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/App.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/App.cs Wed Jan 3 09:34:00 2007 @@ -30,6 +30,12 @@ #region Properties /// <summary> + /// Token for Catalog property. + /// </summary> + /// + public const string CATALOG_KEY = "Catalog"; + + /// <summary> /// Token for entry_key property. /// </summary> /// 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=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/AppEntryList.cs Wed Jan 3 09:34:00 2007 @@ -24,5 +24,10 @@ entry.Add(col.Key.ToString(), col.Value.ToString()); Add(entry); } + + public AppEntry[] ToAppEntryArray() + { + return (AppEntry[])ToArray(typeof(AppEntry)); + } } } Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Core.csproj URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Core.csproj?view=diff&rev=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Core.csproj (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Core/Core.csproj Wed Jan 3 09:34:00 2007 @@ -27,6 +27,22 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> <ItemGroup> <Reference Include="Agility.Core, Version=1.0.2355.25640, Culture=neutral"> <SpecificVersion>False</SpecificVersion> 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=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Test/Test.csproj Wed Jan 3 09:34:00 2007 @@ -27,6 +27,22 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> <ItemGroup> <Reference Include="Agility.Core, Version=1.0.2355.25640, Culture=neutral"> <SpecificVersion>False</SpecificVersion> Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Default.aspx URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Default.aspx?view=diff&rev=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Default.aspx (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Default.aspx Wed Jan 3 09:34:00 2007 @@ -4,7 +4,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> - <title>Untitled Page</title> + <title>PhoneBook and Friends</title> </head> <body> <form id="form1" runat="server"> @@ -14,14 +14,22 @@ <a href="HelloWorld.html">HelloWorld.html</a> - Simple Jayrock example </li> <li> - <a href="Demo.ashx">Demo.ashx</a> - Jayrock JSON-RPC DemoService, with automatic service discovery and interactive test page. It doesn't get any easier than this! - </li> - <li> - <a href="DemoDojo.html">DemoDojo.html</a> - Simple example of integrating Dojo and Jayrock + <a href="DemoService.html">DemoService.html</a> - Simple example of integrating Dojo and Jayrock </li> <li> <a href="PhoneBook.html">PhoneBook.html</a> - First blush example of calling Nexus commands from JSON-RPC service </li> + </ul> + <ul> + <li> + <a href="HelloWorld.ashx">HelloWorld.ashx</a> - Simple example of a Jayrock JSON-RPC service. + </li> + <li> + <a href="DemoService.ashx">DemoService.ashx</a> - Examples of various output types. + </li> + <li> + <a href="PhoneBook.ashx">PhoneBook.ashx</a> - PhoneBook API - WORK IN PROGRESS. + </li> </ul> </div> </form> Copied: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoService.html (from r491822, struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoDojo.html) URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoService.html?view=diff&rev=492228&p1=struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoDojo.html&r1=491822&p2=struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoService.html&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoDojo.html (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/DemoService.html Wed Jan 3 09:34:00 2007 @@ -1,11 +1,11 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> - <title>Dojo/Jayrocks Demo</title> + <title>Dojo Element / Jayrocks Service Demonstration</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name=ProgId content=VisualStudio.HTML> <meta name=Originator content="Microsoft Visual Studio .NET 7.1"> - <script language="javascript" src="Demo.ashx?proxy&v=2"></script> + <script language="javascript" src="DemoService.ashx?proxy&v=2"></script> <script language="javascript" src="js/dojo/dojo.js"></script> <script language="javascript"> dojo.require("dojo.io.*"); @@ -57,6 +57,6 @@ <h2>getStringArray as Select control</h2> <div id="string_array"></div> <hr /> - + </body> -</html> \ No newline at end of file +</html> \ No newline at end of file Modified: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/HelloWorld.html URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/HelloWorld.html?view=diff&rev=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/HelloWorld.html (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/HelloWorld.html Wed Jan 3 09:34:00 2007 @@ -2,26 +2,47 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> - <title>Hello Jayrock</title> + <title>Hello Jayrock and Dojo</title> + + <!-- Basic Jayrock --> <script type="text/javascript" src="js/json.js"></script> <script type="text/javascript" src="helloworld.ashx?proxy"></script> <script type="text/javascript"> -/* <![CDATA[ */ - -window.onload = function() -{ - var s = new HelloWorld(); - - alert("sync:" + s.greetings()); + window.onload = function() + { + var s = new HelloWorld(); + alert("sync:" + s.greetings()); + s.greetings(function(response) { + alert("async:" + response.result) + }); + } + </script> + <!-- Basic Dojo --> + <script language="javascript" src="js/dojo/dojo.js"></script> + <script language="javascript"> + dojo.require("dojo.event.*"); + dojo.require("dojo.widget.*"); + dojo.require("dojo.widget.Button"); - s.greetings(function(response) { - alert("async:" + response.result) - }); -} + function helloPressed() + { + alert('You pressed the button'); + } -/* ]]> */ + function helloInit() + { + var helloButton = dojo.widget.byId('helloButton'); + dojo.event.connect(helloButton, 'onClick', 'helloPressed') + + } + dojo.addOnLoad(helloInit); </script> </head> <body> - <p>This page tests the HelloWorld service with Jayrock.</p> + <p>This page combines the Jayrock and Dojo Hello World examples.</p> + + <p><button id="helloButton" class="dojo-Button">Hello World!</button></p> + </body> +</html> + Added: struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Objects.xml URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Objects.xml?view=auto&rev=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Objects.xml (added) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/Objects.xml Wed Jan 3 09:34:00 2007 @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8" ?> +<objects xmlns="http://www.springframework.net" + 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="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/Web/PhoneBook.ashx URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx?view=diff&rev=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.ashx Wed Jan 3 09:34:00 2007 @@ -6,21 +6,37 @@ using Jayrock.JsonRpc; using Jayrock.JsonRpc.Web; using Nexus.Core; +using Nexus.Core.Helpers; +using PhoneBook.Core; using Spring.Context; namespace JayrockWeb { public class PhoneBook : JsonRpcHandler { - protected IRequestCatalog catalog; - [JsonRpcMethod("last_name_list", Idempotent = true)] - [JsonRpcHelp("Returns Lastn Name List as an array.")] - public string[] last_name_list() + private IRequestCatalog catalog = null; + + private IRequestCatalog GetCatalog() + { + if (catalog == null) + { + IApplicationContext factory = Objects.Factory(); + catalog = factory.GetObject(App.CATALOG_KEY) as IRequestCatalog; + } + return catalog; + } + + private RequestContext Execute(string command) { - IApplicationContext factory = Objects.Factory(); - catalog = factory.GetObject("Catalog") as IRequestCatalog; - RequestContext context = (RequestContext) catalog.ExecuteRequest("last_name_list"); + return (RequestContext) GetCatalog().ExecuteRequest(command); + } + + [JsonRpcMethod(App.LAST_NAME_LIST, Idempotent = true)] + [JsonRpcHelp("Returns Last Name List as an array.")] + public string[] last_name_list() + { + RequestContext context = Execute(App.LAST_NAME_LIST); KeyValueList list = context.Outcome as KeyValueList; ArrayList names = new ArrayList(list.Count); foreach (KeyValue k in list) @@ -29,5 +45,16 @@ } return (string[]) names.ToArray(typeof (String)); } + + [JsonRpcMethod(App.ENTRY_LIST, Idempotent = true)] + [JsonRpcHelp("Returns the complete directory as an array of formatted IDictionary objects.")] + public AppEntry[] entry_list() + { + IViewHelper helper = GetCatalog().GetHelperFor(App.ENTRY_LIST); + helper.Execute(); + // if helper.IsNominal ... + AppEntryList list = helper.Outcome as AppEntryList; + return list.ToAppEntryArray(); + } } } 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=492228&r1=492227&r2=492228 ============================================================================== --- struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.html (original) +++ struts/sandbox/trunk/overdrive/PhoneBook2/projects/Web/PhoneBook.html Wed Jan 3 09:34:00 2007 @@ -5,13 +5,15 @@ <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name=ProgId content=VisualStudio.HTML> <meta name=Originator content="Microsoft Visual Studio .NET 7.1"> - <script language="javascript" src="PhoneBook.ashx?proxy&v=2"></script> + <script language="javascript" src="PhoneBook.ashx?proxy&v=2"></script> <script language="javascript" src="js/dojo/dojo.js"></script> <script language="javascript"> dojo.require("dojo.io.*"); dojo.require("dojo.event.*"); dojo.require("dojo.html.*"); dojo.require("dojo.json"); + dojo.require("dojo.widget.FilteringTable"); + dojo.hostenv.writeIncludes(); function dojoChannel(call) { @@ -21,7 +23,7 @@ method: "POST", mimetype: "text/json", handle: call.callback, - postContent: dojo.json.serialize(call.request) + postContent: dojo.json.serialize(call.request) }; var req = dojo.io.bind(bindArgs); dojo.event @@ -31,24 +33,146 @@ function last_name_list_element(type, data, evt) { var arr = data.result; - var theDiv = dojo.byId('last_name_list'); + var last_name_list = dojo.byId('last_name_list'); var select = document.createElement('select'); for(var i=0; i < arr.length; i++) { select.options[i] = new Option(arr[i], arr[i]); } - theDiv.appendChild(select); + var label = document.createElement('label'); + label.value = "Last Name: "; + last_name_list.appendChild(label); + last_name_list.appendChild(select); } function last_name_list() - { + { PhoneBook.rpc.last_name_list(last_name_list_element).call(dojoChannel); } - dojo.event.connect(window, "onload", last_name_list); + dojo.event.connect(window, "onload", last_name_list); + + function entry_list_element(type, data, evt) + { + var w = dojo.widget.byId("entry_list"); + w.store.setData(data.result); + } + + function entry_list() + { + PhoneBook.rpc.entry_list(entry_list_element).call(dojoChannel); + } + + dojo.event.connect(window, "onload", entry_list); + + function showSelected() { + var w=dojo.widget.byId("entry_list"); + if (w) { + var s=w.getValue(); + if (s.length>0) alert(s); + else alert("No rows are selected."); + } + } + + function dateFilter(dt) { + return (dt == '5/29/1987' || dt == '11/18/1984'); + } + function applyDate(key){ + dojo.widget.byId(key).setFilter("hired", dateFilter); + } + + function nameFilter(name){ + return (name.charAt(0) >= 'M' && name.charAt(0) <= 'Z'); + } + function applyName(key){ + dojo.widget.byId(key).setFilter("last_name", nameFilter); + } + </script> - </head> + + <style type="text/css"> + /*** + The following is just an example of how to use the table. + You can override any class names to be used if you wish. + ***/ + table { + font-family:Lucida Grande, Verdana; + font-size:0.8em; + width:100%; + border:1px solid #ccc; + border-collapse:collapse; + cursor:default; + } + table td, + table th{ + padding:2px; + font-weight:normal; + } + table thead td, table thead th { + background-image:url(images/ft-head.gif); + background-repeat:no-repeat; + background-position:top right; + } + table thead td.selectedUp, table thead th.selectedUp { + background-image:url(images/ft-headup.gif); + } + table thead td.selectedDown, table thead th.selectedDown { + background-image:url(images/ft-headdown.gif); + } + + table tbody tr td{ + border-bottom:1px solid #ddd; + } + table tbody tr.alt td{ + background: #e3edfa; + } + table tbody tr.selected td{ + background: yellow; + } + table tbody tr:hover td{ + background: #a6c2e7; + } + table tbody tr.selected:hover td{ + background:#ff9; + } + + #inputArea{ + margin:1em 0; + padding:1em; + background-color:#eef; + } + #updateTestInput{ + border:1px solid #ccc; + width:100%; + height:80px; + font-family:serif; + font-size:0.9em; + overflow:auto; + } + </style> + </head> <body> + <div id="last_name_list"></div> + + <table id="entry_list" + cellpadding="0" cellspacing="0" border="0" style="margin-bottom:24px;" + dojoType="filteringTable" alternateRows="true" valueField="user_name" > + <thead> + <tr> + <th field="last_name" sort="asc">Last Name</th> + <th field="first_name">First Name</th> + <th field="extension">Extension</th> + <th field="user_name">User</th> + <th field="hired" align="center">Hired</th> + <th field="hours" align="center">Hours</th> + </tr> + </thead> + </table> + <p> + <input type="button" onclick="showSelected();" value="Show the selected object" /> + <input type="button" onclick="applyDate('entry_list');" value="Show only hires between 1/1/1984 and 1/1/1987" /> + <input type="button" onclick="applyName('entry_list');" value="Show only names between M and Z" /> + </p> </body> </html>