You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jakob Korherr <ja...@gmail.com> on 2009/12/16 14:12:32 UTC
Re: This is a bug?
Hi Rafael,
You have to use String instead of Character for the option property in Bean,
because <f:selectItem> generates a String value for itemValue="A".
If you really want to use a Character though, you have to make sure that
<f:selectItem> generates values of type Character and also provide a
Character-converter for <h:selectOneMenu>.
Regards,
Jakob Korherr
2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
> Hi,
>
> I can't figure out why "value is not valid" is throwed. I'm using
> myfaces-core-1.1.7.
>
> Test case:
>
> <h:form>
> <h:outputText value="Option:"/>
> <h:selectOneMenu value="#{bean.option}" id="option">
> <f:selectItem itemValue="A" itemLabel="A"/>
> <f:selectItem itemValue="B" itemLabel="B"/>
> <f:selectItem itemValue="C" itemLabel="C"/>
> </h:selectOneMenu>
> <h:message for="option"/>
> <h:commandButton value="Test" action="#{bean.test}"/>
> </h:form>
>
> public class Bean {
>
> private Character option = 'A';
>
> public Character getOption() {
> return option;
> }
>
> public void setOption(Character option) {
> this.option = option;
> }
>
> public void test() {
> System.out.println(option);
> }
>
> }
>
> This is a bug? What I'm missing?
>
> Thanks,
>
> Rafael Santini
>
Re: This is a bug?
Posted by Mike Kienenberger <mk...@gmail.com>.
You can only generate literal types of Long, Double, or String in EL.
The only way I know to do this in EL is to provide a facelets
conversion function like
itemValue="#{myFunctions:characterToString('A')}". I don't know if a
character-to-String converter for the component would work in this
case, but you could try that like Jakob suggested.
On Wed, Dec 16, 2009 at 9:29 AM, SANTINI, Rafael <ra...@santini.eti.br> wrote:
> Hi Jakob,
>
> My domain class uses Character.
>
> How can I generate values of type Character in <f:selectItem>?
>
> Thanks,
>
> Rafael Santini
>
> ----- Original Message ----- From: "Jakob Korherr" <ja...@gmail.com>
> To: "MyFaces Discussion" <us...@myfaces.apache.org>
> Cc: "SANTINI Rafael" <ra...@santini.eti.br>
> Sent: Wednesday, December 16, 2009 10:12 AM
> Subject: Re: This is a bug?
>
>
>> Hi Rafael,
>>
>> You have to use String instead of Character for the option property in
>> Bean,
>> because <f:selectItem> generates a String value for itemValue="A".
>>
>> If you really want to use a Character though, you have to make sure that
>> <f:selectItem> generates values of type Character and also provide a
>> Character-converter for <h:selectOneMenu>.
>>
>> Regards,
>>
>> Jakob Korherr
>>
>>
>> 2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
>>
>>> Hi,
>>>
>>> I can't figure out why "value is not valid" is throwed. I'm using
>>> myfaces-core-1.1.7.
>>>
>>> Test case:
>>>
>>> <h:form>
>>> <h:outputText value="Option:"/>
>>> <h:selectOneMenu value="#{bean.option}" id="option">
>>> <f:selectItem itemValue="A" itemLabel="A"/>
>>> <f:selectItem itemValue="B" itemLabel="B"/>
>>> <f:selectItem itemValue="C" itemLabel="C"/>
>>> </h:selectOneMenu>
>>> <h:message for="option"/>
>>> <h:commandButton value="Test" action="#{bean.test}"/>
>>> </h:form>
>>>
>>> public class Bean {
>>>
>>> private Character option = 'A';
>>>
>>> public Character getOption() {
>>> return option;
>>> }
>>>
>>> public void setOption(Character option) {
>>> this.option = option;
>>> }
>>>
>>> public void test() {
>>> System.out.println(option);
>>> }
>>>
>>> }
>>>
>>> This is a bug? What I'm missing?
>>>
>>> Thanks,
>>>
>>> Rafael Santini
>>>
>>
>
>
Re: This is a bug?
Posted by "SANTINI, Rafael" <ra...@santini.eti.br>.
Hi Jakob,
My domain class uses Character.
How can I generate values of type Character in <f:selectItem>?
Thanks,
Rafael Santini
----- Original Message -----
From: "Jakob Korherr" <ja...@gmail.com>
To: "MyFaces Discussion" <us...@myfaces.apache.org>
Cc: "SANTINI Rafael" <ra...@santini.eti.br>
Sent: Wednesday, December 16, 2009 10:12 AM
Subject: Re: This is a bug?
> Hi Rafael,
>
> You have to use String instead of Character for the option property in
> Bean,
> because <f:selectItem> generates a String value for itemValue="A".
>
> If you really want to use a Character though, you have to make sure that
> <f:selectItem> generates values of type Character and also provide a
> Character-converter for <h:selectOneMenu>.
>
> Regards,
>
> Jakob Korherr
>
>
> 2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
>
>> Hi,
>>
>> I can't figure out why "value is not valid" is throwed. I'm using
>> myfaces-core-1.1.7.
>>
>> Test case:
>>
>> <h:form>
>> <h:outputText value="Option:"/>
>> <h:selectOneMenu value="#{bean.option}" id="option">
>> <f:selectItem itemValue="A" itemLabel="A"/>
>> <f:selectItem itemValue="B" itemLabel="B"/>
>> <f:selectItem itemValue="C" itemLabel="C"/>
>> </h:selectOneMenu>
>> <h:message for="option"/>
>> <h:commandButton value="Test" action="#{bean.test}"/>
>> </h:form>
>>
>> public class Bean {
>>
>> private Character option = 'A';
>>
>> public Character getOption() {
>> return option;
>> }
>>
>> public void setOption(Character option) {
>> this.option = option;
>> }
>>
>> public void test() {
>> System.out.println(option);
>> }
>>
>> }
>>
>> This is a bug? What I'm missing?
>>
>> Thanks,
>>
>> Rafael Santini
>>
>
Re: This is a bug?
Posted by Jakob Korherr <ja...@gmail.com>.
Hi Rafael,
OK, sorry. I supposed it would work in MyFaces 1.1 too..
Then the best way to get Character values is using <f:selectItems
value="#{bean.characterItems}"> with this method in your Bean:
public List<SelectItem> getCharacterItems()
{
List<SelectItem> l = new ArrayList<SelectItem>();
l.add(new SelectItem('A', "A"));
l.add(new SelectItem('B', "B"));
l.add(new SelectItem('C', "C"));
return l;
}
Regards,
Jakob
2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
> Hi Jakob,
>
> I have tried like you suggest, but does not works.
>
>
> <f:selectItem itemValue="#{'A'}" itemLabel="A"/>
> <f:selectItem itemValue="#{'B'}" itemLabel="B"/>
> <f:selectItem itemValue="#{'C'}" itemLabel="C"/>
>
> Thanks,
>
> Rafael Santini
>
> ----- Original Message ----- From: "Jakob Korherr" <
> jakob.korherr@gmail.com>
> To: "MyFaces Discussion" <us...@myfaces.apache.org>
> Cc: "SANTINI Rafael" <ra...@santini.eti.br>
> Sent: Wednesday, December 16, 2009 10:38 AM
>
> Subject: Re: This is a bug?
>
>
> Hi,
>>
>> +1 for your suggestion, mike!
>>
>> To generate a Character value in <f:selectItem> use #{'A'} for 'A' and
>> #{'B'} for 'B' respectively.
>> I just tried this (although with JSF 2.0), but I think it also works on
>> 1.1.
>>
>> Regards,
>>
>> Jakob
>>
>> 2009/12/16 Mike Kienenberger <mk...@gmail.com>
>>
>> This question pops up fairly often, and it's always a programming
>>> error. Maybe we should change the error text to include the type
>>> expected and the actual type found?
>>>
>>> On Wed, Dec 16, 2009 at 8:12 AM, Jakob Korherr <ja...@gmail.com>
>>> wrote:
>>> > Hi Rafael,
>>> >
>>> > You have to use String instead of Character for the option property in
>>> Bean,
>>> > because <f:selectItem> generates a String value for itemValue="A".
>>> >
>>> > If you really want to use a Character though, you have to make sure >
>>> that
>>> > <f:selectItem> generates values of type Character and also provide a
>>> > Character-converter for <h:selectOneMenu>.
>>> >
>>> > Regards,
>>> >
>>> > Jakob Korherr
>>> >
>>> >
>>> > 2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
>>> >
>>> >> Hi,
>>> >>
>>> >> I can't figure out why "value is not valid" is throwed. I'm using
>>> >> myfaces-core-1.1.7.
>>> >>
>>> >> Test case:
>>> >>
>>> >> <h:form>
>>> >> <h:outputText value="Option:"/>
>>> >> <h:selectOneMenu value="#{bean.option}" id="option">
>>> >> <f:selectItem itemValue="A" itemLabel="A"/>
>>> >> <f:selectItem itemValue="B" itemLabel="B"/>
>>> >> <f:selectItem itemValue="C" itemLabel="C"/>
>>> >> </h:selectOneMenu>
>>> >> <h:message for="option"/>
>>> >> <h:commandButton value="Test" action="#{bean.test}"/>
>>> >> </h:form>
>>> >>
>>> >> public class Bean {
>>> >>
>>> >> private Character option = 'A';
>>> >>
>>> >> public Character getOption() {
>>> >> return option;
>>> >> }
>>> >>
>>> >> public void setOption(Character option) {
>>> >> this.option = option;
>>> >> }
>>> >>
>>> >> public void test() {
>>> >> System.out.println(option);
>>> >> }
>>> >>
>>> >> }
>>> >>
>>> >> This is a bug? What I'm missing?
>>> >>
>>> >> Thanks,
>>> >>
>>> >> Rafael Santini
>>> >>
>>> >
>>>
>>>
>>
>
Re: This is a bug?
Posted by "SANTINI, Rafael" <ra...@santini.eti.br>.
Hi Jakob,
I have tried like you suggest, but does not works.
<f:selectItem itemValue="#{'A'}" itemLabel="A"/>
<f:selectItem itemValue="#{'B'}" itemLabel="B"/>
<f:selectItem itemValue="#{'C'}" itemLabel="C"/>
Thanks,
Rafael Santini
----- Original Message -----
From: "Jakob Korherr" <ja...@gmail.com>
To: "MyFaces Discussion" <us...@myfaces.apache.org>
Cc: "SANTINI Rafael" <ra...@santini.eti.br>
Sent: Wednesday, December 16, 2009 10:38 AM
Subject: Re: This is a bug?
> Hi,
>
> +1 for your suggestion, mike!
>
> To generate a Character value in <f:selectItem> use #{'A'} for 'A' and
> #{'B'} for 'B' respectively.
> I just tried this (although with JSF 2.0), but I think it also works on
> 1.1.
>
> Regards,
>
> Jakob
>
> 2009/12/16 Mike Kienenberger <mk...@gmail.com>
>
>> This question pops up fairly often, and it's always a programming
>> error. Maybe we should change the error text to include the type
>> expected and the actual type found?
>>
>> On Wed, Dec 16, 2009 at 8:12 AM, Jakob Korherr <ja...@gmail.com>
>> wrote:
>> > Hi Rafael,
>> >
>> > You have to use String instead of Character for the option property in
>> Bean,
>> > because <f:selectItem> generates a String value for itemValue="A".
>> >
>> > If you really want to use a Character though, you have to make sure
>> > that
>> > <f:selectItem> generates values of type Character and also provide a
>> > Character-converter for <h:selectOneMenu>.
>> >
>> > Regards,
>> >
>> > Jakob Korherr
>> >
>> >
>> > 2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
>> >
>> >> Hi,
>> >>
>> >> I can't figure out why "value is not valid" is throwed. I'm using
>> >> myfaces-core-1.1.7.
>> >>
>> >> Test case:
>> >>
>> >> <h:form>
>> >> <h:outputText value="Option:"/>
>> >> <h:selectOneMenu value="#{bean.option}" id="option">
>> >> <f:selectItem itemValue="A" itemLabel="A"/>
>> >> <f:selectItem itemValue="B" itemLabel="B"/>
>> >> <f:selectItem itemValue="C" itemLabel="C"/>
>> >> </h:selectOneMenu>
>> >> <h:message for="option"/>
>> >> <h:commandButton value="Test" action="#{bean.test}"/>
>> >> </h:form>
>> >>
>> >> public class Bean {
>> >>
>> >> private Character option = 'A';
>> >>
>> >> public Character getOption() {
>> >> return option;
>> >> }
>> >>
>> >> public void setOption(Character option) {
>> >> this.option = option;
>> >> }
>> >>
>> >> public void test() {
>> >> System.out.println(option);
>> >> }
>> >>
>> >> }
>> >>
>> >> This is a bug? What I'm missing?
>> >>
>> >> Thanks,
>> >>
>> >> Rafael Santini
>> >>
>> >
>>
>
Re: This is a bug?
Posted by Jakob Korherr <ja...@gmail.com>.
Hi,
+1 for your suggestion, mike!
To generate a Character value in <f:selectItem> use #{'A'} for 'A' and
#{'B'} for 'B' respectively.
I just tried this (although with JSF 2.0), but I think it also works on 1.1.
Regards,
Jakob
2009/12/16 Mike Kienenberger <mk...@gmail.com>
> This question pops up fairly often, and it's always a programming
> error. Maybe we should change the error text to include the type
> expected and the actual type found?
>
> On Wed, Dec 16, 2009 at 8:12 AM, Jakob Korherr <ja...@gmail.com>
> wrote:
> > Hi Rafael,
> >
> > You have to use String instead of Character for the option property in
> Bean,
> > because <f:selectItem> generates a String value for itemValue="A".
> >
> > If you really want to use a Character though, you have to make sure that
> > <f:selectItem> generates values of type Character and also provide a
> > Character-converter for <h:selectOneMenu>.
> >
> > Regards,
> >
> > Jakob Korherr
> >
> >
> > 2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
> >
> >> Hi,
> >>
> >> I can't figure out why "value is not valid" is throwed. I'm using
> >> myfaces-core-1.1.7.
> >>
> >> Test case:
> >>
> >> <h:form>
> >> <h:outputText value="Option:"/>
> >> <h:selectOneMenu value="#{bean.option}" id="option">
> >> <f:selectItem itemValue="A" itemLabel="A"/>
> >> <f:selectItem itemValue="B" itemLabel="B"/>
> >> <f:selectItem itemValue="C" itemLabel="C"/>
> >> </h:selectOneMenu>
> >> <h:message for="option"/>
> >> <h:commandButton value="Test" action="#{bean.test}"/>
> >> </h:form>
> >>
> >> public class Bean {
> >>
> >> private Character option = 'A';
> >>
> >> public Character getOption() {
> >> return option;
> >> }
> >>
> >> public void setOption(Character option) {
> >> this.option = option;
> >> }
> >>
> >> public void test() {
> >> System.out.println(option);
> >> }
> >>
> >> }
> >>
> >> This is a bug? What I'm missing?
> >>
> >> Thanks,
> >>
> >> Rafael Santini
> >>
> >
>
Re: This is a bug?
Posted by "SANTINI, Rafael" <ra...@santini.eti.br>.
Hi Mike,
The test case works with Sun RI 1.2. So, I think that it is a bug.
Thanks,
Rafael Santini
----- Original Message -----
From: "Mike Kienenberger" <mk...@gmail.com>
To: "MyFaces Discussion" <us...@myfaces.apache.org>
Cc: "SANTINI Rafael" <ra...@santini.eti.br>
Sent: Wednesday, December 16, 2009 10:20 AM
Subject: Re: This is a bug?
This question pops up fairly often, and it's always a programming
error. Maybe we should change the error text to include the type
expected and the actual type found?
On Wed, Dec 16, 2009 at 8:12 AM, Jakob Korherr <ja...@gmail.com>
wrote:
> Hi Rafael,
>
> You have to use String instead of Character for the option property in
> Bean,
> because <f:selectItem> generates a String value for itemValue="A".
>
> If you really want to use a Character though, you have to make sure that
> <f:selectItem> generates values of type Character and also provide a
> Character-converter for <h:selectOneMenu>.
>
> Regards,
>
> Jakob Korherr
>
>
> 2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
>
>> Hi,
>>
>> I can't figure out why "value is not valid" is throwed. I'm using
>> myfaces-core-1.1.7.
>>
>> Test case:
>>
>> <h:form>
>> <h:outputText value="Option:"/>
>> <h:selectOneMenu value="#{bean.option}" id="option">
>> <f:selectItem itemValue="A" itemLabel="A"/>
>> <f:selectItem itemValue="B" itemLabel="B"/>
>> <f:selectItem itemValue="C" itemLabel="C"/>
>> </h:selectOneMenu>
>> <h:message for="option"/>
>> <h:commandButton value="Test" action="#{bean.test}"/>
>> </h:form>
>>
>> public class Bean {
>>
>> private Character option = 'A';
>>
>> public Character getOption() {
>> return option;
>> }
>>
>> public void setOption(Character option) {
>> this.option = option;
>> }
>>
>> public void test() {
>> System.out.println(option);
>> }
>>
>> }
>>
>> This is a bug? What I'm missing?
>>
>> Thanks,
>>
>> Rafael Santini
>>
>
Re: This is a bug?
Posted by Mike Kienenberger <mk...@gmail.com>.
This question pops up fairly often, and it's always a programming
error. Maybe we should change the error text to include the type
expected and the actual type found?
On Wed, Dec 16, 2009 at 8:12 AM, Jakob Korherr <ja...@gmail.com> wrote:
> Hi Rafael,
>
> You have to use String instead of Character for the option property in Bean,
> because <f:selectItem> generates a String value for itemValue="A".
>
> If you really want to use a Character though, you have to make sure that
> <f:selectItem> generates values of type Character and also provide a
> Character-converter for <h:selectOneMenu>.
>
> Regards,
>
> Jakob Korherr
>
>
> 2009/12/16 SANTINI, Rafael <ra...@santini.eti.br>
>
>> Hi,
>>
>> I can't figure out why "value is not valid" is throwed. I'm using
>> myfaces-core-1.1.7.
>>
>> Test case:
>>
>> <h:form>
>> <h:outputText value="Option:"/>
>> <h:selectOneMenu value="#{bean.option}" id="option">
>> <f:selectItem itemValue="A" itemLabel="A"/>
>> <f:selectItem itemValue="B" itemLabel="B"/>
>> <f:selectItem itemValue="C" itemLabel="C"/>
>> </h:selectOneMenu>
>> <h:message for="option"/>
>> <h:commandButton value="Test" action="#{bean.test}"/>
>> </h:form>
>>
>> public class Bean {
>>
>> private Character option = 'A';
>>
>> public Character getOption() {
>> return option;
>> }
>>
>> public void setOption(Character option) {
>> this.option = option;
>> }
>>
>> public void test() {
>> System.out.println(option);
>> }
>>
>> }
>>
>> This is a bug? What I'm missing?
>>
>> Thanks,
>>
>> Rafael Santini
>>
>