2

I want to reset text field on click of the reset button. How can I do it in JSF?

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
vivek
  • 53
  • 1
  • 2
  • 6

3 Answers3

2

Well, then make an <input type="reset"> and if you have a <h:form> it will work. If you want to clear an individual field, use javascript.

Bozho
  • 572,413
  • 138
  • 1,043
  • 1,132
1

You can reset your form in JSF using

<h:commandButton type="reset" value="Reset" />
1

You can use an action to rest all fields that you want to rest:

<h:commandButton value="Reset" action="#{myBean.reset}" render="formId" />

and

public void rest() {

  setField1(null);
  setList1(null);
  setField2(null);
}
Karthikeyan
  • 7,700
  • 10
  • 46
  • 66