File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Form Reset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Form Reset" Watch "Form Reset" New topic

Form Reset

Luv Bhatia

Joined: Apr 01, 2004
Posts: 16
I am using Struts for my application and have a simple form for user information.AfterI submiting this form,when i come back to the same page, all form elements are filled with previously submiteed value.It seems that the form is not refereshing its value.
Any Advice,
Dave Knipp
Ranch Hand

Joined: Oct 14, 2003
Posts: 146
what scope are you putting the form in? session? If you keep the form in the session those values will be persisted as long as the user is logged in. Try putting it in the request. In your action mapping, just put scope="request".
If that doesnt solve it then can you provide more details and we can see what the problem is?

SCJP 1.4, SCJD 1.4, SCWCD 1.3, SCBCD 1.3, IBM Certified Solution Developer -WebSphere Studio V5.0
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

If you need the form in the session, you can write a reset method in the form that resets all the values to null/empty.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Anand Gondhiya
Ranch Hand

Joined: Feb 24, 2004
Posts: 155
Dave ,
in Action Mapping scope is request. still it doesn't reset the form

I already have javascript function "resetForm()" which would reset the form values to null (or default)

i.e I have two methods
1.overridden reset() in subclass of ActionForm
2.resetForm() function in javascript

the my goal is still not accomplished !!

waiting for replies
thank you in advance
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

Are you using the browser's back button by any chance? If so, the values are cached on the browser and the request is never hitting the server.
I agree. Here's the link:
subject: Form Reset
It's not a secret anymore!