You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Current »
Benefits of MVC
- Data assembled by controllers can be presented by different views
- Site can be reskinned without touching the application logic
- Application logic can be re-factored without touching the presentation
- UI and Application teams can work with maximum independence
What is FreeMarker
- An all-purpose Java template engine for generating text output based on templates
- Not specifically designed to generate web pages, so text generation is independent of the servlet application architecture
FreeMarker Features
- Separation of application and presentation logic is enforced through:
- Syntactic limitations of the template language
- Exposure settings on the template data
- Only FTL is allowed in templates
- Template language
- Clean, simple, and consistent
- Just powerful enough
- Loops, conditionals, local variables, macros, object property access, convenient built-in functions
- String capture
- Controller can use the engine to generate a string without relinquishing control of the request
- Flexible and powerful API
- Thorough documentation
- API documentation
- Template developer documentation
- Active user mailing list
Two ways to use FreeMarker in VIVO
- Generate an entire page in FreeMarker
- This is the direction the application is moving in; transition is still incomplete
- Generate a string for use outside a FreeMarker page
- In the transition from JSPs, generate page headers, footers, menus, etc. using the same FreeMarker templates used in generating whole pages
- Email messages
- Ajax responses
Using FreeMarker
- processRequest() can return a different type of object to trigger a forward, redirect, or error
- Override FreemarkerHttpServlet.doGet()
- Use methods defined in FreemarkerHttpServlet as needed to generate a page
Resources
- JBoss Tools FreeMarker IDE for Eclipse
- vTextmate FreeMarker bundle