JSP Form data lost while back to same Action (struts 2)
Abhi Roy
Greenhorn
Joined: Jun 23, 2009
Posts: 22
posted
0
Hi,
I have to action classes, say Test1 and Test 2 and two jsp pages,say jsp1 and jsp2, while jsp1 is related to Test1 and jsp2 is related to Test2. And the page flow is like , first the user will enter some data in jsp1 and click on next to go to the next page(jsp2) and also we have to display some of the fields entered injsp1. So I have extended Test2 to Test1, so that Test2 will contains all the commons fields and respective setters and getters.
As expected, on click on the next button, the data the jsp1 data is getting dispalyed in jsp2.Now while I'm trying to post the data from jsp2 and as a result users are reditected to the same page , jsp2, all the fields(inherited from Test1) are vanising.
Keep the list in session or application context, regenerate the list, assume your persistence solution has reasonable caching, etc.
Abhi Roy
Greenhorn
Joined: Jun 23, 2009
Posts: 22
posted
0
Dear David,
Thanks for the solution, but in that case I beleive session will be overloaded. I want to keep this one as the last defence.I have just tried with a small PoC,
here is the code
You're not providing enough information to help. If you don't submit a userId or have some other means of getting it (hidden form field, etc.) then yes, it will print null--it's not initialized.
Abhi Roy
Greenhorn
Joined: Jun 23, 2009
Posts: 22
posted
0
ok...let me try in that way....thanks for your response....
Haravallabhan Jn
Greenhorn
Joined: Aug 10, 2009
Posts: 1
posted
0
Abhi Roy wrote:ok...let me try in that way....thanks for your response....
use getUserid instead of this,userid and remove setUserid. You are setting the userid to null here. On submit you should get the value by using getUserid