How to read pair in freemarker
Posted
by
Lukasz Rys
on Stack Overflow
See other posts from Stack Overflow
or by Lukasz Rys
Published on 2013-11-07T17:00:43Z
Indexed on
2013/11/07
21:55 UTC
Read the original article
Hit count: 176
freemarker
Ok i'm having little trouble with reading pair.
So I'm creating my pair
private Pair<Integer, Integer> count(somethink) {
int c1 = 2;
int c2 = 4;
return new Pair<Integer, Integer>(c1, c2);
}
And 'sending' it to ftl via java
mv.addObject("counted", count(somethink));
I won't write everythink how it sends because I dont think it really matters with my issue. So i'm recieving it in "ftl". Then i was trying to 'read' it
<#list counted?keys as key>
<a href="#offerOrderTab"><@spring.message "someMsg"/>(${key}/${counted[key]})</a>
</#list>
After then i'm getting error
Expecting a string, date or number here, Expression x is instead a freemarker.ext.beans.SimpleMethodModel
As i suppose you dont iterate pairs (or I'm wrong?) i know its pair that contains only one key and one value but still i have to do send it that way and I thought its goin be to similar to iterating through map, in java i would use pair.first() and pair.second() but it doesn't work in ftl (ye i know it shouldnt work). I also tried to cast it to String by using ?string
but it didnt work too
© Stack Overflow or respective owner