freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Woonsan Ko (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FREEMARKER-55) FM3 freemarker-spring module, Web MVC support
Date Tue, 04 Jul 2017 04:40:00 GMT

    [ https://issues.apache.org/jira/browse/FREEMARKER-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16073099#comment-16073099
] 

Woonsan Ko commented on FREEMARKER-55:
--------------------------------------

Initial pull request submitted:
- https://github.com/apache/incubator-freemarker/pull/25

This initial pull request contains the following:
- FreemarkerView and FreemarkerViewResolver. So, it is now possible to use this new view and
resolver with the ConfigurationFactoryBean, I think, with a configuration like the following:
{code}
  <bean id="fmTemplateLoader" class="org.apache.freemarker.spring.templateresolver.SpringResourceTemplateLoader">
    <property name="baseLocation" value="/WEB-INF/templates" />
  </bean>

  <bean id="fmConfiguration" class="org.apache.freemarker.spring.ConfigurationFactoryBean">
    <property name="settings">
      <props>
        <prop key="source_encoding">UTF-8</prop>
        <prop key="whitespace_stripping">true</prop>
        <prop key="template_cache_storage">strong:20, soft:250</prop>
     </props>
   </property>
   <property name="autoImports">
      <map>
        <entry key="mylib1" value="/libs/mylib1.ftl" />
        <entry key="mylib2" value="/libs/mylib2.ftl" />
      </map>
    </property>
    <property name="templateLoader" ref="templateLoader" />
  </bean>

  <bean id="fmViewResolver" class="org.apache.freemarker.spring.web.view.FreemarkerViewResolver">
    <property name="configuration" ref="fmConfiguration" />
  </bean>
{code}
- So, we don't need something like {{FreeMarkerConfigurer}} which is referred to implicitly
by type in spring lib, but the view resolver should be configured with a {{Configuration}}
explicitly.
- As {{FreeMarkerViewResolver}} extends {{AbstractTemplateViewResolver}} of spring, I believe
the existing macros of spring should be supported as-is. I didn't verify this though.
- Still we will probably need to consider how we can provide better "custom directives/methods"
for templating in spring env than the existing ones in spring lib.
- FreemarkerViewResolver exposes servlet context model, request attribute/parameter models,
session model and JSP TaglibFactory,  by default, like FreemarkerServlet does.
  (I just thought it wouldn't do any harm by providing those by default. Not sure yet if we
should make them optional.)

TODOs:
- See if we can support {{@EnableWebMvc}} (note that FreeMarker 2 support is hard coded into
ViewResolverRegistry, which we can't modify)
- Consider better "custom directives/methods" for templating in spring env.
- Integration testing in a simple web application module?

> FM3 freemarker-spring module, Web MVC support
> ---------------------------------------------
>
>                 Key: FREEMARKER-55
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-55
>             Project: Apache Freemarker
>          Issue Type: Task
>    Affects Versions: 3.0.0
>            Reporter: Daniel Dekany
>
> Add Spring "Web MVC framework" functionality to freemarker-spring.
> This can be complex task (and the issue possibly has to be subdivided), as it involves
things like:
> * Some aspects of the FreeMarker 2 integration (developed by the Spring developers) are
quite confusing ({{FreemarerConfigurer}}, etc.), and we are looking into if it needs to be
like that.
> * See if we can support {{@EnableWebMvc}} (note that FreeMarker 2 support is hard coded
into {{ViewResolverRegistry}}, which we can't modify)
> * Creating custom directives/methods to expose Spring features like the Spring JSP Tag
Library does (but in a way that firs FreeMarker better)
> * Expose JSP custom tag support from the {{freemarker-servlet}} module.
> Depends on: FREEMARKER-54



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message