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

Forward in Spring

 
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to use Forward in Spring 3.0. My scenerio is I receive some data and put it in some Model attribute and forward to another page. Get few more data and try to put in same Model Object and send it to last page. Here I could see the data being retreived only from the last page and leaving rest of the Model fields are Null.

I assume, the ModelAttribute is re-instantiated somewhere in the middle which I fail to understand. Find below the Controller code





Please share your thoughts.
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tweaked a bit of my code in JSP and I was able to get the values in the final page. I created a hidden tag and the value seems to be retained. Otherwise it proceeds as if Null value is specified.

Can someone explain if my understanding is correct.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct to get them back on the model attribute they must be bound to the object on the JSP. So the hidden tag is the correct approach.
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bill, what if my form has more number of fields. creating hidden variables for all these may not be good. is there any way to retain it without hidden fields
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to use a form backing bean which is essentially what this is then it has to be bound to something on the form (if the model attribute is request scoped). In the case it is not something you want shown on the form then hidden fields is typically what you use.

Alternatively you can have a look at the reference docs on the use of the @SessionAttributes annotation. You can also store things on the real HttpSession (you can pass HttpSession in as a method parameter) or you can pass values back an forth as @RequestParams.
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill. Let me look at that.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic