This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Objects are not staying permanently after JSP is reloaded in next time.

 
Vinod Vijay
Ranch Hand
Posts: 158
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, on my JSP there is a select box which has some objects pre-populated before the screen is displayed to user for his input. Now what is happending when the user submits the form, it performs server side validations using the Spring Validations and in case some issue is found then redirects to same JSP with the error messages to be displayed on JSP. Now this time the pre-populated objects in my dropdown select box are gone, completely blank. Please tell me what is causing this issue and how to make them permanently available on JSP.

here are my codes:-


I'm setting into model using addAttribute() and on JSP retrieving like this:-


First load of JSP, it is coming and on refresh also it is coming but when a page is submitted or actually processed and comes back then it displays nothing.

Thanks
 
Stefan Evans
Bartender
Posts: 1784
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have some code here that adds attributes into the model.
This happens on the default render request.

Does it run through this code when processing this page?
Or is that a different render request?

 
Vinod Vijay
Ranch Hand
Posts: 158
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:You have some code here that adds attributes into the model.
This happens on the default render request.

Does it run through this code when processing this page?
Or is that a different render request?


Hi Stefan,

Yes! this is default render request method which gets called when my jsp is loaded for first time. And when user submits the form, another method Action request gets called. In that method, it checks server side validations and if something goes incorrect then it redirects to this same default render request method.
 
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
most likely you are not getting in that same handler so your model is not getting populated again, set a breakpoint and see. You could also store it as an @SessionAttributes this way it will stay available for you.

See
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/portlet.html#portlet-ann-sessionattrib

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic