primefaces : l'autocomplete ne marche pas
salut,
j'utilise netbeans 6.9.1 avec mandriva et je voudrais utiliser le composant autocomplete mais sans succès.
voici mes 2 petits fichiers:
index.xhtml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
Hello from Facelets
<f:view>
<h:form id="form1">
<table>
<tr>
<td>
Ville :
</td>
<td>
<p:autoComplete id="acp_nomVille"
value="#{beanVille.nomchosen}"
completeMethod="#{beanVille.giveNoms}"
selectListener="#{beanVille.itemchanged}"
onSelectUpdate="otx_changements"
></p:autoComplete>
</td>
</tr>
<tr>
<td>
Nombre de changements :
</td>
<td>
<h:outputText id="otx_changements"
value="#{beanVille.indice}"/>
</td>
</tr>
</table>
</h:form>
</f:view>
</h:body>
</html> |
beanVille.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package code;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
/**
*
* @author lolveley
*/
@ManagedBean
public class BeanVille {
protected String nomVille;
public String getNomVille() {
return nomVille;
}
public void setNomVille(String nomVille) {
this.nomVille = nomVille;
}
protected int indice=0;
public int getIndice() {
return indice;
}
public void setIndice(int indice) {
this.indice = indice;
}
protected String nomchosen;
public String getNomchosen() {
return nomchosen;
}
public void setNomchosen(String nomchosen) {
this.nomchosen = nomchosen;
}
public List<String> giveNoms(){
List<String> liste = new ArrayList<String>();
liste.add("Londres");
liste.add("Paris");
liste.add("Mexico");
return liste;
}
public void itemchanged(){
indice++;
}
} |
le code est très simple : à chaque changement de l'autocomplete, l'indice est incrémenté.
mais ça ne marche pas : si je tape quelque chose dans l' inputbox, ça bloque en recherche et la liste des villes ne s'affiche pas.
pouvez-vous m'aider?
olivier.