Open GoogleCodeExporter opened 9 years ago
To be honnest with you, I have never played with Velocity Macro inside
XDocReport.
I sugest you to attach a basic sample with your problem and I will see your
problem when I will have time.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 12 May 2014 at 12:28
Thanks for your time !
Here is the attached sample code :
- TestVelocityMacro shows that it works with Velocity only
- TestXDocReportMacro tries to do the same with XDocReport : the global macro
is not evaluated
- Both classes are in src/test
Thanks a lot !
Original comment by julie.no...@gmail.com
on 12 May 2014 at 1:30
Attachments:
I didn't use a mergefield in the docx file but I changed the xml directly in
the archive...
Original comment by julie.no...@gmail.com
on 12 May 2014 at 1:36
I finally overrided the processNoCache of the VelocityTemplateEngine to make it
works... it seems that Velocity clean the provided namespace after each
"evaluate". Providing the empty String "" will result in clearing the global
namespace and all the macros. It works properly with a "LOCAL" namespace.
@Override
protected void processNoCache(String entryName, IContext context, Reader reader, Writer writer)
throws XDocReportException, IOException {
VelocityEngine velocityEngine = getVelocityEngine();
// Here use a local namespace name to avoid dumping the global namespace after each template
velocityEngine.evaluate((VelocityContext) context, writer, "LOCAL", reader);
}
Hope it can be integrated in an official release of XDocReport,
Regards,
Julie
Original comment by julie.no...@gmail.com
on 23 May 2014 at 8:32
Julie, could you explain me what is "LOCAL" namespace? Is it Velocity feature
(perhaps it exists a Velocity constant for that).
Original comment by angelo.z...@gmail.com
on 23 May 2014 at 8:47
I am not sure I well understood how Velocity handle the namespaces... here,
this value should be chosen by the caller.
It is described in the Javadoc as :
logTag string to be used as the template name for log messages in case of error
... and later in the velocity process as the template name itself, and at the
end, as the namespace.
So I guess it is to defined a specific namespace for each template, and define
values and macros inside that namespace.... Maybe the best value here would be
entryName.
What is sure is that "" will override the global namespace.
Hope it helps !
Original comment by julie.no...@gmail.com
on 23 May 2014 at 9:40
Sorry Julie,
I was very busy.
If we use entryName as template name (ex : word/document.xml) it means that all
docx report will share the same name. Do you think there is a problem with that?
Perhaps we should use the reportId?
Original comment by angelo.z...@gmail.com
on 7 Aug 2014 at 8:53
I agree with you, it seems a good idea to use a reportId... but I didn't get
any issue using the template name, maybe Velocity cleans the local cache
between each evalutation.
Hope this can be integrated in a further release.
Thanks a lot,
Julie
Original comment by julie.no...@gmail.com
on 15 Aug 2014 at 2:03
Hi Julie,
Please see my commit at
https://code.google.com/p/xdocreport/source/detail?r=14d83bd84d2d28462fab797dbed
e672916e4a70c
Now template engine (Velocity and Freemarker) uses the template name (reportId
! entryName) for cache and no cache process.
Please test to tell me if it resolves your initial problem.
Thank's
Regard's Angelo
Original comment by angelo.z...@gmail.com
on 18 Aug 2014 at 6:22
Original issue reported on code.google.com by
julie.no...@gmail.com
on 12 May 2014 at 12:17