2

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
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
  • 588,226
  • 146
  • 1,060
  • 1,140
1

You can reset your form in JSF using

<h:commandButton type="reset" value="Reset" />
Adheep
  • 1,585
  • 1
  • 14
  • 27
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);
}
seenukarthi
  • 8,241
  • 10
  • 47
  • 68