You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ryan Gardner <ry...@gmail.com> on 2008/09/10 07:20:09 UTC
How do I get a DateTool into my velocity context.
This is what I have set up now - quite a big ordeal just to inject a
dateTool into a header so I can then pull it out in my Velocity
template to format a date.
.process(
new Processor() {
public void process(Exchange exchange) throws
Exception {
// set the context up so we can have the
dateTool in the vm template
exchange.getOut().setHeaders(exchange.getIn().getHeaders());
exchange.getOut().setHeader("dateTool",
new DateTool());
exchange.getOut().setBody(exchange.getIn().getBody());
}})
There HAS to be a simpler way to do this... but I can't find an
example on how to do it... Any tips?
Basically, I just need a way to get an
org.apache.velocity.tools.generic.DateTool into the VelocityContext.
The easiest way I saw to do this was to throw it into the header of
the message.
The easiest way I saw to do this was to create an anonymous inner
class that set the header in the way you see above.
Any tips on an easier way to do this would be appreciated.
Ryan
RE: How do I get a DateTool into my velocity context.
Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi
I think you can use the setHeader DSL
.setHeader("dateTool").constant(new DateTool()).
In your route and avoid the inner anym processor
Med venlig hilsen
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Ryan Gardner [mailto:ryebrye@gmail.com]
Sent: 10. september 2008 07:20
To: camel-user@activemq.apache.org
Subject: How do I get a DateTool into my velocity context.
This is what I have set up now - quite a big ordeal just to inject a
dateTool into a header so I can then pull it out in my Velocity
template to format a date.
.process(
new Processor() {
public void process(Exchange exchange) throws
Exception {
// set the context up so we can have the
dateTool in the vm template
exchange.getOut().setHeaders(exchange.getIn().getHeaders());
exchange.getOut().setHeader("dateTool",
new DateTool());
exchange.getOut().setBody(exchange.getIn().getBody());
}})
There HAS to be a simpler way to do this... but I can't find an
example on how to do it... Any tips?
Basically, I just need a way to get an
org.apache.velocity.tools.generic.DateTool into the VelocityContext.
The easiest way I saw to do this was to throw it into the header of
the message.
The easiest way I saw to do this was to create an anonymous inner
class that set the header in the way you see above.
Any tips on an easier way to do this would be appreciated.
Ryan