On Sat, Jul 28, 2012 at 12:53 PM, Claude Brisson <cla...@renegat.net> wrote:

> On Sat, 28 Jul 2012 11:47:35 +0530
> Dishara Wijewardana <ddwijeward...@gmail.com> wrote:
>
> > On Fri, Jul 27, 2012 at 2:20 PM, Claude Brisson <cla...@renegat.net>
> > wrote:
> >
> > > Well, ok, but it's still not what I asked for: I meant a command
> > > line tool that would, of course, use your JSR 223 API classes.
> > >
> > HI Claude,
> > Sorry for the inconvenience  I made. So what you meant is do the above
> > similar kind of thing (a client code) which would not directly goes
> > through the velocity API but through JSR223 API ? If so in that case
> > we would need to add additional methods to the JSR API ? IS that OK ?
> > Is it what you expected ?
>
> Well, the API is meant to be used, and a command line wrapper seems to
> me one of the simplest things we could do as an example.
>
> Why would you need additional methods to the JSR 223 API? Which methods?
>
JSR223 API doesn't have a concept like templates which is in velocity.
Hence it does not have getTemplate() method. ( because I have simply to
execute a similar example as given through jsr 223 API, need a getTemplate()
)

>
>
>   Claude
>
> >
> > >   Claude
> > >
> > > On Fri, 27 Jul 2012 00:00:31 +0530
> > > Dishara Wijewardana <ddwijeward...@gmail.com> wrote:
> > >
> > > > Hi Claude,
> > > > I was finally able to got a simple code working :-) .
> > > >
> > > > public class Main {
> > > >
> > > >     public static void main(String[] args) throws Exception {
> > > >         VelocityContext context = new VelocityContext();
> > > >         Writer writer = new StringWriter();
> > > >
> > > >         CustomEvent event = new CustomEvent("subash");
> > > >         context.put("event", event);
> > > >         Template template = createTemplate("eventtool.vm");
> > > >
> > > >         template.merge(context, writer);
> > > >         System.out.println(writer);
> > > >         writer.close();
> > > >     }
> > > >
> > > >     private static Template createTemplate(String vmTemplateFile)
> > > > throws Exception {
> > > >         VelocityEngine ve = new VelocityEngine();
> > > >         Properties properties = new Properties();
> > > >         properties.put("resource.loader", "class");
> > > >         properties.put("class.resource.loader.description","Template
> > > > Class Loader");
> > > >         properties.put("class.resource.loader.class",
> > > >
> > > >
> "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
> > > >         ve.init(properties);
> > > >         return ve.getTemplate(vmTemplateFile);
> > > >     }
> > > >
> > > >
> > >
>  
> ---------------------------------------------------------------------------------------------------------------------------------
> > > >
> > > > And here is the template and the out put.
> > > >
> > > > *eventtool.vm*
> > > >
> > > > $event;
> > > >
> > > > Event Created by $event.getName()
> > > > Event Created on $event.getDate()
> > > >
> > > >
> > > > *Output*
> > > > *
> > > > *
> > > > This is a test event template: created bysubash on Thu Jul 26
> > > > 23:57:25 IST 2012;
> > > >
> > > > Event Created by subash
> > > > Event Created on Thu Jul 26 23:57:25 IST 2012
> > > >
> > > >
> > > >
> > > > On Sun, Jul 22, 2012 at 4:54 PM, Claude Brisson
> > > > <cla...@renegat.net> wrote:
> > > >
> > > > > > Did you mean Velocity maven plugin tool[1] as the command line
> > > > > > tool ? If not can you please direct me to a link to find the
> > > > > > example to follow. Because in the documentation page there are
> > > > > > links to XML tool, View tool, JSP tool and etc. And couldn't
> > > > > > find "command line tool" thing . Correct me if I am looking
> > > > > > for irrelevant.
> > > > > >
> > > > > > [1] -
> > > > > >
> > > > >
> > >
> http://velocity.apache.org/tools/devel/maven-velocity-tools-plugin/index.html
> > > > >
> > > > > No, when I say "command line tool", I only mean a plain old Java
> > > > > object with a "main(String args[])" method, that you can call
> > > > > from the command line...
> > > > >
> > > > >
> > > > >   Claude
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


-- 
Thanks
/Dishara

Reply via email to