I have selectOneMenu
like this:
<p:selectOneMenu id="diminui" value="#{naturemb.nature.diminui}" effect="clip">
<f:selectItems itemLabel="#{naturemb.carregarAtributos()}" itemValue="#{naturemb.carregarAtributos()}" />
</p:selectOneMenu>
I want to display the values of my Enum:
package br.com.pokemax.modelo;
public enum Atributos {
HP("HP"), ATTACK("Attack"), DEFENSE("Defense"), SPECIAL_ATTACK("Sp. Attack"), SPECIAL_DEFENSE("Sp. Defense"), SPEED(
"Speed");
private String nome;
private Atributos(String nome) {
this.nome = nome;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
I created a method on the controller like this:
public String carregarAtributos() {
List<Atributos> lista = Arrays.asList(Atributos.values());
for (int i = 0; i < lista.size(); i++) {
return lista.get(i).getNome();
}
return "";
}
But it's not working, can anyone help me?