Two Laptop Bag*
The moose likes JSF and the fly likes Refreshing or Resetting the fields in jSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Refreshing or Resetting the fields in jSF" Watch "Refreshing or Resetting the fields in jSF" New topic

Refreshing or Resetting the fields in jSF

Ranch Hand

Joined: Sep 07, 2007
Posts: 37
Hi ,

I am trying to accomplish clearing the input fields in jsf page.I have a method to be called on clicking the reset button. Here is my code


<div class="formControls"><h:commandButton
value="Search" id="btnSubmit1"
</h:commandButton> <h:commandButton type="button" value="Clear" id="btnReset"
action="#{searchSubscriberBean.resetme}" styleClass="primary"

in my backing bean i have a method resetme().But it looks this method is not being called at all,Since i haven't seen the sys out message aftre clicking the button.

System.out.println("reset>>>>>>>>>>>. ");
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ViewHandler viewHandler = application.getViewHandler();
UIViewRoot viewRoot = viewHandler.createView(context, context

Any ideas , where iam doing wrong?

Jeff Nadler

Joined: Sep 17, 2004
Posts: 1
It's because you are using type="button". If you use type="submit" it will actually submit. When you use type="button" you need to supply a JavaScript onClick event handler to make it actually do anything.
Ranch Hand

Joined: Sep 07, 2007
Posts: 37
Thank you very much for the reply.
I agree. Here's the link:
subject: Refreshing or Resetting the fields in jSF
Similar Threads
Problem in JSF
Setting hidden field attributes through custom viewhandler
Login Problem
why the same URL shows different page in JSF
Creating HtmlCommandButton and HtmlForm in a custom tag