Configuration
Action Mapping
Please see http://cwiki.apache.org/WW/convention-plugin.html for more details - we are planning to switch to the Conventions plugin as it is a superior action mapping tool than the previous version (2.1.2) of Struts that we were using. However, there is currently a bug in XWork 2.1.2 (or OGNL, not sure yet) that has not been fixed yet, see https://issues.apache.org/struts/browse/WW-2971 for more details.
There are currently two ways to map actions in the Struts 2 version of tDAR:
- Explicit mapping in
WEB-INF/classes/struts.xml
- implicit mapping in the filesystem, where a
.ftl
or.jsp
file insrc/main/webapp
is parsed and delivered for content.Implicit mapping example
If you create a file, test.ftl in the
src/main/webapp/blougat
directory, then you should be able to see the contents of that file athttp://localhost:8080/tdar/blougat/test
Deprecated
Notes: Using custom org.tdar.struts.TdarActionMapper
- tried to get CompositeActionMapper working to map the empty action context but was unsuccessful (and documentation on the Struts site is inaccurate). TdarActionMapper
is basically the same thing as the Restful2ActionMapper, just set up so that we can understand the process of action mapping more closely. Subsequent changes in Struts action mapping, e.g., the Conventions plug-in, should be monitored and patched with TdarActionMapper (or replace it entirely).
<constant name='struts.mapper.class' value='org.apache.struts2.dispatcher.mapper.Restful2ActionMapper'/> <constant name='struts.enable.SlashesInActionNames' value='true'/>
Implementation
Consider using Spring Webflow for resource editing and registration. Goal is to have a TurboTax-like workflow.
Miscellaneous Issues / Notes
Spring uses JDK dynamic proxies by default, which means that any autowired proxied class (i.e., the *Service classes, etc.) get injected with the interface type, not the concrete class. For example, if UniqueEmailValidator wants a PersonService to talk to, it will only get a Service from Spring unless explicitly wired. In order to overcome this, need to set
<tx:annotation-driven proxy-target-class='true' />
External links to Struts 2 documentation
- Ajax: http://struts.apache.org/2.x/docs/ajax.html
- Annotations: http://struts.apache.org/2.x/docs/annotations.html
- Conventions: http://struts.apache.org/2.x/docs/convention-plugin.html
- Freemarker tags: http://struts.apache.org/2.x/docs/freemarker-tags.html
- Interceptors: http://struts.apache.org/2.x/docs/interceptors.html
- Tags: http://struts.apache.org/2.x/docs/tag-reference.html
- Themes and Templates: http://struts.apache.org/2.x/docs/themes-and-templates.html
- Type conversion: http://struts.apache.org/2.x/docs/type-conversion.html
- Validation: http://struts.apache.org/2.x/docs/validation.html