dbarra / xdocreport

Automatically exported from code.google.com/p/xdocreport
1 stars 0 forks source link

Conditional Freemarker #231

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a document with XdocReport Marco
2. Process it with Java docx
3. Don't have all items in the data model

Is it possible to avoir having a java error when a field inserted by the macro 
template is not filled ?

Expression any is undefined on line 1, column 1157 in 
fr.opensagres.xdocreport.document.docx.DocxReport@3ba4d6bb!word/document.xml.
The problematic instruction:
----------
==> ${test.emptydata} escaped ${test.emptydata?xml?replace("
","</w:t><w:br/><w:t xml:space=\"preserve\">")?replace("    ","</w:t><w:tab/><w:t 
xml:space=\"preserve\">")} [on line 3, column 4683 in 
fr.opensagres.xdocreport.document.docx.DocxReport@3ba4d6bb!word/document.xml]
----------

Original issue reported on code.google.com by LudoFe...@gmail.com on 6 Mar 2013 at 4:35

GoogleCodeExporter commented 8 years ago
Freemarker can be configured for that 
http://freemarker.sourceforge.net/docs/pgui_config_errorhandling.html#autoid_44 
but I don't know if it's easy to configure that for XDocReport.

Velocity doesn't throw exception in this case.Perhaps you could switch to 
Velocity.

Regards Angelo

Original comment by angelo.z...@gmail.com on 7 Mar 2013 at 12:41

GoogleCodeExporter commented 8 years ago
Hi,

Thank.

http://freemarker.org/docs/api/freemarker/template/class-use/TemplateExceptionHa
ndler.html

It should be possible to change the configuration with something near :

inputStream from docx

IXDocReport finalDocument = 
XDocReportRegistry.getRegistry().loadReport(inputStream, 
TemplateEngineKind.Freemarker);

DocxTemplateEngineConfiguration configuration =  
(DocxTemplateEngineConfiguration) 
finalDocument.getTemplateEngine().getConfiguration();
            configuration.setTemplateExceptionHandler(TemplateExceptionHandler.IGNORE_HANDLER);
            finalDocument.getTemplateEngine().setConfiguration(configuration);

Issue :
 Can't cast to Configuration from ITemplateEngineConfiguration/DocxTemplateEngineConfiguration  and setTemplateExceptionHandler is only for freemarker Configuration

Original comment by LudoFe...@gmail.com on 7 Mar 2013 at 11:03

GoogleCodeExporter commented 8 years ago
to configure template engine you need to create your 
ITemplateEngineInitializerDiscovery 

Pleases read my comments at 
https://code.google.com/p/xdocreport/issues/detail?id=68#c2
(it's for Velocity log, but you can adapt it for Freemarker. If it works could 
you please attach your code in this issue, thank's).

Regards Angelo

Original comment by angelo.z...@gmail.com on 7 Mar 2013 at 2:49

GoogleCodeExporter commented 8 years ago
See https://code.google.com/p/xdocreport/wiki/FreemarkerTemplate to customize 
Freemarker template engine.

Original comment by angelo.z...@gmail.com on 18 Feb 2014 at 1:49