I tried the ResourceBundle suggestion made by Martin and it works really well.

ItemFormats.properties (placed in /WEB-INF/classes folder) file has :
formatXFirst = {0} {1} {2}
formatZFirst = {2} {0} {1}

And in the JSP I have:

<fmt:setBundle basename="ItemFormats" var="itemOrder"/>

followed by setting a key variable to hold either formatXFirst and formatZFirst

and in the single loop:

                <fmt:message key="${formatKey}" bundle="${itemOrder}">
                    <fmt:param value="${item.x}"/>
                    <fmt:param value="${item.y}"/>
                    <fmt:param value="${item.z}"/>
                </fmt:message>

The only problem is that the fmt:message prints null if the variable
value is null.

as in ValueX null ValueZ ,

Without formatting applied , printing just ${item.x} ${item.y}
${item.z}  , prints
ValueX ValueZ (the null value is not printed, which is better).

-Rashmi





On Wed, Feb 11, 2009 at 12:45 PM, Rashmi <rashmi....@gmail.com> wrote:
> Thank you Martin, I'm new to using resource bundle, I'll learn it and
> give this a try.
>
> -Rashmi
>
>
> On Wed, Feb 11, 2009 at 12:29 PM, Martin Cooper <mart...@apache.org> wrote:
>>
>> Assuming you have a resource bundle around somewhere, add two format strings
>> to the bundle, one for each of your two display orders; use a condition
>> ('when', 'if' or whatever) to set a variable with the appropriate key; then
>> use that variable to specify the key to <fmt:message> within your loop.
>>
>> --
>> Martin Cooper
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscr...@jakarta.apache.org
For additional commands, e-mail: taglibs-user-h...@jakarta.apache.org

Reply via email to