Discussion:
[FreeMarker-user] Invalid Reference Exception while accessing nested map in freemarker
Sushrut Bidwai
2013-03-15 18:57:02 UTC
Permalink
Hi,

I have nested map.

Map<String, Map<String, Long>> domains;

When I access it in following manner I get InvalidReferenceException

<#list somelist as item>
<#list domains[item]?keys as key>
${key}
</#list>
</#list>

Expression domains[item] is undefined on line...

I tried using BeansWrapper as well as DefaultObjectWrapper. Also I have
checked contents on the map and none of the values are null.

Link<http://stackoverflow.com/questions/15440026/invalid-reference-exception-while-accessing-nested-map-in-freemarker>to
the same question on SO.


--
Best Regards,
Sushrut
http://simplycious.com
Denis Bredelet
2013-03-15 19:11:04 UTC
Permalink
Hi Sushrut,
Post by Sushrut Bidwai
I have nested map.
Map<String, Map<String, Long>> domains;
How did you add it to the data root?
Post by Sushrut Bidwai
When I access it in following manner I get InvalidReferenceException
<#list somelist as item>
<#list domains[item]?keys as key>
${key}
</#list>
</#list>
Expression domains[item] is undefined on line...
I tried using BeansWrapper as well as DefaultObjectWrapper. Also I have checked contents on the map and none of the values are null.
Link to the same question on SO.
--
Best Regards,
Sushrut
http://simplycious.com
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Sushrut Bidwai
2013-03-15 19:16:15 UTC
Permalink
Hi Dennis,

Map root = new HashMap();
root.put("domains", domains);
Post by Denis Bredelet
Hi Sushrut,
I have nested map.
Map<String, Map<String, Long>> domains;
How did you add it to the data root?
When I access it in following manner I get InvalidReferenceException
<#list somelist as item>
<#list domains[item]?keys as key>
${key}
</#list>
</#list>
Expression domains[item] is undefined on line...
I tried using BeansWrapper as well as DefaultObjectWrapper. Also I have
checked contents on the map and none of the values are null.
Link<http://stackoverflow.com/questions/15440026/invalid-reference-exception-while-accessing-nested-map-in-freemarker>to the same question on SO.
--
Best Regards,
Sushrut
http://simplycious.com
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user
--
Best Regards,
Sushrut
http://simplycious.com
Daniel Dekany
2013-03-16 10:22:56 UTC
Permalink
Works for me with both DefaultObjectWrapper and BeansWrapper, so I
guess somelist contains some bad keys. But see the same answer on SO
with test code:
http://stackoverflow.com/questions/15440026/invalid-reference-exception-while-accessing-nested-map-in-freemarker/15448101#15448101
Post by Sushrut Bidwai
Hi,
I have nested map.
Map<String, Map<String, Long>> domains;
When I access it in following manner I get InvalidReferenceException
<#list somelist as item>
<#list domains[item]?keys as key>
${key}
</#list>
</#list>
Expression domains[item] is undefined on line...
I tried using BeansWrapper as well as DefaultObjectWrapper. Also I
have checked contents on the map and none of the values are null.
Link to the same question on SO.
--
Best Regards,
Sushrut
http://simplycious.com
--
Best regards,
Daniel Dekany
Loading...