I have a ftl template file stored in alfresco repository. The path of this file is: /app:company_home/app:dictionary/cm:StarXpert_x0020_Workflow/cm:templates/cm:contentModelTemplate.ftl
I want to use this FTL file to create an XML file. In my java backed webscript controller, i want to get the FTL file, i used many method to achieve this, but nothing works.
I tried this code:
Template template=cfg.getTemplate("PATH:\"/app:company_home/app:dictionary/cm:StarXpert_x0020_Workflow/cm:templates/cm:contentModelTemplate.ftl\"");
But i still getting this error:
java.io.FileNotFoundException: Template "contentModelTemplate.ftl" not found
I also tried to get the template by passing its nodeRef as reference to the getTemplate() method, but also it's not works.
Is there anybody who did this before ? Thanks for any hlep.
If the goal is to have your web script respond with the transformed XML file, then why not leverage the web script itself to do this transformation?
To do this, move the Freemarker template from its current home in the Data Dictionary to be part of your web script (I don't know if you are using repository deployed web scripts or classpath deployed web scripts--it doesn't make a functional difference).
Then, your Java-backed web script will grab data and put it in to the model.
The Freemarker template will automatically be used to render an XML response using the data in the model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With