i have a form (registration.jsp) which is associated with a form bean. The bean is in session scope. I need it in the session for various reasons which i wont go into right now. Now everything happens fine and when i submit the page all goes fine.
However, when i come back into the page like suppose on submit i have to go back into home page and have a link to get back into registration.jsp then the form bean that comes into memory is the exact same one as the previous one.
How do i know this, i printed out all the objects in request scope. When i did this i found out that the form bean alone referred to the exact same address irrespective of the round trips that i made to the server.
As a result of this problem, my jsp pages retains all the values and basically i have a refresh problem. Is there a way i can remove the form bean on sucess of the page without putting any more holes into my code
Joined: Aug 20, 2002
org.apache.struts.taglib.html.BEAN::::request:::::::::com.zerodegrees.struts.for ms.auth.RegisterFormBean@3f6843 is what my request parameter prints out when the request for the page is made the first time.
on confirmation of the page i go into the home page again and come back into the registration page and see what it prints again
so it looks like it does not take the form bean out of scope.
Is there a way to do this. Basically every time the page is hit a new instance of form bean should be got for the user.
Please let me know.
Joined: Sep 21, 2003
See u can call the reset method of that form bean explicitly and in that method can reset the values when necessary ...but one thing is that if u reset it then the values wont be available further .........so the bset idea is to keep the required values in session attributes rather than part of the form bean r dont use this formbean for other pages as the data will be persisted and it will display u unnecessary data
Joined: Aug 25, 2004
I had a similar problem and the reset method was not appropriate (can't tell you why right now -- I don't have my books and notes with me), but my solution was to code a utility class which I called ClearForms in which I explicitly set each of the form's elements to "" (empty string). I call the appropriate method (ie, ClearForms.clearApplicantForm) just prior to displaying the form. It works great. If you want more info on why reset didn't work for me, I will be glad to post another reply after reviewing my notes at work tomorrow. Good luck.
Joined: Sep 21, 2003
I will tell u reset will work but the instance of the formbean that u get in ur action class should be correct and the form should be typecasted properly before u call ur reset method
and if u reset the purpose of storing in session will be lost as u neex to populate the data once again