...
Depending on whether you are coming from a WebWork 2 or Struts 1 background, your perspective on the key changes will differ.
From WebWork2 WebWork 2
- Struts 2 is dependant on XWork 2 (nightly build).
- At this time, Java 1.5 is required to build and deploy Struts 2. If possible, RetroWeaver or RetroTranslater may be used to support Java 1.4 in the Struts 2.0.x series.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" />Code Block
For other changes from WebWork 2, see the "Members to rename", "New property settings", "New members or feature changes", and "Removed or deprecated".
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 or feature changes
- 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
- 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.
- Configuration is no longer statically accessible, 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.
- The
prepare
interceptor now uses reflection to call prepareXXX prepareXxx where XXX Xxx is the action method configured for the particular action instruts.xml
Code Block <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
Code Block <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.
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 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.
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
| 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 . | ||
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 alias is not supported. |
From Struts 1
- See http://confluence.twdata.org/display/WW/Comparing+Struts+1+and+2
More notes to come ...
...