Blank a text field on click of a button
How to blank a text field on click of开发者_JAVA百科 a button in JSF?
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.
----->>> 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";
}
<input name="loginname" type="text" value="USERNAME"
size="10" onFocus="this.value=''"><br>
In actionListner you should use
txtField.setText("");
精彩评论