Iterating over messages.properties values

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Iterating over messages.properties values

alex_e
Hi,

is it possible to iterate over some values from the messages.properties?

Eg. when I have the following entries in my messages.properties:

    value.1 = foo
    value.2 = bar
    value.3 = baz

I want to do something like:

    <option th:each="v: #{value}" th:value="${v}" th:text="${v}">values</option>

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Iterating over messages.properties values

Metroids
This post was updated on .
I don't think you can... I mean, I guess you might be able doing hackish things like this:

            <th:block th:each="i: ${#numbers.sequence(1, 100)}"  th:if="${(#messages.msgOrNull('value.' + i) != NULL) AND (#messages.msgOrNull('value.' + (i + 1)) == NULL)}">
                <option th:each="j: ${#numbers.sequence(1, i)}" th:value="${#messages.msg('value.' + j)}" th:text="${#messages.msg('value.' + j)}" />
            </th:block>

but I can't think of any way to do it without hardcoding some upper limits.
Reply | Threaded
Open this post in threaded view
|

Re: Iterating over messages.properties values

alex_e
I worried that there is only a hackish solution.

However, thanks for your reply.