Results 1 to 6 of 6

Thread: Spring.net and MVC

  1. #1
    Join Date
    Jun 2013
    Posts
    3

    Arrow 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 =

    Model Layer
    Business Objects (BO) = these will map logically to database information to create usable models for the project.

    Service Layer
    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

    View Layer
    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?


    Thanks Again!

  2. #2
    Join Date
    Apr 2011
    Posts
    57

    Default

    Quote Originally Posted by Jason View Post
    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.


    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?


    Thanks Again!

    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)

    regards,
    Jordan.

  3. #3
    Join Date
    Jun 2013
    Posts
    3

    Default

    Sure, let me see if I can explain better.

    I am creating a MVC 3 Website

    The website will use javascript, jquery and ajax to get data from the view to the controller

    The jquery ajax POST is the javascript used to take the page data and post it to a specific controller method.


    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?

  4. #4
    Join Date
    Apr 2011
    Posts
    57

    Default

    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.

  5. #5
    Join Date
    Jun 2013
    Posts
    3

    Default

    Quote Originally Posted by gusgorman View Post
    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.
    Ok, cool! So... is there a tutorial on using Spring.Net DI (direct injection?)

  6. #6
    Join Date
    Apr 2011
    Posts
    57

    Default

    Quote Originally Posted by Jason View Post
    Ok, cool! So... is there a tutorial on using Spring.Net DI (direct injection?)
    DI == Dependency injection.

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •