Re: freemarker error: Expected hash, evaluated instead to ...

Jake Ochs <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hmm. By not making the NotesDocWrapper an extension or implementation of 
anything I seem to get the functionality I desire. Odd, I thought I went 
through that combination earlier...

On 12/16/2009 11:38 AM, Daniel Dekany wrote:
> Wednesday, December 16, 2009, 4:24:08 PM, Jake Ochs wrote:
>
>> I set the NotesDocWrapper to implement a TemplateHashModel and the
>> collection extends AbstractList and it works. The only issue is that the
>> NotesDocWrapper has a custom method that I want to call from Freemarker
>> (in addition to the standard 'get'). Again, this custom method is
>> available if I drop a NotesDocWrapper directly onto the root hash.
>
> That's strange because if NotesDocWrapper implements TemplateModel (or
> a subinterface of it) it shouldn't be re-wrapped, means, it should
> behave no how you retrieve it. Are you sure you don't mess up
> something there?
>
> Anyway... since NotesDocWrapper is already a TemplateMode, FreeMarker
> will not (should not) do any extra magic with it (like exposing
> methods). So if you want to call a method, you have to return it as a
> hash item.
>
>
>> On 12/16/2009 9:45 AM, Daniel Dekany wrote:
>>> Wednesday, December 16, 2009, 2:03:10 PM, Jake Ochs wrote:
>>>
>>>> I've created a custom collection that implements iterator and returns
>>>> another custom object - NotesDocWrapper (wraps a Lotus Domino Document
>>>> object.) My template then lists the docs collection I placed in the root
>>>> hash and iterates over the doc accessing a field like so:
>>>> <#list docs as doc>
>>>> <li>${doc.Subject}</li>
>>>> </#list>
>>>> The NotesDocWrapper implements TemplateModel and has a get method so it
>>>> can return a Notes Document field using the standard template dot syntax
>>>> as used above. I've used the NotesDocWrapper by itself, dropping it into
>>>> the root hash successfully, but when I attempt to nest it in this manner
>>>> I get a freemarker exception (see full stacktrace at bottom of post)
>>>>
>>>> How do I prevent Freemarker from expecting a hash instead of using the
>>>> wrapper I supplied for the nested object? (assuming this is the problem)
>>>> Any tips are appreciated.
>>>
>>> Exactly what does NotesDocWrapper extend and implement? It should
>>> implement TemplateHashModel (or TemplateHashModelEx).
>


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.