Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2: why object is removed from the ValueStack?

 
Ramesh Babu Essampalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am calling an action class that initialize PersonDTO object in its execute method. This PersonDTO object have getter-setter methods in the action class. I am able to retrieve the value of PersonDTO in success.jsp page using ValueStack. but, on click of submit button in the success.jsp page, i am getting null value for PersonDTO object in the action class. value of PersonDTO object is stored into ValueStack then why its getting null? and how to resolve it.

to clarify my query, here is the action class:




success.jsp:



to get the value of PersonDTO in the action class on click of update button; i added a person bean in success.jsp, but it does not work:



i also tried putting a hidden tag, but it does not work either:



please help me in keeping person object into the valuestack.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because a form submission is a new request, hence a new value stack.
 
Ramesh Babu Essampalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you david. then copying the person object into session object is the best way. or it there any better approach provided by struts2?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's certainly an option, although depending on your expected workload it might not be the absolute best approach. Other approaches could be to re-look up the object; if caching has been implemented it probably wouldn't require another trip to the database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic