How to blank a text field on click of a button in JSF?
4 Answers
use f:ajax
Your text field is obviosly binded to some property in backing bean. You can call the method of backing bean, which will null the appropriate property. Specifying the f:ajax tag, you will mention what action should be called and what ui component will be updated.

- 42,730
- 18
- 77
- 103
-
That only works when the OP is using JSF 2.0. The OP didn't mention the JSF version at all. – BalusC Nov 25 '10 at 11:47
----->>> JSPX File
< ice:inputText id="nameId" value="#{createBrandBean.brand.name}" size="30" maxlength="40" tabindex="2" onkeydown="moveFocus(event, 'aliasId')" />
< ice:commandButton value="Save" id="saveButton" action="#{createBrandBean.createBrand}" tabindex="5" styleClass="std-btn" />
--- >> in my createBrandBean.java File
private BrandVO brand; // Create a POJO Object
public String createBrand() {
brand.setName("");
or
brand = new BrandVO();
return "SUCCESS";
}

- 1,479
- 5
- 19
- 25