Struts 2.0.0 is the first distribution of WebWork 2 as an Apache Struts product.
Warning |
---|
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 developeruser, 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.
Known Issues
- For known issues, see Struts 2.0.1
Key Snippets
Maven Artifact ID
Code Block |
---|
<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.0.0-SNAPSHOT<0</version> </dependency> |
Struts Configuration DTD XML
Code Block |
---|
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="struts-default.xml"/> <package name="support" extends="struts-default"> <action name="$name" class="$class"> <result>$location</result> </action> </package> </struts> |
XWork Validation XML
Code Block |
---|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<field name="$name">
<field-validator type="$type">
<message>$message</message>
</field-validator>
</field>
</validators>
|
New Features and Extensions
- Can we use Acegi Security with the framework extension is available.
- CheckBox Interceptor detects unchecked checkboxes and adds a parameter with a default value (usually 'false') .
- JavaServer Faces extension is available.
- A
struts.xml
file can be placed in a JAR and automatically plugged into an application, so that modules can be self-contained and automatically configured.- In the case of Freemarker and Velocity modules, the templates can also be loaded from the classpath, so the entire module can be plugged in as a single JAR.
- DebuggingInterceptor displays the value stack at runtime.
Key Changes
Depending on whether you are coming from a Struts 1 or a WebWork 2 or Struts 1 background, your perspective on the key changes will differ.
From Struts 1
- See Comparing Struts 1 and 2
- More notes to come ...
From WebWork2 WebWork 2
- Struts 2 is dependant on XWork 2 (nightly build).
- Java 1.5 is required to build the and deploy Struts 2 distribution from source, but .
- For Java 1.4 deployments, RetroWeaver or RetroTranslater may be used to provide Java 1.4
- 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)
Code Block <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)
Code Block title struts.properties struts.compatibilityMode = true
- support
- A pre-packaged set of RetroTranslator JARs is being provided with the distribution.
For other changes from WebWork 2, see the "Members to rename", "New property settings", "New features or feature changes", and "Removed or deprecated".
Members to rename
WebWork 2 | Struts 2 |
---|---|
| |
| |
| |
| |
DispatcherUtil | Dispatcher |
com.opensymphony.webwork.config.Configuration | org.apache.struts2.config.Settings |
The tag prefix conventions in the example applications have changed.
JSP | s: | <s:form ...> |
---|---|---|
Freemarker | s. | <@s.form ...> |
Velocity | s | #sform ( ... ) |
New property settings
struts.enable.DynamicMethodInvocation | Enable support for the hardwired |
---|
Tip |
---|
It is recommended that all applications specify the DynamicMethodInvocation setting for now, since the default may change. The recommended approach to action aliasing is to use wildcard aliases instead of the hardwired bang. |
New features and feature changes
- Various changes to ConfigurationManager
- ConfigurationManager is no longer a static factory. It is now an instance created through Dispatcher. Custom configuration could be done through DispatcherListener.
- Custom configuration to ConfigurationManager and Configuration cannot be done statically anymore, instead use Dispatcher's DispatcherListener to achieve the same effect.
- The
prepare
interceptor now uses reflection to call prepareXXX where XXX prepare_Method_ where method is the action method configured for the particular action instruts.xml
.Code Block <action name="myAction" method="executeinsert" ....> ..... </action> // with the above configuration, and preparatorPrepareInterceptor interceptor in placeplay, call // sequencecallsequence will be 1] prepareExecuteprepareInsert() (If it exists) 2] prepare() (couldUnless beInterceptor's leftalwaysInvokePrepare outparameter dependingis onset interceptor's alwaysInvokePreapre parameterto false) 3] executeinsert()
- Default workflow interceptor DefaultWorkflowInterceptor (named
workflow
instruts-default.xml
) now uses reflection to call validateXXXvalidateMethod
on the action class that implements Validateable interface where XXXmethod
is the action method configured for the particular action instruts.xml
.Code Block <action name="myAction" method="executeinsert" ...> ... </action> // with the above configuration, and workflow interceptorDefaultWorkflowInterceptor in placeplay, call // call sequence for action that imlpementsimplements Validateable interface will be 1] validateExecutevalidateInsert() 2] validate() (couldunless beInterceptor's leftalwaysInvokeValidate outparameter dependingis onset interceptor's alwaysInvokeValidate parameterto false) 3] executeinsert()
- doXXX fallback method call is being removed.
Code Block <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 DispatcherListener.
- Custom configuration to ConfigurationManager and Configuration cannot be done statically anymore, instead use Dispatcher's DispatcherListener to achieve such effect.
Code Block 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
- Datepicker tag is now using dojo's (limited in terms functionality and internationalization)
- Tiles integration extension is available.
- Wildcards can be specified in action mappings.
- MessageStoreInterceptor is introduced to allow field errors / action errors and messages to be store and retrieve through session, resulting them to be preservable across request.
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
...
Rich text editor tag | 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)
| ||
---|---|---|---|
| The convention of trying a "do" form of an action method is not supported.
In WebWork,
| ||
| Calling the "default" method via "doDefault" is not supported |
...
. |
Detail
Pending and open issues
Jira Issues | |||||||
---|---|---|---|---|---|---|---|
|