freemarker-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Albert Kam <>
Subject HashAdapter keySet() is null ?
Date Thu, 26 May 2016 08:55:16 GMT

I'm experimenting on passing hash or a seq of hashes to the java code.
I tried doing keySet() from the hash or list of hashes passed as
HashAdapter type, and found out that it results in null.

I had to 'wrap' the hashAdapter into another map through guava to get
a normal map with the correct keySet() behavior.

I wonder if it's the normal behavior ?

Example of ftl:

    <@testParameters />

    <#macro testParameters>
        ${proc.debug('hello world')}
            'msg': 'hello world'
                { 'msg': 'hello world' },
                { 'msg': 'hello world2' },
                { 'msg': 'hello world3' }

And the code of proc in the model / context:

    public static class DataProcessor {
        public void debug(String str) {

        public void debugMap(Map<String, Object> map) {
            System.out.println(JsonUtil.prettyString(map.keySet())); // null
// ok

        public void debugMaps(List<Map<String, Object>> maps) {
// null
// ok

Thank you

Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)

View raw message