Yep, totally possible.
So freemarker binds a "context" to the template, and populates the template
body with whatever is found in the "context"
So in the case of Camel integration, Camel will put some parts of the
exchange (and the whole exchange actually) which is then available in the
freemarker template.
The body and headers are all treated as POJOs when they are bound to the
freemarker context, so if you have your own pojo, MyPerson, and you wish
you access its members 'givenName' or 'familyName' within the freemarker
template, you can do so like ${body.givenName} or ${body.familyName}. Same
thing goes for headers.

Have a peek at this unit test to make it more clear:

https://github.com/apache/camel/blob/master/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerBodyAsDomainObjectTest.java#L32


On Tue, Aug 27, 2013 at 8:44 PM, paulc8712 <paulc8...@gmail.com> wrote:

> Hi All.
>
> I'm fairly new to Camel - and very new to Freemarker.
>
> There doesn't seem to be much out there in the way of camel-freemarker
> examples other than the fairly simplistic email example in
> http://camel.apache.org/freemarker.html
>
> What I would like to be able to do is use freemarker with either a POJO
> header or body, or XML using xpath.  Is this possible?
>
> If it is - I would appreciate it greatly if people could share some sample
> freemarker templates that use POJO as the data source.
>
> Thanks, Paulc
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/freemarker-with-pojo-and-or-xpath-tp5738098.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Reply via email to