Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.8
-
None
-
Patch, Important
Description
Current issues include:
- limiting decorators to use 1 technology (Freemarker, Velocity, or JSP) only. SiteMesh should be able to use any of the three decorators as definied in decorators.xml
- velocity struts tags and toolchain not available to velocity decorators, .
- freemarker statics and manager configuration not available to freemarker decorators.
- in general, the decorators use a completely different manager.
- problems mixing freemarker decorators with velocity/jsp results and vice versa.
This improvement/patch will use the SiteMeshFilter provided by SiteMesh and implement a Freemarker and Velocity dispatcher that uses the appropriate Managers in Struts 2 to create their contexts and configurations, as well as share the same model when available. If the context has not been created for that technology, the Struts Manager will be asked to construct one. Since many of these configurations were constructed multiple times, there should be a small speed improvement as well. Once implemented, there will not be a restriction on decorators.xml on which technology is being used, and the same context will be available to the decorators as is available to the results.
The new web.xml will look like this (configuration to use all three technologies).
<filter>
<filter-name>struts-prepare</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>net.stonescape.renegade20.presentation</param-value>
</init-param>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter>
<filter-name>struts-execute</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts-execute</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>sitemesh-freemarker</servlet-name>
<servlet-class>org.apache.struts2.sitemesh.FreemarkerDecoratorServlet</servlet-class>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>sitemesh-velocity</servlet-name>
<servlet-class>org.apache.struts2.sitemesh.VelocityDecoratorServlet</servlet-class>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sitemesh-velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JspSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>