Re: Hashes (in general)
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
On 2009.06.10., at 9:52, Daniel Dekany wrote: > Tuesday, June 9, 2009, 4:57:11 PM, Brian Pontarelli wrote: >> >> Yeah. It doesn't unwrap the map directly. It creates a special Map >> that is an adapter with a custom entry set. It definitely can make >> things messy. > > What did you use for unwrapping (and what was the ObjectWrapper)? If > you use BeansWrapper and call a plain Java method, it should give you > back the original Map. DefaultObjectWrapper will do that... DefaultObjectWrapper is a BeansWrapper that hijacks BeansWrapper wrapping logic for strings, numbers, dates, lists, arrays, and maps, and diverts it to creation of SimpleXxx models. SimpleHash creates a private map copy, and can't expose it back (it doesn't implement AdapterTemplateModel), so the BeansWrapper.unwrap() has to resort to creating a new f.ext.beans.HashAdapter (which is a TemplateHashModel->java.util.Map adapter). You can tell I *really* dislike DefaultObjectWrapper and its penchant for creating SimpleXxx models; it quite carelessly breaks some intuitively expected behaviour, like expectation of being able to pass a Map returned from one Java method to another Java method. As I already said, just use BeansWrapper. It preserves identity of objects bidirectionally (passing back to Java from Java), doesn't create copies of collections, and in general behaves intuitively. If you dislike having map methods visible, use BeansWrapper with setSimpleMapWrapper(true). Attila. -- http://twitter.com/szegedi > >> -bp >> > > -- > Best regards, > Daniel Dekany ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects