wood burning stoves 2.0*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Refreshing or Resetting the fields in jSF" Watch "Refreshing or Resetting the fields in jSF" New topic
Author

Refreshing or Resetting the fields in jSF

Venkata
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

<blah...blah>

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

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
.getViewRoot().getViewId());
context.setViewRoot(viewRoot);
context.renderResponse();



Any ideas , where iam doing wrong?

Thanks
Jeff Nadler
Greenhorn

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.
Venkata
Ranch Hand

Joined: Sep 07, 2007
Posts: 37
Thank you very much for the reply.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Refreshing or Resetting the fields in jSF