Comment faire pour vider un champ de texte sur un clic sur un bouton dans JSF?Vider un champ de texte en cliquant sur un bouton
Répondre
utilisation f:ajax
Votre champ de texte est obviosly binded à une propriété dans la sauvegarde de haricots. Vous pouvez appeler la méthode de bean backing, qui annulera la propriété appropriée. En spécifiant la balise f: ajax, vous indiquerez quelle action doit être appelée et quel composant ui sera mis à jour.
Cela ne fonctionne que lorsque l'OP utilise JSF 2.0. L'OP n'a pas mentionné la version JSF du tout. – BalusC
----- >>> JSPX Fichier
< glace: inputText id = "nameId" value = "# {} createBrandBean.brand.name" size = "30" maxlength = "40 "tabindex =" 2" onkeydown = "MoveFocus (événement, 'aliasId')" />
< glace: commandButton value = "Enregistrer" id = "saveButton" action = "# {} createBrandBean.createBrand "tabindex =" 5 "styleClass =" std-btn " />
--- >> dans mon fichier createBrandBean.java
marque privée BrandVO; // Création d'un objet POJO
public String createBrand() {
brand.setName ("");
ou
marque = nouveau BrandVO();
retourner "SUCCESS";
}
<input name="loginname" type="text" value="USERNAME"
size="10" onFocus="this.value=''"><br>
Dans actionListner vous devez utiliser
txtField.setText("");
Vous avez déjà demandé auparavant: [JSF reset champ texte] (http://stackoverflow.com/questions/4266132/ jsf-reset-text-field). Vous devriez avoir édité la question pour clarifier davantage l'exigence. – BalusC