Preserving ordering in a Freemarker sequence when iterating over an OrderedBidiMap.

Stephen Smith <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hi,

We're using an OrderedBidiMap from Commons Collections 3.x to store a mapping of
keys<->values (the implementation we use is TreeBidiMap). Our Freemarker syntax
is as follows:

    <#list subjectsMap?keys as subjectName>
      ${subjectName}
    </#if>

The problem is that the sequence is returning an unordered list of keys. The same
Freemarker syntax seems to work with a LinkedHashMap, but I don't understand what
Freemarker is doing under the hood when getting the map's keys. Surely it is just
calling Map#keySet, in which case our ordering should be preserved?

Is this a defect in Freemarker, are we misusing the sequence syntax, or should we
pass through the OrderedBidiMap's entry set and then call getKey and getValue on
each bean?

Thanks in advance

Stephen Smith

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.