-1

How to blank a text field on click of a button in JSF?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
vivek
  • 53
  • 1
  • 2
  • 6
  • 1
    You've already asked this before: [JSF reset text field](http://stackoverflow.com/questions/4266132/jsf-reset-text-field). You should have edited the question to clarify the requirement more. – BalusC Nov 25 '10 at 11:49

4 Answers4

0

In actionListner you should use

txtField.setText("");
Prasad
  • 1,188
  • 3
  • 11
  • 29
0

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.

Vladimir Ivanov
  • 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
0

----->>> 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";

}

Jimit Tank
  • 1,479
  • 5
  • 19
  • 25
0
<input name="loginname" type="text" value="USERNAME" 
       size="10" onFocus="this.value=''"><br>
akjoshi
  • 15,374
  • 13
  • 103
  • 121
Ahsan
  • 1