14 May 18:19
Suggestion about the best BeansWrapper
Jacopo Cappellato <jacopo.cappellato <at> gmail.com>
2012-05-14 16:19:36 GMT
2012-05-14 16:19:36 GMT
Hi all, recently Daniel Dekany helped me in this list to fix a deadlock condition happening under special conditions when OFBiz (http://ofbiz.apache.org) screens were rendering Freemarker templates; during that interesting thread Daniel also mentioned that the way about the way we use BeansWrapper in OFBiz; here is the relevant part of the conversation: ===================================================== QUESTION (me): Currently in OFBiz we are using the default object wrapper: BeansWrapper defaultOfbizWrapper = BeansWrapper.getDefaultInstance(); do you think we should use a different one? ANSWER (Daniel): I'm not sure. There are two problems with the current one: - If you look at what map keys FreeMarker sees (`<#list k as someMap?keys>${k} </#list>`), it mixes the actual Map keys with the methods of the Map class. This I already find annoying enough to stay away. But it's also dangerous, because if you are unlucky and have key like "get", then someMap.get and someMap[myDynamicKey] where myDynamicKey happens to be "get" will return the get method instead of the map item. You can think further what if you have a custom Map class and you add methods to it. Using someMap.get("theKey") is robust however, but too verbose. - It doesn't wrap W3C DOM nodes automatically in a way so that the user can use FreeMarker's XML processing facility. It also doesn't wrap Jython or Rhino JavaScript objects nicely.(Continue reading)
RSS Feed