• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forward in Spring

 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • 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
Flex Oracle Spring
  • 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.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 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
Flex Oracle Spring
  • 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 IntelliJ IDE Linux Mac OS X Spring
  • 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
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill. Let me look at that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic