views:

173

answers:

2

The following doesn't work as I'd hoped:

<ul>
    <ui:repeat var="i" value="#{fn:split('1,2,3,4', ',')}">
        <li>
            <h:outputText value="1.2345">
                <f:convertNumber
                        minFractionDigits="#{i}"
                        maxFractionDigits="#{i}" />
            </h:outputText>
        </li>
    </ui:repeat>
</ul>

I was hoping to see:

  • 1.2
  • 1.23
  • 1.234
  • 1.2345

Instead I see:

  • 1
  • 1
  • 1
  • 1

What am I missing? My guess is that the converter is initialised when the Facelet is initially loaded, before the run-time looping occurs. Is there a way around this?

My real use-case involves a RichFaces rich:dataTable component instead of a ui:repeat, but the gist is the same.

+1  A: 

It seems not to work indeed. Even if you use <h:outputText value="#{1.2345}">, which is more correct.

I guess, if you need this, you will have to prepare the output in the managed bean.

Bozho
A: 

I have the same problem. It doesn't work with a4j:repeat too. It works using c:forEach but this kind of iterator is giving me other problems and I don't want to use it. If you use, in your f:convertNumber, an object from the managed bean it works, but I only need to get the attribute from the object of the list that i'm looping.

Can anyone help?

Alv21
Welcome at Stackoverflow! There is one little problem: you've posted a question as an answer! If you have a question, please use the `Ask Question` button at the right top, not the `Post Your Answer` button at the bottom :) Feel free to include links to questions you found in search, but didn't help you much.
BalusC