How To Use JSP Custom Tag Within Freemarker Template Page?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How To Use JSP Custom Tag Within Freemarker Template Page?

BrettS
Hi,

I am attempting to use a custom JSP tag within a Freemarker template within OFBiz without success.

In a JSP, the tag syntax is as follows:
<%@ taglib uri="/WEB-INF/imps.tld" prefix="imps"%>
<imps:xhtmldoctype request="<%=request%>"/>


So, I attempted the following in Freemarker:
<#assign imps=JspTaglibs["/WEB-INF/imps.tld"]>
<@imps.xhtmldoctype request=request />


However, the second line throws this error:
%{#request} Could not find an instance of
freemarker.ext.servlet.ServletContextHashModel in the data model under either the name __FreeMarkerServlet.Application__ or Application
The problematic instruction: ---------- ==> user-directive imps.xhtmldoctype
[on line 5, column 1 in mobile.ftl]

I do not know if my tag syntax is incorrect or, There is something I need to configure elsewhere or, if Freemarker within OFBiz supports custom JSP tags.

I did find this in controller.xml
<handler name="ftl" type="view" class="org.ofbiz.webapp.ftl.FreeMarkerViewHandler"/> 
I'm a total newbie to OFBiz and Freemarker, but I'm guessing this is not the same handler as standalone Freemarker.

Thank you.

Regards Brett S
Reply | Threaded
Open this post in threaded view
|

Re: How To Use JSP Custom Tag Within Freemarker Template Page?

BrettS
Hi,

I am *still* failing to get a JSP tag working in an FTL file. Since last time, I have added the following to web.xml.
(so I am using the stock freemarker.ext.servlet.FreemarkerServlet)
----------------------------------------
<servlet>
  <servlet-name>freemarker</servlet-name>
  <servlet-class>freemarker.ext.servlet.FreemarkerServlet</servlet-class>
       
 
  <init-param>
        <param-name>TemplatePath</param-name>
        <param-value>/</param-value>
  </init-param>
  <init-param>
        <param-name>NoCache</param-name>
        <param-value>true</param-value>
  </init-param>
  <init-param>
        <param-name>ContentType</param-name>
        <param-value>text/html; charset=UTF-8</param-value> 
  </init-param>
       
 
  <init-param>
        <param-name>template_update_delay</param-name>
        <param-value>0</param-value> 
  </init-param>
  <init-param>
        <param-name>default_encoding</param-name>
        <param-value>ISO-8859-1</param-value> 
  </init-param>
  <init-param>
        <param-name>number_format</param-name>
        <param-value>0.##########</param-value>
  </init-param>

  <load-on-startup>3</load-on-startup>
</servlet>


<servlet-mapping>
  <servlet-name>freemarker</servlet-name>
  <url-pattern>*.ftl</url-pattern>
</servlet-mapping> 
----------------------------------------

However, when I attempt the following in Freemarker:
<#assign imps=JspTaglibs["/WEB-INF/imps.tld"]>
<@imps.xhtmldoctype request=request />

I still get this message:
"Could not find an instance of freemarker.ext.servlet.ServletContextHashModel in the data model under either the name __FreeMarkerServlet.Application__ or Application"

Any suggestions?

Regards

Brett S