You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by BrettS <br...@gmail.com> on 2010/03/09 09:02:50 UTC

How To Use JSP Custom Tag Within Freemarker Template Page?

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
-- 
View this message in context: http://n4.nabble.com/How-To-Use-JSP-Custom-Tag-Within-Freemarker-Template-Page-tp1585638p1585638.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

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

Posted by BrettS <br...@gmail.com>.
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>
	
  <!-- FreemarkerServlet settings: -->
  <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> <!-- Forces UTF-8
output encoding! -->
  </init-param>
	
  <!-- FreeMarker settings: -->
  <init-param>
	<param-name>template_update_delay</param-name>
	<param-value>0</param-value> <!-- 0 is for development only! Use higher
value otherwise. -->
  </init-param>
  <init-param>
	<param-name>default_encoding</param-name>
	<param-value>ISO-8859-1</param-value> <!-- The encoding of the template
files. -->
  </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

-- 
View this message in context: http://ofbiz.135035.n4.nabble.com/How-To-Use-JSP-Custom-Tag-Within-Freemarker-Template-Page-tp1585638p2022927.html
Sent from the OFBiz - User mailing list archive at Nabble.com.