si les valeurs sont statiques donc tu peux faire comme suit:
-tu ajoute le code suivant à ta classe.
1 2 3 4 5 6 7 8 9 10
| private String[] elt;
private Option[] eltoptions;
public String[] getElt() {
return elt;
}
public Option[] getEltOptions() {
return eltoptions;
} |
puis tu ajoute cet import:
import com.sun.webui.jsf.model.Option;
tu ajoute ce code dans la méthode init()
1 2 3 4 5 6 7
|
this.elt = new String[]{"1er element", "2eme element ", "3e elt", ...};
this.eltoptions = new Option[this.elt.length];
for (int i = 0; i < this.getElt().length; i++) {
eltoptions[i] = new Option(getElt()[i]);
} |
et enfin tu fais un clic droit sur ton dropdown et tu choisis bind to data
et tu choisis eltOptions de l'anglet bind to an object
si tu dois charger les valeur à partir d'une table c'est encore plus simple
Partager