diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs index 799bbe6b..496cefb0 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs @@ -64,7 +64,7 @@ namespace Spring.Northwind.Dao.NHibernate } [Transaction(ReadOnly = false)] - public void SaveOrUpdate(Customer customer) + public void Update(Customer customer) { Session.SaveOrUpdate(customer); } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs index 5046f3d2..bee54b7b 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs @@ -26,34 +26,41 @@ using Spring.Data.NHibernate.Generic; using Spring.Data.NHibernate.Support; using Spring.Northwind.Domain; +using Spring.Stereotype; +using Spring.Transaction.Interceptor; #endregion namespace Spring.Northwind.Dao.NHibernate { + [Repository] public class HibernateOrderDao : HibernateDao, IOrderDao { + [Transaction(ReadOnly = true)] public Order Get(int orderId) { return Session.Get(orderId); - } + [Transaction(ReadOnly = true)] public IList GetAll() { return GetAll(); } + [Transaction] public int Save(Order order) { return (int) Session.Save(order); } - public void SaveOrUpdate(Order order) + [Transaction] + public void Update(Order order) { Session.SaveOrUpdate(order); } + [Transaction] public void Delete(Order order) { Session.Delete(order); diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs index f1922c92..f256cb8f 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs @@ -25,34 +25,41 @@ using System.Collections.Generic; using Spring.Data.NHibernate.Support; using Spring.Northwind.Domain; +using Spring.Stereotype; +using Spring.Transaction.Interceptor; #endregion namespace Spring.Northwind.Dao.NHibernate { + [Repository] public class HibernateProductDao : HibernateDao, IProductDao { + [Transaction(ReadOnly = true)] public Product Get(int productId) { return Session.Get(productId); - } + [Transaction(ReadOnly = true)] public IList GetAll() { return GetAll(); } + [Transaction] public int Save(Product product) { return (int) Session.Save(product); } - public void SaveOrUpdate(Product product) + [Transaction] + public void Update(Product product) { Session.SaveOrUpdate(product); } + [Transaction] public void Delete(Product product) { Session.Delete(product); diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj index 74f1729c..04289f59 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj @@ -36,6 +36,10 @@ False ..\..\..\..\..\bin\net\2.0\debug\Common.Logging.dll + + False + ..\..\lib\net\2.0\FluentNHibernate.dll + False ..\..\..\..\..\lib\NHibernate21\net\2.0\Iesi.Collections.dll @@ -61,6 +65,7 @@ ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate21.dll + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs index 35bcc6f3..10d1320b 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs @@ -28,6 +28,9 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao { + /// + /// Customer related DAO operations interface. + /// public interface ICustomerDao : IDao, ISupportsDeleteDao, ISupportsSave { } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs index a816c18b..fa28fa8b 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs @@ -2,6 +2,11 @@ using System.Collections.Generic; namespace Spring.Northwind.Dao { + /// + /// Generic DAO interface with minimum retrieval methods. + /// + /// Entity to operate with. + /// Entity id type. public interface IDao { /// diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs index 2eb70993..be17ec76 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs @@ -28,10 +28,10 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao { - public interface IOrderDao : IDao, ISupportsDeleteDao + /// + /// Order related DAO operations interface. + /// + public interface IOrderDao : IDao, ISupportsDeleteDao, ISupportsSave { - int Save(Order order); - - void SaveOrUpdate(Order order); } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs index e0507aaa..abed8690 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs @@ -28,6 +28,9 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao { + /// + /// Product related DAO operations interface. + /// public interface IProductDao : IDao, ISupportsDeleteDao, ISupportsSave { diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsDeleteDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsDeleteDao.cs index 057cba87..8a475226 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsDeleteDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsDeleteDao.cs @@ -1,7 +1,15 @@ namespace Spring.Northwind.Dao { + /// + /// Role interface for DAOs that support deletion of entities. + /// + /// Entity type. public interface ISupportsDeleteDao { + /// + /// Deletes the entity. + /// + /// Entity to delete. void Delete(TEntity entity); } } \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs index a40b3093..9bcbdc06 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs @@ -1,5 +1,10 @@ namespace Spring.Northwind.Dao { + /// + /// Role interface for DAOs that support saves and updates to entities. + /// + /// Entity type. + /// Entity id type. public interface ISupportsSave { /// @@ -13,6 +18,6 @@ namespace Spring.Northwind.Dao /// Saves or updates the entity. Behavior depends on the current state of entity's ID. /// /// Entity to save or update. - void SaveOrUpdate(TEntity entity); + void Update(TEntity entity); } } \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs index e5f1fa59..68da4f9d 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs @@ -96,7 +96,7 @@ namespace Spring.Northwind.Service order.ShippedDate = DateTime.Now; //Update shipment date - OrderDao.SaveOrUpdate(order); + OrderDao.Update(order); //Other operations...Decrease product quantity... etc } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF index ec83fded..0ef778c7 100644 Binary files a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf index fcbbdf4a..fa529836 100644 Binary files a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Themes/Spring/Spring.skin b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Themes/Spring/Spring.skin new file mode 100644 index 00000000..0a92e794 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Themes/Spring/Spring.skin @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CSS/style.css b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CSS/style.css index 8314f473..784e77f6 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CSS/style.css +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CSS/style.css @@ -1,129 +1,166 @@ -body { - margin: 0px; - padding: 0px; - background-color: #dfeac1; - text-align: center; -} - -.logo { - position:relative; - top:-8px; - left:22px; - float:left; -} - -#ad { - float:right; - position:relative; - right: 22px; - top:-8px; -} - - - -.navigation { - position:relative; - left: 25px; - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #000000; - text-decoration: none; - width:150px; -} -.navigation a, .navigation a:active, .navigation a:visited { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #7E7E7E; - text-decoration: none; -} -.navigation a:hover { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #000000; - text-decoration: none; -} - - -h4.navbar { - position:relative; - left: 0px; - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #5F5F5F; - text-decoration: none; - margin-bottom: 2px; -} -h1 { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 14px; - font-weight: normal; - color: #90A720; -} -a, a:active, a:visited { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #606060; - text-decoration: underline; -} -a:hover { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #000000; -} -b { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - font-weight: bold; - color: #606060; -} -i { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #606060; -} - -table { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #606060; -} -.news { - border: 1px solid; - border-color: #C9C9C9; - padding: 12px; - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - color: #606060; - background-color: #F5F5F5; - margin-top: 20px; - margin-bottom: 20px; -} -.news b { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 11px; - font-weight: normal; - color: #90A720; -} -.news u { - font-family: Verdana, Arial, Helvetica, sans; - font-size: 12px; - font-weight: bold; - color: #606060; - text-decoration: none; -} -li { - margin-bottom: 12px; -} - -li.newslist { - margin-bottom: 2px; -} - -ul.newslist { - margin-left: 10px; - margin-top: 10px; -} -ul { - margin-left: 25px; - margin-top: 10px; +body { + margin: 0px; + padding: 0px; + background-color: #dfeac1; + text-align: center; + text-decoration: none; +} + +.logo { + position:relative; + top:-8px; + left:22px; + float:left; +} + +.headerText +{ + color: White; + left: 350px; + top: 50px; + font-family: Verdana; + font-size: 150%; + font-weight: bold; + position: absolute; +} + +fieldset { + border: 1px solid #CCA383; + width: 60%; + background: LightGoldenrodYellow; + padding: 3px; + padding-bottom: 10px; +} + +fieldset legend { + background: PaleGoldenrod; + padding: 6px; + font-weight: bold; +} + +.formLabelCell +{ + text-align: left; + padding-left: 10px; + padding-right: 30px; + font-weight: bold; +} + +.formValueCell +{ + text-align: left; +} + +.actionPanel +{ + margin: 30px; + border: 1px solid #CCA383; + width: 50%; + background: LightGoldenrodYellow; + text-align: center; + padding: 5px; +} + +#headerCell +{ + background: url(../img/header-spring.png); + height: 150px; + width: 719px; +} + +#contentCell +{ + background-image: url(../img/bg-spring.png); + text-align: left; + vertical-align: top; +} + +#footerCell +{ + background-image: url(../img/footern.gif); + text-align: center; + height: 29px; +} + +.datagrid +{ + border: solid 1px Tan; + margin-left: 10px; +} + +.datagrid-header +{ + font-weight: bold; + background-color: Tan; +} + +.datagid-item +{ + background-color: LightGoldenrodYellow; +} + +.datagrid-alt-item +{ + background-color: PaleGoldenrod; +} + +.datagrid-footer +{ + font-weight: bold; + background-color: Tan; +} + +h1 { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 14px; + font-weight: normal; + color: #90A720; +} +a, a:active, a:visited { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; + text-decoration: underline; +} +a:hover { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #000000; +} +b { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + font-weight: bold; + color: #606060; +} +i { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; +} + +table { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; +} +.news { + border: 1px solid; + border-color: #C9C9C9; + padding: 12px; + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; + background-color: #F5F5F5; + margin-top: 20px; + margin-bottom: 20px; +} + +li { + margin-bottom: 12px; +} + +ul { + margin-left: 25px; + margin-top: 10px; } \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx index 63ff4870..7061a2a4 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx @@ -2,22 +2,36 @@ Inherits="CustomerEditor" %> - - - - - - - - - - -
- ID: -
- Contact: -
-
- +

