Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

More Spring(MVC) Dumbness

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody.
I am building an application (slowy), the first page has a list of items, when you click on an item it goes to the second page to a details of that item.


I have a Spring Form (SimpleFormController) for the details page, it has its requried backing object, and displays the details quite nicely.

However I would like the details page to also display the list of items. Now I have tried this using the views model like so:



The only problem is, that once this code is in place, the formbacking object no long displays the item details.

JSP looks like:

<div id="left"> is basicly lifted from the item list page, and isnt part of the form, I dont think it should be part of the form either.

So what am I doing wrong? I think it is because I am creating a model, that overwrites the model created by Object formBackingObject(HttpServletRequest request), but I cant see another mothed that would allow me to do what I wish, which is to add an object to the model without destorying the formbacking part of teh controller.

Is there a good/recommanded/"bible" book on creating Spring MVC applications?

Thanks
G
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gavin,

First and foremost please make sure that you don't have a typo within your jsp:



Nevertheless if your __itemModel__ is kind of a __Map__, the code above should definitely work. This because you�re using JSTL, which in turn implements and supports the EL (expression language).
Another elegant solution that you could use as well is to override the __referenceData__ method. This will return a map of beans (name-value pairs), which will be bounded to your page within the page context.

Regards.
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
ah sorry about that, I was "cleaning" the code, describing the problem in generic terms rather then in terms of my application.

Thanks for the advice too, it works like a charm
What is annoying me is, i tried

While waiting for a reply, and couldnt get it to work. just get some error which seemed the data i was trying to put in the model wasnt being put in the model. most annoying, perhaps it was down to operas cache, which is a pain when it comes to CSS.

But it works now,
Thank you
Gavin
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're very welcome Gavin , I'm glad I could help.
 
No more fooling around. Read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic