myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tkazmierczak <>
Subject Re: default value in tr:selectOneChoice
Date Wed, 15 Oct 2008 10:36:59 GMT

I'm using Java 6. But maybe the problem is caused by the fact that the
version of JSF I'm using is 1.1?
Anyway, I cannot upgrade to a higher version. But I've found a solution -
instead of adding the tr:selectItem tags using tr:foreach, I just hardcoded
the list of tr:selectItem tags into the jspx page, with the value attributes
of the tags set just to, for example, value="2008" (so a plain string
instead of EL). Not the neatest solution, but in my case it was acceptable
and what is the most important thing - it works.

Richard Yee-3 wrote:
> I'm guessing that you are using java 5 and the year variable is  
> getting autoboxed to an Integer object in the selectItem.
> I suggest that you create the list of selectItems in the backing bean,  
> have a getter for the list, and use the f:items tag to retrieve the  
> list. Make sure the type you use for you selectOneChoice matches the  
> type of the value in the selectItem. Is. They are both Integers or  
> Strings.
> -R
> Sent from my iPhone
> On Sep 24, 2008, at 1:35 AM, tkazmierczak <>  
> wrote:
>> Richard Yee-3 wrote:
>>> As I mentioned in my prior email, you need to set the value attribute
>>> in the tr:selectOneChoice tag to be an el expression that resolves to
>>> a property in a backing bean.
>>> ie. value="#{myBacking.selectVal}"
>>> selectVal would be defined as a String and would have a getter and
>>> setter. To select a default select item, you would have the value of
>>> selectVal to the desired selected value
>>> ie
>>> String selectVal = "1";
>> It doesn't help. I still get the warning that the value has not been  
>> found
>> in the <tr:selectItem>s.
>> But I've found a workaround (maybe not the neatest, but at least it  
>> works) -
>> I set the first <tr:selectItem> to the same value as the "value"  
>> attribute
>> of <tr:selectOneChoice>, then, I generate the rest of selectItems,  
>> but start
>> the iteration from one year later.
>> -- 
>> View this message in context:
>> Sent from the MyFaces - Users mailing list archive at

View this message in context:
Sent from the MyFaces - Users mailing list archive at

View raw message