views:

812

answers:

3

Hi,

I'm struggling with a little internationalization issue in one of my apps. The story goes like this:

I have a datatable which displays records, and a selectOneMenu in order to select a column of the dataTable to be filtered for. The selectOne is fed with SelectItems which are filled according to the actual locale in the backing bean on DataRefresh time.

Now, when the user changes the locale the contents of the selectOne stay in the old locale until the page is rerendered. This is quite logical and expected.

Of course I want that to change.

So I tried writing an own selectOne which uses selectItems which contain references to languageFile entries in order to be able to change them without rerendering.

Here's what I tried

<select id="j_id5:filterSelector" name="j_id5:filterSelector" size="1"> 
    <c:forEach var="item" items="#{gridBean.filterFields}">
        <option value="#{item.Value}">#{msg[item.Label]}</option>
    </c:forEach>
</select>

Sadly JSF tells me the item does not have a Label or Value property, which I hardly believe. ;)

Does anyone's got an idea how to access thise properties this way?

+1  A: 

It seems to me you should write:

#{item.value}

instead of #{item.Value}, as standard JavaBeans convention is to have getXyz() getter for xyz property.

Also, why don't you provide a valueChangeListener to the UI component for locale selection, and then, inside it, populate the select item labels for that locale. That way you can use standard f:selectItems tag.

javashlook
thx for the answer, I can access the properties now. My d'oh.I agree that a valueChangeListener would be the better wayto go. I'm not perfectly sure how to integrate it into my app.Acually I've got a LanguageSelectioBean which displays two flagswhich do change the locale on click, via commandLinks.--> can command links fire a valueChange event?Secondy my datatable is a component which I use in severallocations in my app. I need to extend it to make it listenfor valueChanges and requery the language files onValueChange, right? thx K
KB22
A: 

I solved the issue with storing the filterfields twice. Once for each language - runtime decission which is rendered. Not a nice one, but it works. Could'nt get the changeListener going...

KB22
A: 

You could also make it so your command links re-render the page so that it automatically does what you need it to. Don't know if this meets your requirements or not. :)

Drew