1 namespace JSGenExample
.Controllers
3 using Castle
.MonoRail
.Framework
;
4 using Castle
.MonoRail
.Framework
.Helpers
;
5 using JSGenExample
.Models
;
7 [Layout("default"), Rescue("generalerror")]
8 public class HomeController
: SmartDispatcherController
10 private const int PageSize
= 5;
14 PropertyBag
["customers"] = PaginationHelper
.CreatePagination
<Customer
>(this, Customers
, PageSize
);
20 public void NewCustomer()
22 // Here, the NewCustomer.njs will be "rendered"
28 public void AddCustomer([DataBind("customer")] Customer customer
)
31 // Here, the AddCustomer.njs will be "rendered"
33 PropertyBag
["customer"] = customer
;
37 /// Just to mimic a persistent storage
39 protected Customer
[] Customers
43 if (!Session
.Contains("items"))
45 Session
["items"] = new Customer
[]
47 new Customer(1, "Apple", "contact@apple.com"),
48 new Customer(2, "Google", "contact@google.com"),
49 new Customer(3, "Microsoft", "contact@ms.com"),
50 new Customer(4, "ChangeCorporation", "contact@changecorporation.com.au"),
51 new Customer(5, "Castle Stronghold", "contact@castlestronghold.com"),
52 new Customer(6, "Fox Networks", "contact@fox-intl.com"),
53 new Customer(7, "Cisco", "contact@cisco.com"),
54 new Customer(8, "Linksys", "contact@linksys.com"),
55 new Customer(9, "Siemens", "contact@siemens.com"),
56 new Customer(10, "Toshiba", "contact@toshiba.com"),
57 new Customer(11, "Dell", "contact@dell.com"),
61 return (Customer
[]) Session
["items"];