AnsweredAssumed Answered

Java backed webscript and Freemarker templates

Question asked by amenel on Mar 30, 2009
Latest reply on Jun 20, 2014 by juilee
Hi all,
I have spent some time trying to figure out how web scripts work in Alfresco 3.0 and also trying to set up a simple web script. For the first part, the information from the wiki pages got me started. For the second part, these same pages seem not enough to me.

My task is to write a web script that provides data access to the Alfresco repository for an application we are working on. For now, I am trying to write a script that returns a simple xml response: the names and values of the parameters it has been called with. I wrote the Java class that extends AbstractWebScript, and installed the jar file in webapps/alfresco/WEB-INF/lib. I also wrote the appropriate desc.xml file and added a bean in web-scripts-custom-context.xml referencing my script.

At first, the script was not found (class load exception). I had to change package names before it was loaded.

However, Alfresco returned an exception stating that my webscript had no Freemarker template… The wiki says that AbstractWebScript "allows the webscript to take full control over the request" whereas DeclarativeWebScript "allows a web script to mix Java, JavaScript and templates" (I understood "Freemarker templates"). My deduction was that AbstractWebScript is not constrained with the obligation of providing templates. Am I wrong ?

I provided a template anyway. But I here comes the problem: how can I include the streamed xml that my java class returns into the template so as to provide a full response ?
The FreeMarker Template Cookbook (http://wiki.alfresco.com/wiki/FreeMarker_Template_Cookbook) didn't help.
The Java-backed examples page does not mention templates.
The section for response templates (http://wiki.alfresco.com/wiki/Web_Scripts#Creating_a_Response_Template) does not mention a possible inclusion of java returned results.

I haven't been able to find a reference that listed all variables available to the template under Alfresco. Does such a reference exist ?

Outcomes