AnsweredAssumed Answered

FTL file Error

Question asked by vesuinfo on Jul 27, 2009
Hi All,

I have created a New Web Project in WCM, and i have added Web Forms for my webproject.
In WebForms if i try to use "Render Engine Template" as FTL, its not working properly.

I have added template variable to identify the User Agent in Work Flow Template by adding a new method in WorkFlow.java file and i am able to view the User Agent value sucessfully if i try to access in FTL files which is present in "DataDictionary\PresentationTemplates\*.FTL"

I have added ${Workflow.UserAgent()} it prints the userAgent value properly, but if I TRY TO USE THE SAME IN "RENDER ENGINE TEMPLATE" in WebForms, i am getting error message and i didnt get the USERAGENT value.

"Please correct the errors below then click Finish.
    * Error generating rendition using content.ftl: freemarker.template.TemplateException: Expected method. workflow.UserAgent evaluated instead to freemarker.ext.dom.NodeListModel on line 5, column 25 in freemarker_template."

Stack trace:
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)
Caused by: freemarker.template.TemplateException: Expected method. workflow.UserAgent evaluated instead to freemarker.ext.dom.NodeListModel on line 5, column 25 in freemarker_template.
        at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
        at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:114)
        at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
        at freemarker.core.Assignment.accept(Assignment.java:90)
        at freemarker.core.Environment.visit(Environment.java:208)
        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:208)
        at freemarker.core.Environment.process(Environment.java:188)
        at freemarker.template.Template.process(Template.java:237)
        at org.alfresco.web.forms.FreeMarkerRenderingEngine.render(FreeMarkerRenderingEngine.java:134)
        … 55 more

please let me know, how to get the ftl value in the "Render Template Engine FTL" file.

My XSD and FTL file details:

XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:as="http://www.alfresco.org/alfresco/as"
           targetNamespace="http://www.alfresco.org/alfresco/as"
elementFormDefault="qualified">
  <xs:element name="simple">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="string" type="xs:normalizedString"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

FTL:

<#ftl ns_prefixes={"D", "http://www.alfresco.org/alfresco/as"}>
   ${simple.string}
   <#assign useragent = workflow.UserAgent()>
  ${useragent}


please help me, if i am doing some thing wrong ?

Outcomes