File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Simple form: inputText does not reset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Simple form: inputText does not reset" Watch "Simple form: inputText does not reset" New topic
Author

Simple form: inputText does not reset

Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179
Hi

I am new to JSF and I have got working a simple form, that takes input from user by inputText and after I submit the form - the data will be saved to a database.

The navigation goes like this, that after the form is submitted, the same page and same form will be showed. My problem is, that after the submit, when page is reloaded, the input fields are filled with information I just submitted. I want them to be empty, just like they were from the first request.

I am sure for that, there is a simple solution, but I can't find it.


contacts.jsp:


faces-config.xml:


my.package.ContactForm.java is just simple form bean with action-methods and properties: String firstname, lastname and email.


Thanks.
Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179
Anybody?
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
<td><h:inputText value="#{contactForm.firstname}" id="text1"/>
</td>
here i defined an id for your textfield so that it can be referenced from your backing bean. Now get this component in the action method of your button and clear it.

like

getText1.setValue("");

I am not sure if this is the right approach.

Thanks,
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Originally posted by Rajeev Ravindran:
<td><h:inputText value="#{contactForm.firstname}" id="text1"/>
</td>
here i defined an id for your textfield so that it can be referenced from your backing bean. Now get this component in the action method of your button and clear it.

like

getText1.setValue("");

I am not sure if this is the right approach.

Thanks,

contactForm.setFirstname(null); would do the trick.


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
 
wood burning stoves
 
subject: Simple form: inputText does not reset
 
Similar Threads
Action method is never entered/executed. Please help
inputText tag not working properly
Managed Bean problem
Problems with running JSF in Eclipse 3.1
form and address do not match.