Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Form Beans

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok here goes another problem with form beans.

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

 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

org.apache.struts.taglib.html.BEAN::::request:::::::::com.zerodegrees.struts.for
ms.auth.RegisterFormBean@3f6843

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.

Thanks

 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi charu

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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi maria

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic