AnsweredAssumed Answered

Template Question

Question asked by rich.weiskopf on Jul 9, 2006
1.   Generated codeBase: rev36 from svn
   Windows XP

2.   Created a template genModelNames.ftl (these 2 lines were its only contents):



2.   Using jsp example from, created a jsp, and put it into a dialog

   <%@ taglib uri="" prefix="h" %>
   <%@ taglib uri="" prefix="f" %>
   <%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
   <%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>

   <r:template template="alfresco/templates/genModelNames.ftl" model="#{TestTemplateBB.templateModel}"

3.   Created a TestTemplateBB per example:

     public Map getTemplateModel()

        HashMap model = new HashMap(1, 1.0f);
        TemplateNode documentNode = new TemplateNode(browseBean.getDocument().getNodeRef(),
        model.put("document", documentNode);
        return model;

4.   Received error message when accesing genModelNames.ftl:
   Expression is undefined on line 4, column 3 in alfresco/templates/genModelNames.ftl.
   The problematic instruction:
   ==> ${} [on line 4, column 1 in alfresco/templates/genModelNames.ftl]

   Note: Also received this error where accessing  from 'Preview in template'

5.   Modified genModelNames.ftl (copied table snippet from wiki page):


   <#– Get a list of all the property names for the document –>
   <#assign props =>
   <#list props as t>
         <#– If the property exists –>
             <#– If it is a date, format it accordingly–>
             <tr><td>${t} = ${[t]?date}</td></tr>
             <#– If it is a boolean, format it accordingly–>
             <tr><td>${t} = ${[t]?string("yes", "no")}</td></tr>
             <#– Otherwise treat it as a string –>
             <tr><td>${t} = ${[t]}</td></tr>

6.   Got results of:
   {}modelDirectoryName = testmodel

7.   Removed final from TemplateNode so it could be extended, and created MyTemplateNode

8.   Overrode getProperties and replaced:, propValue);


, propValue);

9.   Executed genModelNames.ftl as defined in #5
   a.   It accessed correctly; returning value of: testmodel

   b.   It also prepended the localname with the cm: URI
      {}modelDirectoryName = testmodel

10.   Is there someplace to register custom model URI's so freemarker can deal with them without resorting to the localname?