Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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) Code Block <s:textarea theme="ajax" />

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.*

xwork.xml

struts.xml

webwork.properties

struts.properties

DispatcherUtil

Dispatcher

New property settings

struts.compatibilityMode.WebWork

Enable support for the action!alias syntax

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
    titlestruts.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 in struts.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.*

xwork.xml

struts.xml

webwork.properties

struts.properties

DispatcherUtil

Dispatcher

New property settings

struts.compatibilityMode.WebWork

Enable support for the action!alias syntax

This setting will be removed in a future release!

New members

(warning) ...

Removed or deprecated

action!alias

The "action!alias" syntax is deprecated. The idiom is disabled by default, but it can be enabled via the struts.compatibilityMode.WebWork property setting. This setting will be removed in a future release.

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.

oldSyntax

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)

Code Block
 <s:textarea theme="ajax" /> 

doAlias

The convention of trying a "do" form of an alias is not supported.

From Struts 1

...