Java Mailing List Archive

http://www.junlu.com/

Home » users.myfaces »

Re: default value in tr:selectOneChoice

Richard Yee

2008-09-24

Replies: Find Java Web Hosting

Author LoginPost Reply
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 <T.Kazmierczak@(protected)>
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: http://www.nabble.com/default-value-in-tr%3AselectOneChoice-tp19393693p19644376.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
©2008 junlu.com - Jax Systems, LLC, U.S.A.