aspose file tools*
The moose likes JForum and the fly likes Freemarker and include_page directive - Almost there I think Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Freemarker and include_page directive - Almost there I think" Watch "Freemarker and include_page directive - Almost there I think" New topic
Author

Freemarker and include_page directive - Almost there I think

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi there,

I've been trying to get freemarker to be able to perform a include in the same way as a jsp page does. As of Freemarker 2.3.15 this possible according to the manual (extract below)

Including content from other web application resources

You can use the <@include_page path="..."/> custom directive provided by the FreemarkerServlet (since 2.3.15) to include the contents of another web application resource into the output; this is often useful to integrate output of JSP pages (living alongside the FreeMarker templates in the same web server) into the FreeMarker template output. Using:

<@include_page path="path/to/some.jsp"/>

is identical to using this tag in JSP:

<jsp:include page="path/to/some.jsp">


I noticed that jforum uses the 2.3.9 jar file so I have replace this with the 2.3.15 but if I try to use this directive I get a message telling me the directive can not be found:
on line 8, column 1 in default/header.htm include_page not found. The problematic instruction:


There is a note in the documentation that if the Application does not use freemarker.ext.servlet.FreemarkerServlet then this functionality is not available. My question is how do I get Jforum to use this? I have the src code from cvs in eclipse and I've tried a few things in the JForumBaseServlet but I can't seem to figure out how to get JForum to use this.

Any advice would be greatly appreciated!

Best regards

David




[originally posted on jforum.net by daverh]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Don't know about freemarker and jsp, but I do know that jForum does use the servlet.

Instead, it creates a Freemarker TemplateConfig object in the JForumBaseServlet. Then uses this to get the FreeMarker template object in the Command object, process method. Which has it's process method called in the JForum.processCommand method.

Note, there may be a few other places that templates get processed or created via the TemplateConfig (like in the install servlet). So, you may need to search around a bit to make sure.

I wonder if you can add the right options to the TemplateConfig to get this to work?
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi Monroe

Thanks, I notice there are a couple of methods available for Configuration that look like they might work but I don't seem to be able to get them to work and I don't seem to be able to find any documentation to explain how to do it.

You mentione that JForum does use the servlet but I couldn't see where this is being set up?

I've posted a message on the freemarker site too so hopefully someone will get back to me on how to get this working from there

Best regards

David
[originally posted on jforum.net by daverh]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Sigh... typo on my part... should be "does NOT use the servlet".... sorry.
[originally posted on jforum.net by monroe]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Freemarker and include_page directive - Almost there I think