Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to reset the form?

vinay kurudi
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing some problem while trying to reset the form.
I am using convertors and validators on the same form elements so I have enabled the "immediate" property of reset button to "true" to avoid the validation process, and in backing bean I am setting the field values but the new values are not getting reflefted in front view. As I can see there is no request made to get the new values from backing bean.

Here are the code snippets:

1. Front view - facelet


b. Reset button :

2. Backing bean -



3. Web.xml

4. Server.xml file of Tomcat 6.0

I tried to use Ajax push to forcefully update the front view values but I am getting this error:

do you have any another way for configuring the web.xml and server.xml in tomcat6.o

I know one way to rest the form and that is, to have binding for all the form fileds and call the submittevValue of UIComponent in reset method on backing bean, but my form contains a lot of fields so I want to avoid doing form reset in that way.
It will be helpful if you guys can suggest me any other way to reset the form.
Thanks in advance.

Tim Holloway
Saloon Keeper
Posts: 18325
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many times - especially in JSF - people start with a complicated solution for a simple problem. I'm going to suggest the simple solutions. They may not be sufficient, but I'd have to print out your stuff and look at it on paper to be sure and it's too early in the morning. Try these, and if they don't work, we can do something more complex.

The simplest approach of all is do nothing. That's right. Nothing att all. If you're using a true Reset button, there's not a thing you normally should or could do.

HTML defines a Reset button as a button of type "reset". It's essentially just like a button of type "submit" except that where "submit" gathers up the form data and sends it to the server, "reset" never talks to the server at all. In fact, all "reset" does is cause the browser to restore the form values to whatever they were when the page was loaded.

The JSF reset control simply generates an HTML reset button, so the same is true for JSF.

Next up is what you'd do if you'd already committed data to the server. For this, the solution is to keep the bean initialization code separate from the bean's constructor. Example:

You can simply have an action process invoke init() if you need to discard changes and reset the form.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic