Albert Kam
2013-02-10 04:58:54 UTC
I want to use freemarker's multiple StringTemplateLoader-s per each
request. This means that i will have to new Configuration() per each
request, right ?
I wonder if this is the right way to do it, since i've read somewhere that
Configuration should be initialized once per webapp because it's expensive ?
Why do i need this approach is because i want to get locale specific
templates per request, which i put inside a properties file, and then fill
up the templates.
Example of the entry in the properties file :
my.template.key1=my.freemarker.template1.here
my.template.key2=my.freemarker.template2.here
So the logic what i have in mind is :
- i have the keys in the UI (dynamiclly obtained)
- i load templates with resourcebundle depending of current user's locale
- initialize configuration object
- setup multiple string template loaders with those i load from
resourcebundle and set them to configuration object via MultiTemplateLoader
- setup the models n get the template outputs
- print them onto UI response
All of these can happen per web request.
Is this approach appropriate ? Thank you !
request. This means that i will have to new Configuration() per each
request, right ?
I wonder if this is the right way to do it, since i've read somewhere that
Configuration should be initialized once per webapp because it's expensive ?
Why do i need this approach is because i want to get locale specific
templates per request, which i put inside a properties file, and then fill
up the templates.
Example of the entry in the properties file :
my.template.key1=my.freemarker.template1.here
my.template.key2=my.freemarker.template2.here
So the logic what i have in mind is :
- i have the keys in the UI (dynamiclly obtained)
- i load templates with resourcebundle depending of current user's locale
- initialize configuration object
- setup multiple string template loaders with those i load from
resourcebundle and set them to configuration object via MultiTemplateLoader
- setup the models n get the template outputs
- print them onto UI response
All of these can happen per web request.
Is this approach appropriate ? Thank you !
--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)