JSF reset text field [duplicate]

2019-07-22 16:12发布

This question already has an answer here:

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

标签: jsf
3条回答
疯言疯语
2楼-- · 2019-07-22 16:27

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.

查看更多
你好瞎i
3楼-- · 2019-07-22 16:39

You can reset your form in JSF using

<h:commandButton type="reset" value="Reset" />
查看更多
Fickle 薄情
4楼-- · 2019-07-22 16:40

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);
}
查看更多
登录 后发表回答