Re: question on object that extends AbstractList<E>
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Friday, April 16, 2010, 7:31:19 PM, jake ochs wrote: > I have a custom object that extends AbstractList<E> (E, in my case, is > a Lotus Notes Document object wrapper.) I also want to implement methods > in my custom object that return SimpleSequence values. i.e., in addition > to requesting of my object an element in the AbstractList of Notes > Documents I want to ask the object to lookup specific values and return > them as SimpleSequences. The problem is that when trying to access the > methods from FTL, I throw the error "Expected hash. <<objectname>> > evaluated instead to freemarker.template.SimpleSequence..." How do I > work around this? The default backward-compatible object wrapper doesn't expose the methods of objects unless it doesn't recognize any of their interfaces... That's so because originally the methods wasn't exposed for anything (as there was no automatic object-wrapping either). So, you could switch to freemareker.ext.beans.BeansWrapper... where you setup FM do: BeansWrapper wrapper = new BeansWrapper(); wrapper.setSimpleMapWrapper(true); cfg.setObjectWrapper(wrapper); Now that's not totally backward-compatible, but in practice it's 99% that, I think... The problem could be mostly only that it doesn't automatically wrap XML and Jython objects. (We really should introduce a BeansWrapper that represents the best-practice, and that later can become the default... BeansWrapper doesn't as it has SimpleMapWrapper set to false by default, and it doesn't wrap XML (nor Jython).) -- Best regards, Daniel Dekany ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev