Struts 2.0.0 is the first distribution of WebWork 2 as an Apache Struts product.
The current snapshot is graded "test build" quality. It is "ready enough" for early development – but there are gaps in the documentation, and early testing will undoubtedly expose other oversights.
For your convenience, a one-stop all distribution is available. Individaul elements of the distribution may also be downloaded separately.
The entire distribution, including all the elements. (36mb) |
|
The example applications, as ready-to-deploy WARs. (27mb) |
|
Just the blank application, ready to deploy as a template for new development. (Also included in apps.) (4mb) |
|
The documentation, as provided on the website (currently only the welcome page Javadocs, not the wiki pages). (6mb) |
|
The essential dependencies, including the Struts 2 JARs. (3mb) |
|
The source code for the framework, ready to build as a Maven project. (18mb) |
- If you are a Maven developer, you might want to get started using the Maven Archetype.
- Another quick-start entry point is the blank application. Rename and deploy the WAR as a starting point for your own development.
Key Snippets
Maven Artifact ID
<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.0.0-SNAPSHOT</version> </dependency>
Struts Configuration DTD
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
Key Changes
Depending on whether you are coming from a WebWork 2 or Struts 1 background, your perspective on the key changes will differ.
From WebWork2
- Struts 2 is dependant on XWork 2 (nightly build).
- Java 1.5 is required to build the Struts 2 distribution from source, but Java 1.4 is targeted for the binary JARs.
- Rich text editor tag has been removed (a possible replacement would be to use the textarea tag with theme="ajax", this will used dojo's rich text editor)
<s:textarea theme="ajax" />
- Datepicker tag is now using dojo's (limited in terms functionality and internationalization)
- foo!bar functionality is off by default (could be truned on by having struts.compatibilityMode=true in struts.properties)
struts.properties
struts.compatibilityMode = true
- prepare interceptor now uses reflection to call prepareXXX where XXX is the action method configured for the particular action in struts.xml
<action name="myAction" method="execute" ....> ..... </action> // with the above configuration, and preparator interceptor in place, call // sequence will be 1] prepareExecute() 2] prepare() (could be left out depending on interceptor's alwaysInvokePreapre parameter) 3] execute()
- Default workflow interceptor (named workflow in struts-default.xml) now uses reflection to call validateXXX on the action class that implements Validateable interface where XXX is the action method configured for the particular action in struts.xml
<action name="myAction" method="execute" ...> ... </action> // with the above configuration, and workflow interceptor in place, call // sequence for action that imlpements Validateable interface will be 1] validateExecute() 2] validate() (could be left out depending on interceptor's alwaysInvokeValidate parameter) 3] execute()
- doXXX fallback method call is being removed.
<action name="myAction" method="execute" ...> ... </action> // with the above, if execute() method is not found in the action, no // doExecute() will be fallbacked. It is considered as an error
- ConfigurationManager is no longer a static factory. It is now an instance created through Dispatcher. Custom configuration could be done through DispatcherListener.
- Configuration is no longer statically accesible, it is created by ConfigurationManager. Custom configuration could be done through ConfigurationManager which in turns could be configured through DispatcherListener.
- Custom configuration to ConfigurationManager and Configuration cannot be done statically anymore, instead use Dispatcher's DispatcherListener to achieve such effect.
Dispatcher.addDispatcherListener( new DispatcherListener() { public void dispatcherInitialized(Dispatcher dispatcher) { // do custom stuff here eg. dispatcher.setConfigurationManager(....); } public void dispatcherDestroyed(Dispatcher dispatcher) { // do clean up of custom stuff here } });
Members to rename
WebWork 2 |
Struts 2 |
---|---|
com.opensymphony.webwork.* |
org.apache.struts2.* |
|
|
|
|
DispatcherUtil |
Dispatcher |
New property settings
struts.compatibilityMode.WebWork |
Enable support for the |
This setting will be removed in a future release! |
---|
New members
...
Removed or deprecated
|
The "action!alias" syntax is deprecated. The idiom is disabled by default, but it can be enabled via the |
---|---|
AroundInterceptor |
The AroundInterceptor has been removed. If your application extends the AroundInterceptor, either import the class into your source code form WebWork 2 (pursuant to the Open Symphony License) and modify it to server as your own base class, or rewrite your interceptor. |
|
Support for the "oldSyntax" is removed . |
From Struts 1
- See http://confluence.twdata.org/display/WW/Comparing+Struts+1+and+2
- More notes to come ...