I believe velocity tools is like any other class and just needs to be instantiated and added to the context to use it. If you want to use one of the velocity tools in the project , place it in the class path and then can you verify if the following helps?

protected void populateContextMap(Map map) {
        super.populateContextMap(map);
        map.put("date",new
                org.apache.velocity.tools.generic.DateTool());

}

You might have to do the same for every velocity-tools you plan to use - ie look for the actual implementation class and add it to the context.
 
regards,
karthik

On Thu, 15 Dec 2005 Diogo Quintela(EF) wrote :
>Try to override populateContextMap as in this example.
>What you put in this map will be available in velocity context (or in jelly
>context, if using jelly).
>
>protected void populateContextMap(Map map) {
>        super.populateContextMap(map);
>        map.put("util", getEjbUtils());
>        map.put("version", getVersion());
>    }
>
>Regards
>Diogo
>
>-----------------------------------
>Diogo Bacelar Quintela
>EF - Tecnologias de Informação, Lda.
>Av. António Serpa, 26 - 4º Dto.
>1050-027 Lisboa, Portugal
>Tel: (+351) 217 827 800
>Fax: (+351) 217 827 830
>Email: [EMAIL PROTECTED]
>PGP: 0xF51A5AB9
>
> > -----Original Message-----
> > From: Stefan Undorf [mailto:[EMAIL PROTECTED]
> > Sent: quarta-feira, 14 de Dezembro de 2005 22:23
> > To: [email protected]
> > Subject: [xdoclet-user] Transfering data to the velocity script
> >
> > Hello,
> >
> > I'm just making my first steps with XDoclet(2). First thanks for sharing
> > this tool.
> >
> > I tried to to output the creation date in my generated files. The first
> > attempt was to add velocity-tools-1.2.jar to my classpath and generate -
> > without any results. The $date tag in the 2nd line of the script is simply
> > ignored. This is my velocity script:
> >
> > *** start velocity script ***
> > #set( $class = $metadata )
> > //Created on $date
> > //Created on $date.format('medium',$myObjectName)
> >
> >
> > public class ${class.getName()} extends ${class.getName()}Standard {}
> > *** end velocity script ***
> >
> > Then I thought about providing a date object from my java class to the
> > script which could be used in line 3 of the velocity script. This is my
> > java
> > class:
> >
> > *** start java class ***
> > import java.util.Date;
> >
> > import org.generama.QDoxCapableMetadataProvider;
> > import org.generama.VelocityTemplateEngine;
> > import org.generama.WriterMapper;
> > import org.generama.defaults.JavaGeneratingPlugin;
> >
> > public class EntityClassImplPlugin extends JavaGeneratingPlugin {
> >
> >      public EntityClassImplPlugin(VelocityTemplateEngine
> > velocityTemplateEngine,
> >                QDoxCapableMetadataProvider metadataProvider,
> > WriterMapper writerMapper)
> >                throws ClassNotFoundException {
> >
> >           super(velocityTemplateEngine, metadataProvider,
>writerMapper);
> >           //metadataProvider.getMetadata().add("myDate", new Date());
> >           setMultioutput(true);
> >      }
> > }
> > *** end java class ***
> >
> > In line 16 I tried to provide my data object. Of course this is not
> > possible. Is there an alternative?
> >
> > Thanks in advance,
> > Stefan



Reply via email to