Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-1052

Support for jsp taglibs in freemarker templates

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0 M5
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      It would be nice if Spring had support for jsp taglibs like f.x.

      <#assign tolog=JspTaglibs["/WEB-INF/jsp/tolog.tld"]>

      as decribed on http://fmpp.sourceforge.net/freemarker/pgui_misc_servlet.html (see the heading "Using JSP custom tags in FTL")

        Activity

        kajh Kaj Hejer created issue -
        Hide
        kajh Kaj Hejer added a comment -

        There is a thread about this issue in the forum, see http://forum.springframework.org/viewtopic.php?t=905

        Show
        kajh Kaj Hejer added a comment - There is a thread about this issue in the forum, see http://forum.springframework.org/viewtopic.php?t=905
        Show
        turelto Tom Turelinckx added a comment - I wrote an article about this: http://opensource.atlassian.com/confluence/spring/display/INTEGRATE/Using+JSP+taglibs+with+FreeMarkerView
        Hide
        turelto Tom Turelinckx added a comment -

        Source code from the article.

        Show
        turelto Tom Turelinckx added a comment - Source code from the article.
        turelto Tom Turelinckx made changes -
        Field Original Value New Value
        Attachment TaglibFreeMarkerView.zip [ 10881 ]
        juergen.hoeller Juergen Hoeller made changes -
        Fix Version/s 1.2.3 [ 10260 ]
        Hide
        turelto Tom Turelinckx added a comment -

        FYI, I received this email from someone who's been using the code in my article:

        Hi Tom,

        Just an update on your code to get JspTaglibs working in Spring
        Freemarker installations.....

        It seems to work flawlessly. I've migrated all of my functionality to
        use the code and seen no problems.

        It seems to a good piece of work - I encourage you to get this into
        Spring, it something I know that I want, something in the Spring JIRA,
        and something I know a few other J2EE people want.

        Thanks for a fine piece of work,
        Dean.

        Show
        turelto Tom Turelinckx added a comment - FYI, I received this email from someone who's been using the code in my article: Hi Tom, Just an update on your code to get JspTaglibs working in Spring Freemarker installations..... It seems to work flawlessly. I've migrated all of my functionality to use the code and seen no problems. It seems to a good piece of work - I encourage you to get this into Spring, it something I know that I want, something in the Spring JIRA, and something I know a few other J2EE people want. Thanks for a fine piece of work, Dean.
        juergen.hoeller Juergen Hoeller made changes -
        Fix Version/s 1.2.3 [ 10260 ]
        Fix Version/s 1.3 RC1 [ 10131 ]
        Hide
        erik Erik Pedersen added a comment -

        I tested this implementation. I had to create a new view resolver to make this work the way I needed.

        It works great.

        See:

        http://forum.springframework.org/viewtopic.php?t=905&postdays=0&postorder=asc&start=15

        Show
        erik Erik Pedersen added a comment - I tested this implementation. I had to create a new view resolver to make this work the way I needed. It works great. See: http://forum.springframework.org/viewtopic.php?t=905&postdays=0&postorder=asc&start=15
        juergen.hoeller Juergen Hoeller made changes -
        Fix Version/s 2.0 M2 [ 10290 ]
        Fix Version/s 2.0 M1 [ 10131 ]
        juergen.hoeller Juergen Hoeller made changes -
        Fix Version/s 2.0 RC1 [ 10220 ]
        Fix Version/s 2.0 M2 [ 10290 ]
        Environment
        Description It would be nice if Spring had support for jsp taglibs like f.x.

        <#assign tolog=JspTaglibs["/WEB-INF/jsp/tolog.tld"]>

        as decribed on http://fmpp.sourceforge.net/freemarker/pgui_misc_servlet.html (see the heading "Using JSP custom tags in FTL")


        It would be nice if Spring had support for jsp taglibs like f.x.

        <#assign tolog=JspTaglibs["/WEB-INF/jsp/tolog.tld"]>

        as decribed on http://fmpp.sourceforge.net/freemarker/pgui_misc_servlet.html (see the heading "Using JSP custom tags in FTL")


        robh Rob Harrop made changes -
        Assignee Juergen Hoeller [ juergen.hoeller ] Rob Harrop [ robh ]
        Hide
        robh Rob Harrop added a comment -

        All,

        I updated FreeMarkerView and FreeMarkerConfigurer as appropriate so this should now just work. Can anyone who needs this feature please try it out. I gave it a basic run in a local Tomcat but feedback from a real usage scenario would be great.

        Rob

        Show
        robh Rob Harrop added a comment - All, I updated FreeMarkerView and FreeMarkerConfigurer as appropriate so this should now just work . Can anyone who needs this feature please try it out. I gave it a basic run in a local Tomcat but feedback from a real usage scenario would be great. Rob
        robh Rob Harrop made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        turelto Tom Turelinckx added a comment -

        Rob,

        I've just replaced all usages of TaglibFreeMarkerView with the regular FreeMarkerView in several of our real-world applications which heavily use the taglib functionality, and it seems to work just fine! Waiting for RC1 to deploy into production...

        Tom

        Show
        turelto Tom Turelinckx added a comment - Rob, I've just replaced all usages of TaglibFreeMarkerView with the regular FreeMarkerView in several of our real-world applications which heavily use the taglib functionality, and it seems to work just fine! Waiting for RC1 to deploy into production... Tom
        Hide
        nrichards Nick Richards added a comment -

        To quote Homer, "Holy Macaroni!". Integrating both Erik's and Tom's code gives me JspTaglibs access in my out of the box spring + freemarker setup. Thanks very much! (and to the rest of the Spring folks too!)

        This JspTaglibs support really needs to be made a part of Spring, or made into a filter. Immediately after discovering the no-taglibs limitation with the out of the box Spring integration, I felt like I had to drop FreeMarker...that was a "deal breaker".

        I opted to drop Tom's Views.properties and go with Erik's bean config xml. Here's mine:

        <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
        </bean>
        <bean id="freemarkerServletContextModel"
        class="springext.web.servlet.view.freemarker.support.ServletContextModelFactoryBean"/>
        <bean id="freemarkerTaglibFactory"
        class="springext.web.servlet.view.freemarker.support.TaglibFactoryBean"/>
        <bean id="viewResolver"
        class="springext.web.servlet.view.freemarker.TaglibFreeMarkerViewResolver">
        <property name="servletContextModel" ref="freemarkerServletContextModel" />
        <property name="taglibFactory" ref="freemarkerTaglibFactory" />
        <property name="cache" value="true" />
        <property name="prefix" value="" />
        <property name="suffix" value=".ftl" />
        <property name="exposeSpringMacroHelpers"
        value="true" />
        </bean>

        Nick

        Show
        nrichards Nick Richards added a comment - To quote Homer, "Holy Macaroni!". Integrating both Erik's and Tom's code gives me JspTaglibs access in my out of the box spring + freemarker setup. Thanks very much! (and to the rest of the Spring folks too!) This JspTaglibs support really needs to be made a part of Spring, or made into a filter. Immediately after discovering the no-taglibs limitation with the out of the box Spring integration, I felt like I had to drop FreeMarker...that was a "deal breaker". I opted to drop Tom's Views.properties and go with Erik's bean config xml. Here's mine: <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF/ftl/"/> </bean> <bean id="freemarkerServletContextModel" class="springext.web.servlet.view.freemarker.support.ServletContextModelFactoryBean"/> <bean id="freemarkerTaglibFactory" class="springext.web.servlet.view.freemarker.support.TaglibFactoryBean"/> <bean id="viewResolver" class="springext.web.servlet.view.freemarker.TaglibFreeMarkerViewResolver"> <property name="servletContextModel" ref="freemarkerServletContextModel" /> <property name="taglibFactory" ref="freemarkerTaglibFactory" /> <property name="cache" value="true" /> <property name="prefix" value="" /> <property name="suffix" value=".ftl" /> <property name="exposeSpringMacroHelpers" value="true" /> </bean> Nick
        Hide
        nrichards Nick Richards added a comment -

        FYI I am still on 1.2.6, not sure about jumping to 2.0, worried about destabilization.... Cheers.

        Show
        nrichards Nick Richards added a comment - FYI I am still on 1.2.6, not sure about jumping to 2.0, worried about destabilization.... Cheers.
        Hide
        walbar Waldemar Baraldi added a comment -

        I have started a new thread in the forum regarding an issue using this feature.

        http://forum.springframework.org/showthread.php?t=35156

        Show
        walbar Waldemar Baraldi added a comment - I have started a new thread in the forum regarding an issue using this feature. http://forum.springframework.org/showthread.php?t=35156
        tmarshall Trevor Marshall made changes -
        Workflow jira [ 11771 ] SPR Workflow [ 38361 ]
        cbeams Chris Beams made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        tmarshall Trevor Marshall made changes -
        Workflow SPR Workflow [ 38361 ] New SPR Workflow [ 64218 ]
        tmarshall Trevor Marshall made changes -
        Workflow New SPR Workflow [ 64218 ] SPR Workflow [ 73660 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        320d 19h 58m 1 Rob Harrop 04/May/06 1:15 AM
        Resolved Resolved Closed Closed
        2238d 2h 39m 1 Chris Beams 19/Jun/12 3:54 AM

          People

          • Assignee:
            robh Rob Harrop
            Reporter:
            kajh Kaj Hejer
            Last updater:
            Trevor Marshall
          • Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              10 years, 32 weeks ago