Hi Volker,
The problem also occurrs with itemValue="#{1}".
The solution was change the getter e setter to accept and return Strings:
public String getOpcao() {
return (opcao != null ? opcao.toString() : null);
}
public void setOpcao(String opcao) {
this.opcao = Integer.valueOf(opcao);
}
But, is not there a converter for this case?
Thank you,
Rafael Santini
----- Original Message -----
From: "Volker Weber" <[email protected]>
To: "MyFaces Discussion" <[email protected]>
Sent: Tuesday, July 21, 2009 12:59 PM
Subject: Re: <t:selectOneMenu>: value is not a valid option
Hi Rafael,
your itemValues are Strings, your bean expect Integer.
you can change the getter and setter to accept and return Strings
or try itemValue="#{1}", you may need to change from Integer to Number than.
Regards,
Volker
2009/7/21 SANTINI, Rafael <[email protected]>:
Hi,
I can't figure out why the following code results in "value is not a valid
option":
<h:messages/>
<h:form>
<t:selectOneMenu value="#{bean.opcao}" id="opcao">
<f:selectItem itemLabel="Opção 1" itemValue="1"/>
<f:selectItem itemLabel="Opção 2" itemValue="2"/>
<f:selectItem itemLabel="Opção 3" itemValue="3"/>
</t:selectOneMenu>
<h:message for="opcao"/>
<h:commandButton value="OK"/>
</h:form>
public class Bean {
private Integer opcao;
public Integer getOpcao() {
return opcao;
}
public void setOpcao(Integer opcao) {
this.opcao = opcao;
}
}
Thanks,
Rafael Santini
--
inexso - information exchange solutions GmbH
Bismarckstraße 13 | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX: +49 441 4082 355 | www.inexso.de