Re: Is MessageFormat supported?

[email protected]
Newsgroups gmane.comp.web.freemarker.user
Message-ID <OFD0784A52.10EAC81B-ON8725765B.0056BA6F-8725765B.0058DFEA@blm.gov>
Building the app so that ant TemplateModel classes are in the classpath
isn't a problem - it's essentially automatic. Adding TemplateMethodModel
and TemplateDirectiveModel instances to the FreeMarker shared variables via
the Spring configuration gives a number of advantages - for example, I have
beans containing helper classes for i18n & localization that are used by
the Spring controllers and are also useful during the View phase, and being
able to use Spring's dependency injection to make these available to those
TemplateXModel instances is a better solution for a number of reasons -
everything is gathered in one XML configuration file, the components are
instantiated once and once only during application startup and not
recreated for every template render, we don't have obscure assignments
hidden away in various template files, and I don't have to worry about my
developers forgetting the necessary include/import statements in their FTL
files. Sure, doing things the other way has value but at the end of the day
the options are open and it's up to the designer to figure out what's best
for a specific application. In this case, I'm confident that making use of
the Spring features is the better way to go.

To get back to the problem I was having, it turns out that you can
configure all the FreeMarker settings using the "setFreemarkerSettings()"
and "setFreemarkerVariables()" methods in the Spring MVC FreeMarker
Configurer (I was trying to use "settings" rather than "freemarkerSettings"
as the property name in the Spring XML - no wonder it didn't work). With
that corrected my application is now working correctly.

Daniel Dekany <[email protected]> wrote on 10/23/2009 05:19:08 PM:

> Friday, October 23, 2009, 10:58:22 PM, [email protected] wrote:
>
> >
> > Daniel Dekany <[email protected]> wrote on 10/22/2009 10:09:20 AM:
> >
> >> Thursday, October 22, 2009, 5:58:34 PM, [email protected] wrote:
> >>
> >> >
> >> > Actually I have it set up as a shared variable when I create the
> >> > Configuration.
> >>
> >> Don't... A year later you won't understand where did "messageFormat"
> >> gone. Better said, if where did it come earlier.
> >>
> >
> > According to the documentation I can set this as a shared variable in
the
> > SpringMVC View Resolvers configuration (specifically on the
> > FreeMarkerConfigurer bean definition). For the app I'm working on this
is
> > by far the best place to set this up (assuming it works... I've had
some
> > problems getting the Spring configurer to play nice with the FreeMarker
> > Configuration, such as not being able to use FreeMarker's
"setSettings()"
> > method because the Spring developers didn't include that in the
> > FreeMarkerConfigurer class).
> [snip]
>
> What I'm saying is that you have a #include-ed or #import-ed file
> somewhere anyway, and you need that TemplateMethodModel modell class
> in the "class path" somewhere too. That's already two things to care
> about. Adding a shared variable, which happens on a yet another
> separate place, is a third thing to care about. But, it's needless,
> because you can just pull that TemplateMethodModel inside that
> #include-ed/#import-ed file, and that's it. One less thing that can
> break later... It's a maintenance thing.
>
> --
> Best regards,
>  Daniel Dekany
>
>
>
------------------------------------------------------------------------------

> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay

> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.