Results 1 to 4 of 4

Thread: normal and detail view, how to solve this with spring?

  1. #1
    Join Date
    Sep 2005
    Posts
    15

    Default normal and detail view, how to solve this with spring?

    Hi, i have a web application with a product catalog page. Right now i want t to bring users the posibility of choice between a normal view (products are show inside a list) and detail view (products are shows with image, short description, etc). My question is ?. What is the best option to solve this?. In this situation, user click to select a view and have the responsabilty for selection of jsp?. Maybe with one jsp can i solve this situation?

    Thanks
    Danny

  2. #2
    Join Date
    Dec 2004
    Location
    Bucuresti, Romania
    Posts
    72

    Default

    I think you need 2 different model/controller/view tuples:
    1. Model: a list of Product object, controller ProductListController calls a service which returns the list of Produc objects, View: productList.jsp which displays the list of products
    2. Mode: a single Product object: ProductController: calls a service which returns a PRoduct objec for a given id, View: product.jsp: displays a single product with all the details

  3. #3
    Join Date
    Sep 2005
    Posts
    15

    Default

    Hi Croco, thank for your answer. The second option detail only a product and your data. Really i need the same product list that first option, but with another web desing (showing image, description, price). The problem is, how to implement to diferent desing views with the same product list.

    Thank
    Danny

  4. #4
    Join Date
    Aug 2005
    Location
    München, Germany
    Posts
    24

    Default

    If it's really only the views that are different, then there is an elegant way to solve your problem:

    - Define a model that contains everything that both of those views might want to display.

    - Define two different JSPs.

    - Either let both JSPs send the same URL when they are posted, or link both URLs to the same controller in your URL mapping.

    - Somehow, the user must have indicated which view he wants to see next. Depending on that input (e.g. a button), set a variable viewToFollow containing the appropriate view. When returning a ModelAndView, the controller just returns this variable for the view.

    If, however, the functionality offered to the user differs between those views, then this approach, while still possible, will lead to a controller that has to ask all the time from which view the request came, and what is contained in the command. I would then prefer two controllers, each specialized on a view.

    Multi-action controllers might be another solution, but I have no practical experience with them.

Similar Threads

  1. Replies: 5
    Last Post: Aug 9th, 2008, 05:30 AM

Posting Permissions

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