Spring.net and MVC
I am starting a project to learn spring and MVC I am using visual studio 2012 and c# to make a web project.
My hopes is to have this discussion help guide me and others into using these items with the best practices in mind and maybe even get people to offer ideas and post links to where I can get started on all this.
Here is the general concept I am going to start with, and then everyone is welcome to help correct or refine the architecture. Thanks!!!
Layers of Project =
Business Objects (BO) = these will map logically to database information to create usable models for the project.
Data Access Objects (DAO) = these will be to the classes used to make the ADO stored proc calls to the database.
Service Objects (SO) = this will be the business rules and validation objects that pass data between the DAO and the Controller
Controller Objects = these are there to gather data from the views and pass data to the views from the SO
Views = these are the UI pages and controls that make up the web site.
* * * * *
So here is where I am stuck...
= The Service Layer....
I am trying to make my Controllers able to get a BO from the SO and then manipulate that throughout the life of the page. But with each ajax call to the controller method, the BO that is passed in is null.
So where is my architecture breaking down?
What do I need to make sure I have in place (codewise) that would allow spring to keep my BO alive throughout the page ajax postbacks?
Originally Posted by Jason
Your post is a little bit confusing. First you say you are creating an MVC webapp. Then you talk about ajax.
What are you doing? Creating an MVC webapp or a "web 2" style single page application that communicates with the server via ajax?
Also, when you say "ajax postback" what do you mean? The term "postback" is ASP.NET specific, and refers to an HTTP POST request sent by a form submission. "Postback" doesn't really mean anything in the ajax or MVC worlds. (sorry to be picky, but I am trying to understand what you are trying to do)
Sure, let me see if I can explain better.
I am creating a MVC 3 Website
SO then the question I guess is... Where does Spring.Net fit into that?, and where can i use it to improve the architecture and code-ability?
Sorry I missed your reply.
I'm working on a similar setup at the moment, except I am using the latest microsoft WebAPI for the "Controllers", which slightly confusingly is part of MVC4.
The way Spring.NET fits into it, is that you can use the DI to wire up your data access layer, service layer, and Controllers. There doesn't appear to be anything wrong with your architecture.
So..... when you say "But with each ajax call to the controller method, the BO that is passed in is null" you must have a bug in your code. Perhaps if you posted the source code to one of your controllers someone might be able to spot it.
Ok, cool! So... is there a tutorial on using Spring.Net DI (direct injection?)
Originally Posted by gusgorman
DI == Dependency injection.
Originally Posted by Jason
This is a pretty good article by Martin Fowler from the early days of DI: http://martinfowler.com/articles/injection.html
The spring.net documentation itself is pretty thorough: http://www.springframework.net/documentation.html
But as for tutorials, I'm sure there are quite a few out there, but I haven't looked at any for years, sorry. The Martin Fowler article is probably a great place to start, although it may be a bit much to digest in one read if you are totally new to the concepts.