Skip to content

Fixed: HashMaps are not properly rendered in FTL with current FTL integration (OFBIZ-13164) - #1616

Merged
mridulpathak merged 1 commit into
apache:release24.09from
mridulpathak:OFBIZ-13164-release24.09
Aug 10, 2026
Merged

Fixed: HashMaps are not properly rendered in FTL with current FTL integration (OFBIZ-13164)#1616
mridulpathak merged 1 commit into
apache:release24.09from
mridulpathak:OFBIZ-13164-release24.09

Conversation

@mridulpathak

Copy link
Copy Markdown
Contributor

Backported from trunk (#1615). OfbizBeansWrapper substitutes a MapModel whose key set is the map's own, instead of FreeMarker's stock union of the map's keys and its bean property names, so ?keys, ?size, and <#list map as key, value> stop seeing accessors like getClass or entrySet mixed in with the real entries; HtmlWidget.ExtendedWrapper picks up the same fix for screen rendering. Cherry-picked cleanly onto release24.09 with no conflicts and no adaptation needed.

Thanks: Aditi Patel (author of the trunk fix) and Carsten Schinzer (original reporter).

…egration (OFBIZ-13164)

FreeMarkerWorker built a plain BeansWrapper, so every java.util.Map reached
templates as freemarker.ext.beans.MapModel. MapModel.keySet() returns the
union of the map's own keys and the bean property names of the map object, so
key enumeration saw accessors mixed in with the real entries. On a two entry
map, ?size reported 30, ?keys listed getClass, put, entrySet and the rest
alongside alpha and beta, and <#list aMap as key, value> failed outright,
because the values behind those synthetic keys are methods rather than
strings.

Added OfbizBeansWrapper, which substitutes a MapModel whose key set is the
map's own. Only enumeration changes: member lookup still falls back to the
bean model, so templates keep calling methods on maps. That distinction
matters because GenericEntity implements Map, so switching to
DefaultObjectWrapper or enabling simpleMapWrapper would have broken every
${anEntity.getRelatedOne(...)}, ${anEntity.getString(...)} and
${aMap.get(...)} currently in the templates.

HtmlWidget.ExtendedWrapper now extends OfbizBeansWrapper so that screen
rendering picks up the same behaviour.

Two secondary effects are worth noting: ?keys now follows the map's iteration
order rather than being arbitrary, and an empty map now reports ?size 0,
which is consistent with the ?has_content it already reported.

Thanks to Carsten Schinzer for reporting this issue and for identifying the
BeansWrapper versus DefaultObjectWrapper mechanism behind it.
@mridulpathak
mridulpathak merged commit e332d3d into apache:release24.09 Aug 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants