This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Spring4, Tiles and Freemarker integration problems

 
Ranch Hand
Posts: 111
PHP Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my Spring MVC project I use Tiles to eliminate any redundant page structure code. As a view renderer, I first chose Thymeleaf because it was descreibed as a primising new kid on the block and pretty easy to use.
Unfortuantely, the integration of Thymeleaf with Tiles depends on deprecated Spring (Tiles2) classes, furthermore the only Thymeleaf forum is almost inactive and questions mostly remain unanswered.

Therefore I want to switch to Freemarker because it has a well established user community and is also supported by Spring. But the configuration of the integrated Spring MVC, Tiles3 and Freemarker is apparently not documented and most examples on the internet are using Tiles in combination of JSP or Freemarker without Tiles, but I cannot find a clear, working integrated example.

I am not very experienced with Spring MVC and confugurations, but I think the following issues must be addressed:

-Loading the Tiles definition file. According to some examples, it can be done using following method in the MvcConfig class:



-Resolving the returning String from a controller method to a Tiles definition:



My first question is whether this Tiles view resolver should be in some way "Freemarker-aware". According to the Tiles documentation, the attribute 'type="freemarker"' should be added to the <definition> tag as well as to the <put-attribute> tags in the Tiles definition XML file, but is it unclear to me what is the effect of that.
Furthermore, the fragments as referenced in the value attribute of those put-attribute tags must be parsed as Freemarker templates instead of JSP. I do not see how this should be configured.

In fact it is unclear to me how the lookup/resolving proces from a Tiles fragment in Spring works. Is the extension .ftl anough for Spring to know that is should look for a Freemarker template?

Some examples lists code fragments like these:



Is this method enough for Spring MVC to load the Freemarker templates from the Tiles definition? How does Spring "know" that a template referenced by Tiles is actually a Freemarker template? There also exists a FreeMarkerViewResolver class which extends UrlBasedViewResolver. But is is unclear to me whether and how we should use this class.

I hope for some clarification and maybe even an integration example

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also facing the same issue. Without type"freemarker" it doesn't recognise the file at all. With type"freemarker" an error is displayed that freemarker renderer is not registered.
 
Shiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!