Results 1 to 4 of 4

Thread: Spring-js Ajax call to different MVC controllers

  1. #1

    Default Spring-js Ajax call to different MVC controllers

    Hello everyone,

    I'm working on a budgeting web application using Spring Javascript and Spring MVC with annotations. I'm using Apache Tiles2 for the templating.

    My goal is to create a page using the dojo TabContainer. In the TabContainer I will have 5-6 tabs that each reference a different web page (such as budgets, vendors, transactions, etc...). Currently, I have a separate MVC controller set up for each one of these pages.

    The TabContainer resides on a page called Home.jsp.

    I have found the way to get my budget tile to display on the budget tab using Tiles. However, the budgeting data from the database doesn't display. I've figured out that this is because the BudgetController isn't called when the Home.jsp page is loaded...the HomeController is called.

    Now, if I move the BudgetController code into HomeController, the data is displayed.

    My question is this: How can I tell Spring-JS/Ajax to make calls to my various controllers all while on the Home.jsp page? It would be very messy to put logic for the different Controllers all into the HomeController.

    It would be great if someone can give me a solution or at least help point me in the right direction.

    Thanks!!!
    Bill

  2. #2

    Default Any suggestions?

    Would it be bad design to have a single controller (HomeController.java) that made calls to the various budget, vendor, transaction, etc.. service classes?

    I could just have the user navigate to separate web pages (thereby calling the appropriate controllers), but the customer really wants to be able to navigate through the web site using tabs.

    Has anyone out there built a web page/site using Dojo's TabContainer and Spring MVC controllers?

  3. #3
    Join Date
    Jun 2009
    Posts
    23

    Default

    I have no experience with Spring and the Dojo library. Particularly, I don't know to which extend URLs with Dojo are customizable.

    However, regarding separation of concerns, a controller should only consist of logic to obtain a model, choose a view, and pass the posted-back model to validators, reacting on possible binding errors.

    Consider using the Front Controller design pattern.

  4. #4

    Default DispatcherServlet

    Thanks for the response. I did look into the Front Controller pattern and it seems that Spring has in fact implemented that out of the box with the DispatcherServlet which I am using as declared in my web.xml.

    As you may already know, the DispatcherServlet is mapping my web pages to my controllers via the URL (and I'm using annotations for this).

    My problem is that the URL doesn't change when switching between the tabs in the TabContainer. I don't think it's supposed to change, but because it stays as Home.jsp the DispatcherServlet keeps mapping to the HomeController.

    I can set the href attribute of the ContentPanes (which are my tabs) to budget.jsp, vendor.jsp, etc... but when I do this the widgets in the budget.jsp, vendor.jsp, etc... pages do not display. This was "fixed" in the dojox ContentPane but Spring-js doesn't implement the dojox library.

    Any other ideas? Anyone?

Tags for this Thread

Posting Permissions

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