Re: Custom Directive - Return Objects From TemplateDirectiveModel

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
I think you'd rather want your object to implement TemplateMethodModel  
or TemplateMethodModelEx for that purpose, and not  
TemplateDirectiveModel. Method models are the Java equivalent of  
[#function] in FTL, and have a return value.

Attila.

On 2008.02.18., at 17:41, jaybytez wrote:

>
> I am passing in a OMElement (Apache Axiom) into the freemarker  
> template.
> Unfortunately, not all the methods for the OMElement are accessible  
> using
> Bean syntax and some methods require QName parameters and not String
> parameters.  So one feature I wanted was to walk the OMElement and  
> call its
> getChildrenWithName(javax.xml.namespace.QName elementQName) to  
> return an
> iterator that only included specific elements, but at you can see the
> parameter is not something I can pass from freemarker.
>
> So what I wanted to do was create a custom directive where I could  
> pass the
> namespace and local name to the custom directive and under the  
> covers call
> this method and return its return value, which is an iterator and  
> then store
> that iterator into a variable in Freemarker (like the assign).
>
> I was going to try and simplify this by placing the OMElement into a  
> wrapper
> object so I could add some functionality, but this doesn't work.  So I
> thought about creating some custom directives, where I could do  
> OMElement
> functionality under the covers and return the results.  The only  
> thing is
> that my custom directive won't be writing to the OutputStream, but  
> will just
> be returning objects to the freemarker template to be processed by  
> other
> commands.
>
> How do you do this in the custom freemarker directive?
>
> Thanks - jay

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
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.