Closed GoogleCodeExporter closed 9 years ago
Hi,
In the web demo template engine kind is setted in the request. I tell me if
default template engine works always?
---------------------------------------------
TemplateEngineRegistry.getRegistry().getDefaultTemplateEngine();
---------------------------------------------
returns perhaps null and it's your problem. This code is used
in the getTemplateEngine( HttpServletRequest request ) of
http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocrep
ort.document/src/main/java/fr/opensagres/xdocreport/document/web/BaseXDocReportS
ervlet.java
---------------------------------------------------------------------------
@Override
protected ITemplateEngine getTemplateEngine( HttpServletRequest request )
{
String templateEngineId = getTemplateEngineId( request );
if ( StringUtils.isNotEmpty( templateEngineId ) )
{
return TemplateEngineInitializerRegistry.getRegistry().getTemplateEngine( templateEngineId );
}
return TemplateEngineRegistry.getRegistry().getDefaultTemplateEngine();
}
---------------------------------------------------------------------------
So I suggest you to force template engine kind in your servlet like this :
---------------------------------------------------------------------------
@Override
protected String getTemplateEngineKind( HttpServletRequest request )
return TemplateEngineKind.Freemarker.name();
}
---------------------------------------------------------------------------
Regards Angelo
Original comment by angelo.z...@gmail.com
on 25 Dec 2012 at 11:36
-----------
TemplateEngineRegistry.getRegistry().getDefaultTemplateEngine();
-----------
returns 'null'
What I did wrong to get this problem? Why it returns null?
Original comment by MrSo...@gmail.com
on 25 Dec 2012 at 12:14
Sorry i was wrong. 'null' was returned when there was no parameters in GET, but
when I type parameters, servlet give me docx output. Now How can I convert it
to pdf. I didn't found it for servlets.
Original comment by MrSo...@gmail.com
on 25 Dec 2012 at 12:41
---------------
@Override
protected String getTemplateEngineKind( HttpServletRequest request )
return TemplateEngineKind.Freemarker.name();
}
--------------
This helped to override template, thx.
But now I'm wondering about pdf converting.
Original comment by MrSo...@gmail.com
on 25 Dec 2012 at 12:44
Sorry I already found PDF converting parameters for servlet, now I have to find
method to parse template and read source of all input tags.
Original comment by MrSo...@gmail.com
on 25 Dec 2012 at 12:53
-----------
TemplateEngineRegistry.getRegistry().getDefaultTemplateEngine();
-----------
>returns 'null'
>What I did wrong to get this problem? Why it returns null?
Nothing, this smethod should be removed, I think.
> Sorry I already found PDF converting parameters for servlet, now I have to
find >method to parse template and read source of all input tags.
I don't understand. Can you convert your report to PDF?
What do you mean with parse template and read source of all input tags?
Extract fields name of your docx? If it's that, see FieldsExtractor.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 25 Dec 2012 at 2:45
1. I can convert report to PDF.
2. Yes, I think FieldsExtractor will help me to know all fields names
I read Issue 91 about usage.
Is this working for Freemarker?
final public static Collection<String> getFields(IXDocReport report) throws XDocReportExcep
tion{
Collection<String> names = new TreeSet<String>();
FieldsExtractor<FieldExtractor> extractor = new FieldsExtractor<FieldExtractor>();
report.extractFields(extractor);
List<FieldExtractor> fields = extractor.getFields();
for(FieldExtractor field : fields) names.add(field.getName());
return names;
}
Original comment by MrSo...@gmail.com
on 25 Dec 2012 at 6:48
Yes it's working for Freemarker, but it manages basic cases. FieldsExtractor
exists but I think it's a bad idea to use it. I think you must define fields
(with FieldsMetadata) and create report and not create report to define fields
(FieldsExtractor).
But perhaps you wish manage a web application with generic report like our demo
at http://xdocreport.opensagres.cloudbees.net/
So I suggest you to study (to see the parameter used to generete, convert
report at http://xdocreport.opensagres.cloudbees.net/processReport.jsp
When you load report at
http://xdocreport.opensagres.cloudbees.net/loadReport.jsp, it uses
FieldsExtractor, so you can study how it's used.
Source of this webapp are on Git at
http://code.google.com/p/xdocreport/source/browse/?repo=samples#git%2Fdemo-webap
p
Good luck.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 25 Dec 2012 at 7:14
Looks like FieldsExtractor can't help me with file "полис
(шаблон).docx" (remove it from server plz, some problems with encoding).
It didn't extract any files at all =(
Original comment by MrSo...@gmail.com
on 26 Dec 2012 at 6:53
"It didn't extract any fields at all"*
Original comment by MrSo...@gmail.com
on 26 Dec 2012 at 7:02
Sorry I don't understand your problem.
I suggest you to ssee sources of the webapp demo to see how to use
FieldsExtractor.
But as I told you, I think it's bad idea to use it.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 26 Dec 2012 at 11:53
1) please delete file "полис (шаблон).docx" from test server, it
shows on the bottom of "Choose a report"
http://xdocreport.opensagres.cloudbees.net/processReport.jsp
I uploaded it, but now can't delete because of problems with encoding.
2) I used http://xdocreport.opensagres.cloudbees.net/loadReport.jsp to load
report above and FieldsExtractor didn't find any fields. This means that it
can't help to solve my problem.
3) Can you give me the source of this FieldsExtractor class, maybe I'll
understand how to extract fields from reports.
Original comment by MrSo...@gmail.com
on 26 Dec 2012 at 1:59
For 1) you can do yourself at
http://xdocreport.opensagres.cloudbees.net/admin.jsp (click on remove link of
your report).
2) Perhaps you have complex fields. The basic idea is that your field starts
with $
3) see extractFields at
http://code.google.com/p/xdocreport/source/browse/template/fr.opensagres.xdocrep
ort.template.freemarker/src/main/java/fr/opensagres/xdocreport/template/freemark
er/FreemarkerTemplateEngine.java
see Junit at
http://code.google.com/p/xdocreport/source/browse/template/fr.opensagres.xdocrep
ort.template.freemarker/src/test/java/fr/opensagres/xdocreport/template/freemark
er/FreemarkerTemplateEngineExtractVariablesTestCase.java
Regards Angelo
Original comment by angelo.z...@gmail.com
on 26 Dec 2012 at 3:29
1) no, I can't do it by myself because of _encoding problems_. It displays like
"????? (??????).docx" and remove not working =(
2) Fields created by MS Word in my report, and I can't change it, because I
have to use this templates anyway. So I guess I have to make my own parser.
Original comment by MrSo...@gmail.com
on 26 Dec 2012 at 5:45
Ok,
For 1) I have restarted the webapp, your docx is removed. It's a bug with demo
webapp, but as it's a demo, it's not urgent, I will see that when I will have
time.
for 2), plase attach your docx.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 26 Dec 2012 at 6:46
1) Thanks
2) Looks like I have other syntax of Fields: { MACROBUTTON ##611100825271##
Name } and I have to extract this number 611100825271
Original comment by MrSo...@gmail.com
on 27 Dec 2012 at 7:05
I close this bug, because your current problem is not aboutFreemarker+Servlet.
If you have some problem, please create a new isuse by explaining more your
problem and attach your docx.
Thank's
Regards Angelo
Original comment by angelo.z...@gmail.com
on 27 Dec 2012 at 9:51
Original issue reported on code.google.com by
MrSo...@gmail.com
on 25 Dec 2012 at 10:36