• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Freemarker support for JSP taglibs in JForum

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to integrate JForum with my site, I'd like to be able to use some custom tags and other JSP features in the header and footer templates.

According to the freemarker docs, it directly supports using JSP tags like so:
<#assign bean=JspTaglibs["/WEB-INF/mytaglib.tld"]>

It turns out that this causes an "Expression JspTaglibs is undefined" error. What seems to be the problem is that JForum doesn't use the "TaglibFactory" model which is needed for Freemarker to support taglibs.

Now I don't really know anything about freemarker except what I've learned today, but I'm not sure why this can't be added. Tt looks like JForum just directly uses the Freemarker library with a "SimpleHash" as the model instead of using the Freemarker servlet. But in keeping with this system, can we also add support for the TaglibFactory model?

I'm comfortable making the changes myself, but I could use some suggestions to point me in the right direction.

Thanks!
[originally posted on jforum.net by csbook]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there.

Did you manage to workaround this issue. I am just getting started with jforum and I need to include a common header from another jsp file that is using struts taglibs. I have tried adding com.opensymphony.webwork.views.JspSupportServlet to web.xml but I still get following error ;

assignment: html=JspTaglibs["/WEB-INF/struts-html.tld"] [on line 5, column 1 in default/header.htm] in include "header.htm" [on line 1, column 1 in default/forum_list.htm] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression JspTaglibs is undefined on line 5, column 15 in default/header.htm. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)

Is there any alternate way to integrate jsp struts html tags into freemarker template?

Thanks.
[originally posted on jforum.net by shah_m]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, I know this post is a bit late, but maybe it can be helpful to people who are still having this problem.

I had this same error when I was trying to put custom tags into some of the JForum pages and I managed to get it working (I am using JForum 2.1.8 ). The problem is due to the fact that there are some missing context attributes required by Freemarker for it to support custom tags.

Here is a link to the Freemarker manual where they explain how to integrate custom tags in your templates:
http://freemarker.sourceforge.net/docs/pgui_misc_servlet.html
Scroll down to the section titled "Using JSP custom tags in FTL"

To save you time, here is the code I added to the net.jforum.JForum class in the "service" method. I added the code just before the call to "processCommand"


Hope this helps,
Jason
[originally posted on jforum.net by marlingj]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Can you show the header.htm code where you inserted the JSP Tags.

Thanks,
Jude
[originally posted on jforum.net by judekm]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the code I used to include the tag lib on the page. The url you see here is the taglib uri and is the same one I defined in the TLD file for my tag library. You'll have to check your particular TLD file to know what your URL should be.


And this is the code I used to call one of the tags from my tag library. This tag doesn't have any attributes as you can see.

[originally posted on jforum.net by marlingj]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Taglib class is




The XML is



Its working but just wanted to make sure whether it is good enough for production.
[originally posted on jforum.net by judekm]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it works then it works. But there might be an easier way than implementing your own custom tag to do an include.

For instance you might try the Freemarker include directive which you could just put on the page you want to do the include from



Or you might also try to use the JSP include directive. I'm not sure how freemarker supports the built-in JSP tag lib though, so this one might not work.
[originally posted on jforum.net by marlingj]
 
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic