Meaningless Drivel is fun!
The moose likes Struts and the fly likes How to reset form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to reset form" Watch "How to reset form" New topic

How to reset form

Gilbert johnson
Ranch Hand

Joined: Jul 10, 2005
Posts: 45
Hi Fellas

I am using the normal ActionForm class.

This is the design flow of how it is setup.

There is a link on the homepage. When this link is clicked, the POPULATE_FORM_ACTION class is called which prepopulates the drop down menus etc of the form.

Now this form has two buttons, the submit and the reset. When I click the reset button, I want the same action class (POPULATE_FORM_ACTION) to be called which will show the form with default values and all the values entered by the user should be cleared.

But I am not able to do this. The values entered by the user are not cleared.

I was told to change the scope to request - but it has to be session for this project. I have a reset method in which i initialize all fields to null. But that doesnt help either.

I am sure its a very simple problem cos every form does have a submit and reset functionality - but I dont know why i'm having problems

Adam Kreiss
Ranch Hand

Joined: Sep 12, 2005
Posts: 35
Are you using <html:reset ... /> for the reset button? I know that is usually my problem when buttons are not working as expected.
Gilbert johnson
Ranch Hand

Joined: Jul 10, 2005
Posts: 45

I tried html:reset button but the weird thing is nothing happens when u click on that button . I mean even the page does not get submitted and the button is inside the form tag - so i'm not sure why that happens....

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

You don't want html:reset for what you're doing. html:reset won't submit the form because it performs a browser functionality of resetting values to what they loaded as. You need a regular old submit button.

A good workman is known by his tools.
I agree. Here's the link:
subject: How to reset form
It's not a secret anymore!