• Generate document from template

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #48078  by Under5hadow
 
Hi,

I'm trying to generate a document from template when the worflow start.
I got the generated file but it's empty :/
all the template field value got replace by "". Don't really know where to start the debug.
If I create the document from the template by the user interface, I got all the field replaced.

I defined my metadata :
Code: Select all
<property-group label="Fre" name="okg:fre">
    <input label="Input label" name="okp:fre.input"/>
    <textarea label="Comment" name="okp:fre.comment" />
    <input label="Input label2" name="okp:fre.input2" />
    <input label="Document" name="okp:fre.document" />
</property-group>
My template as the Template field value :
capturewf.PNG
capturewf.PNG (1.46 KiB) Viewed 2248 times
I use the code below to create the final document :
Code: Select all
Map<String, String> map = new HashMap<String, String>(); 
map.put("okp_fre_Input2","Alicia"); 
List<Map<String,String>> lista = new ArrayList<>(); 
lista.add(map);
List<GWTFormElement> elementos = new ArrayList<>();
Map<String,List<Map<String,String>>> mapa = new HashMap<>(); 
mapa.put("okp_fre_Input2", lista); 
DocumentServlet ds = new DocumentServlet();
GWTDocument  file = ds.createFromTemplate("/okm:templates/PMGI_0_TE_07_TemplateFRE.odt", "/okm:root/finaldoc.odt", elementos, mapa);
Catalina log :
catalina.png
catalina.png (9.07 KiB) Viewed 2248 times
How the final document look like:
finaldoc.png
finaldoc.png (853 Bytes) Viewed 2248 times
Any idea about my issue ? thanks !
 #48096  by jllort
 
You have a lot of wrong concepts in your code. You should not use Servlet in the way you are using, also you should not use GWTXXX into workflow classes.

I suggest first debug step by step the Servlet code and then understanding what it does, try to apply from workflow class.
 #48139  by jllort
 
If you do not know how to debug with eclipse or IntelliJ a JAVA application means you are starting with JAVA development and you will take some time until you get the minimum skills for playing with the code.

https://www.vogella.com/tutorials/Eclip ... ticle.html
https://www.google.com/search?q=youtube ... bu+eclipse ( youtube java debug with eclipse )

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.