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

Jake Ochs <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
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.

-----BEGIN STACKTRACE-----
Expected hash. doc evaluated instead to 
com.cmti.freemarker.NotesDocWrapper on line 9, column 7 in VETest1.ftl.
The problematic instruction:
----------
==> ${doc.Subject} [on line 9, column 5 in VETest1.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateException: Expected hash. doc evaluated 
instead to com.cmti.freemarker.NotesDocWrapper on line 9, column 7 in 
VETest1.ftl.
	at 
freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
	at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
	at freemarker.core.Expression.getStringValue(Expression.java:93)
	at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
	at freemarker.core.Environment.visit(Environment.java:209)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:209)
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167)
	at freemarker.core.Environment.visit(Environment.java:416)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
	at freemarker.core.Environment.visit(Environment.java:209)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:209)
	at freemarker.core.Environment.process(Environment.java:189)
	at freemarker.template.Template.process(Template.java:237)
	at FreemarkerTester.main(FreemarkerTester.java:54)


------------------------------------------------------------------------------
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.