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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to