Ok, now my code looks like this:

<tr:selectOneChoice label="Start year" value="#{bean.initialValue}"
required="true" valuePassThru="true">
        <tr:forEach var="year" begin="#0" end="10">
                <tr:selectItem label="#{year}" value="#{year}" />
        </tr:forEach>
</tr:selectOneChoice>

the bean.initialValue is set to 1 in the declaration of the member (private
int initialValue = 1;)
but this doesn't help. I get such warning:

2008-09-17 11:08:18
org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleSelectOneRenderer
_getSelectedIndex
WARNING: Could not find selected item matching value "1" in
CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=_idJsp9]

As you might have noticed, the combo-box will store years, so the values
will be greater than 1000. When I put, for example, 2008 as the
initialValue, and iterate from 2008 to 2050, the warning says:
Could not find selected item matching value "2 008" in CoreSelectOneChoice
So it seems that the value is converted from an integer to a string... Maybe
that's the problem? If so, then how to force the selectOneChoice and
selectItem to compare the values as integers?


Richard Yee-3 wrote:
> 
> You should have the value attribute in the selectOneChoice be an EL
> expression that references a field in your backing bean. If you do
> this and set the value of the field to "1" when the bean is created,
> it will be defaulted as you expect. With your current code, there is
> no way of submitting the value of the selectOneChoice.
> 
> -Richard
> 
> On Tue, Sep 9, 2008 at 7:34 AM, tkazmierczak <[EMAIL PROTECTED]>
> wrote:
>>
>> Hello,
>> I've searched half of the Internet, but haven't found an answer to my
>> question.
>>
>> I create a tr:selectOneChoice this way:
>>
>> <tr:selectOneChoice label="Start year" value="1" required="true"
>> valuePassThru="true">
>>        <tr:forEach var="year" begin="0" end="10">
>>                <tr:selectItem label="#{year}" value="#{year}" />
>>        </tr:forEach>
>> </tr:selectOneChoice>
>>
>> and want the resulting HTML combobox to have the value with label "1" set
>> by
>> default, but what I get is that the combobox is set to an "empty" value
>> and
>> I get this error message in the server's output:
>>
>> 2008-09-09 15:54:23
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleSelectOneRenderer
>> _getSelectedIndex
>> WARNING: Could not find selected item matching value "1" in
>> CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=_idJsp9]
>>
>> What is wrong/missing in the code?
>> I'm using Trinidad 1.0.7.
>> --
>> View this message in context:
>> http://www.nabble.com/default-value-in-tr%3AselectOneChoice-tp19393693p19393693.html
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/default-value-in-tr%3AselectOneChoice-tp19393693p19527785.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to