Canadensys / vascan

The Database of Vascular Plants of Canada
MIT License
2 stars 2 forks source link

Render pages using SiteMesh 3 #23

Closed cgendreau closed 9 years ago

cgendreau commented 9 years ago

Vascan should start to use the canadensys-web-core and canadensys-web-theme projects. Those components should be resused in Canadensys web apps. SiteMesh3 is required in order to reuse the Canadensys theme but is also very useful to simplify page layout.

cgendreau commented 9 years ago

2 possible solutions:

Spring Freemarker ViewResolver

Reuse the Freemarker ViewResolver to resolve the decorator templates by simply adding a @RequestMapping annotation for /decorators/* in the controller. Then, return a ModelAndView object for the decorator. This solution is fast to implement but brings new issues. It exposes the URL for the layout so an internal check must be done to only accept internal forwards. It also becomes error prone in case a decorator and a view would have the same name since they both load from the same ViewResolver.

ServletWrappingController

Use the ServletWrappingController to wrap our implementation of FreemarkerServlet. Then, use SimpleUrlHandlerMapping to map decorator URLs to our controller. Note that ServletWrappingController will not give the expected result when calling getPathInfo (always null), this needs to be solved in our FreemarkerServlet implementation.

dshorthouse commented 9 years ago

Which of the two solutions are easiest to maintain and least prone to confusion later? At first glance, it seems like the second solution is best to avoid potential clashes with decorator and view naming.

cgendreau commented 9 years ago

yes the second solution will be used.

cgendreau commented 9 years ago

For the records, ServletWrappingController will not used because dependency injection is required by our setup. Instead, we will instantiate our SpringFreemarkerDecoratorServlet and use it with Spring's SimpleServletHandlerAdapter.