+ Update customer information

+
+ +
+ Customer details + + + + + + + + + + + + +
+ ID: +
+ Contact: +
+
+
+
+ +
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx.cs index 6920e3de..ce673e79 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx.cs @@ -1,69 +1,63 @@ using System; -using System.Web; using Spring.Northwind.Dao; using Spring.Northwind.Domain; using Spring.Web.UI; public partial class CustomerEditor : Page { - private ICustomerEditController customerEditController; - private ICustomerDao customerDao; + private ICustomerEditController customerEditController; + private ICustomerDao customerDao; - public ICustomerDao CustomerDao - { - set { this.customerDao = value; } - } - - public ICustomerEditController CustomerEditController - { - set { this.customerEditController = value; } - } - - public Customer CurrentCustomer - { - get + public ICustomerDao CustomerDao { - //return (Customer) Session[typeof(CustomerEditor).FullName + ".Customer"]; - return customerEditController.CurrentCustomer; + set { customerDao = value; } } - } -// public static void Edit( Customer customer ) -// { -// HttpContext.Current.Session[typeof(CustomerEditor).FullName + ".Customer"] = customer; -// } + public ICustomerEditController CustomerEditController + { + set { customerEditController = value; } + } - public CustomerEditor() - { - this.InitializeControls+=new EventHandler(Page_InitializeControls); - this.DataBound+=new EventHandler(Page_DataBound); - this.DataUnbound+=new EventHandler(Page_DataUnbound); - } + public Customer CurrentCustomer + { + get + { + return customerEditController.CurrentCustomer; + } + } - override protected void InitializeDataBindings() - { - base.InitializeDataBindings(); + public CustomerEditor() + { + InitializeControls += Page_InitializeControls; + DataBound += Page_DataBound; + DataUnbound += Page_DataUnbound; + } - // do the "one time" setup for databinding - } + override protected void InitializeDataBindings() + { + base.InitializeDataBindings(); - private void Page_DataBound(object sender, EventArgs e) - { - // perform custom tasks for binding data from model to the form - } + // do the "one time" setup for databinding + } - private void Page_DataUnbound(object sender, EventArgs e) - { - // perform custom tasks for unbinding data from form to the model - } + private void Page_DataBound(object sender, EventArgs e) + { + // perform custom tasks for binding data from model to the form + } - private void Page_InitializeControls(object sender, EventArgs e) - { - btnSave.Click += new EventHandler(BtnSave_Click); - } + private void Page_DataUnbound(object sender, EventArgs e) + { + // perform custom tasks for unbinding data from form to the model + } - private void BtnSave_Click(object sender, EventArgs e) - { - customerDao.SaveOrUpdate(CurrentCustomer); - } + private void Page_InitializeControls(object sender, EventArgs e) + { + btnSave.Click += BtnSave_Click; + } + + private void BtnSave_Click(object sender, EventArgs e) + { + customerDao.Update(CurrentCustomer); + Response.Redirect("~/CustomerView.aspx"); + } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx index f38883b0..9863da94 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx @@ -3,6 +3,8 @@ +

Customers in database

+ + +

Orders for customer

+ +
+ + + + + +
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx.cs index b65bfc77..dfa2f028 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx.cs @@ -3,66 +3,64 @@ using System.Collections; using System.Web.UI.WebControls; using Spring.Northwind.Domain; -public partial class CustomerOrders:Spring.Web.UI.Page +public partial class CustomerOrders : Spring.Web.UI.Page { - private ICustomerEditController customerEditController; + private ICustomerEditController customerEditController; - public ICustomerEditController CustomerEditController - { - set { this.customerEditController = value; } - } - - public Customer SelectedCustomer - { - get + public ICustomerEditController CustomerEditController { - return this.customerEditController.CurrentCustomer; + set { customerEditController = value; } } - } - public CustomerOrders() - { - this.InitializeControls+=new EventHandler(Page_InitializeControls); - this.DataBound+=new EventHandler(Page_DataBound); - this.DataUnbound+=new EventHandler(Page_DataUnbound); - } - - override protected void InitializeDataBindings() - { - base.InitializeDataBindings(); - - // do the "one time" setup for databinding - } - - private void Page_DataBound(object sender, EventArgs e) - { - // perform custom tasks for binding data from model to the form - } - - private void Page_DataUnbound(object sender, EventArgs e) - { - // perform custom tasks for unbinding data from form to the model - } - - private void Page_InitializeControls(object sender, EventArgs e) - { - // create/initialize controls here - customerOrders.DataSource = SelectedCustomer.Orders; - if (!IsPostBack) + public Customer SelectedCustomer { - customerOrders.DataBind(); + get { return customerEditController.CurrentCustomer; } } - else - { - customerOrders.ItemCreated+=new DataGridItemEventHandler( this.CustomerList_ItemCreated ); - } - } - private void CustomerList_ItemCreated(object sender, DataGridItemEventArgs e) - { - if(e.Item.DataSetIndex > -1) + public CustomerOrders() { - e.Item.DataItem = ((IList)customerOrders.DataSource)[e.Item.DataSetIndex]; + InitializeControls += Page_InitializeControls; + DataBound += Page_DataBound; + DataUnbound += Page_DataUnbound; } - } -} + + protected override void InitializeDataBindings() + { + base.InitializeDataBindings(); + + // do the "one time" setup for databinding + } + + private void Page_DataBound(object sender, EventArgs e) + { + // perform custom tasks for binding data from model to the form + } + + private void Page_DataUnbound(object sender, EventArgs e) + { + // perform custom tasks for unbinding data from form to the model + } + + private void Page_InitializeControls(object sender, EventArgs e) + { + // create/initialize controls here + customerOrders.DataSource = SelectedCustomer.Orders; + customerName.Text = SelectedCustomer.CompanyName; + if (!IsPostBack) + { + customerOrders.DataBind(); + } + else + { + customerOrders.ItemCreated += CustomerList_ItemCreated; + } + } + + private void CustomerList_ItemCreated(object sender, DataGridItemEventArgs e) + { + if (e.Item.DataSetIndex > -1) + { + e.Item.DataItem = ((IList) customerOrders.DataSource)[e.Item.DataSetIndex]; + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx index 71cf3653..7d02181c 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx @@ -1,25 +1,32 @@ -<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" CodeFile="CustomerEditor.aspx.cs" - Inherits="CustomerEditor" %> +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" CodeFile="CustomerView.aspx.cs" + Inherits="CustomerView" %> - -
- - - - - - - - - -
- ID: -
- Contact: -
-
-
- +
+ +
+ Customer details + + + + + + + + + +
+ ID: + <%= CurrentCustomer.Id %> +
+ Contact: + <%= CurrentCustomer.ContactName %> +
+
+
+ +
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx.cs index 7e958131..d150b512 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx.cs @@ -55,11 +55,7 @@ public partial class CustomerView : Page private void Page_InitializeControls(object sender, EventArgs e) { - btnSave.Click += new EventHandler(BtnSave_Click); + } - private void BtnSave_Click(object sender, EventArgs e) - { - customerDao.SaveOrUpdate(CurrentCustomer); - } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx index 9943ba9d..99e348a7 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx @@ -1,2 +1,13 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> -<%Response.Redirect("CustomerList.aspx");%> +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> + + + +

Welcome to Spring.NET Northwind sample application!

+ +

+This sample demostrates Spring.NET NHibernate integration and concepts. All data access is done using NHibernate and +all transactions are automatically handled by Spring.NET. +

+ +Proceed to customer listing » +
\ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/bg-spring.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/bg-spring.png new file mode 100644 index 00000000..fdb377cd Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/bg-spring.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/footern.gif b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/footern.gif new file mode 100644 index 00000000..8375fea1 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/footern.gif differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master index 8e9ea2f4..7edee251 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master @@ -7,52 +7,38 @@
-
- - - - - - - - - - - - -
- -
- - - - - - - - - - - - - -
-
-
-
- - - - - -
-
-
-
-
-
+ +
+
+ + + + + + + + + + + + +
+ +
+ Goes Northwind
with NHibernate +
+
+
+ + + +
+
+
+
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config index 883c8916..d4cdec1e 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config @@ -65,8 +65,10 @@ - - + + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.xml b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.xml index 7883e61d..56782857 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.xml +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.xml @@ -34,6 +34,11 @@ + + + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs index c45316a2..8471710f 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs @@ -20,8 +20,6 @@ #region Imports -using System; -using System.Collections; using System.Data; using NHibernate; using NUnit.Framework; @@ -99,7 +97,7 @@ namespace Spring.Northwind.IntegrationTests c.CompanyName = "SpringSource"; - customerDao.SaveOrUpdate(c); + customerDao.Update(c); c = customerDao.Get("MPOLL"); Assert.AreEqual(c.Id, "MPOLL"); @@ -149,7 +147,7 @@ namespace Spring.Northwind.IntegrationTests Assert.AreEqual(831, orderDao.GetAll().Count); order.ShipCity = "Sao Paulo"; - orderDao.SaveOrUpdate(order); + orderDao.Update(order); order = orderDao.Get(orderId); Assert.AreEqual("PICCO", order.Customer.Id);