Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refreshing or Resetting the fields in jSF

 
Venkata
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic