Rather than String, try using Long for your accessors.

By default, accessors for literals must either be String or Long or Double.

#{1} is a new Long(1), not a new Integer(1).

Yes, a converter will work automatically, so if you were to provide
#{something that evaluates to an integer}, then everything would work
as you expect.   But the problem is that you're not generating
Integers.

But, again, El returns Longs "#{1}", Strings "1", and Doubles "#{1.1}"
for literals, not Integers or any other type.

So if you had a facelets toInt() method, you could do:
"#{myFunction:toInteger(1)}"

Your other option is to do what Rene suggests and provide a method
that returns SelectItem<Label:String,Value:Integer> select items from
your java code

On Tue, Jul 21, 2009 at 1:04 PM, SANTINI, Rafael<raf...@santini.eti.br> wrote:
> 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" <v.we...@inexso.de>
> To: "MyFaces Discussion" <users@myfaces.apache.org>
> 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 <raf...@santini.eti.br>:
>>
>> 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
>
>

Reply via email to