Showing posts with label webwork. Show all posts
Showing posts with label webwork. Show all posts

Wednesday, August 22, 2007

WebWork 2 to Struts 2 Migration Note

1. web.xml
Update FilterDispatcher, ActionContextCleanupFilter and SitemeshFilter to use Struts

2. JAR libs
Remove webwork-2.2.5.jar, xwork-1.2.2.jar, xwork-tiger-1.2.2.jar
Use struts2-core-2.0.9.jar, xwork-2.0.4.jar, struts-sitemesh-plugin-2.0.9.jar and struts-spring-plugin-2.0.9.jar. Note that the extensions are separated into different plugin jars.

3. xml Config files
Rename xwork.xml to struts.xml, xwork-agent.xml to struts-agent.xml, xwork-audit.xml to struts-audit.xml, etc.
in the config files, change some occurences of 'xwork' to 'struts' and change DOCTYPE to use struts-2.0.dtd

4. property files
Rename webwork.properties to struts.properties and change all occurences of 'webwork' to 'struts' in the property file
multipart parser set to jakarta which replaces com.opensymphony.webwork.dispatcher.multipart.CosMultiPartRequest
change ui templateDir to admin/themes/struts

Note that the conversion property file is still called xwork-conversion.properties

***NOTE that in struts.properties, set struts.i18n.encoding=UTF-8, otherwise it will cause problem in working with dojo contentPane. By default, struts will use charset CP1252 encoding for windows server and UTF-8 encoding charset for Linux.

5. validatiors.xml
Change all com.opensymphony.xwork to com.opensymphony.xwork2, and the DOCTYPE must be defined to avoid SAXParser exception. It is allowed for webwork though.

6. Action classes
Imported package name: com.opensymphony.xwork change to com.opensymphony.xwork2 and com.opensymphony.webwork change to org.apache.struts2
Class Configuration is changed to DefaultSettings. It seems that Struts 2 provides better support in custom property config setting
AroundInterceptor is removed from xwork2, use MethodFilterInterceptor instead.

7. On all FreeMarker ftl pages
Rename webwork tag prefix @ww. to @s.

8. FreeMarkerManager, ActionSupport API
Change OgnlValueStack type to ValueStack in parameter list.

9. FileUpload
The random generated file names such as xxx.tmp is used and the files are stored in a upload folder on the server when we upload the files. So the features such as install cartridge, script agent builder are broken because they will get the random generated file name instead by calling File.getName() or File.getAbsolutePath(). To obtain the original file name, MultiPartRequestWrapper provides a method getFileNames() method, and for FileUploadInterceptor, the file name is injected.

Tuesday, May 15, 2007

Webwork ScopeInterceptor

ScopeInterceptor is used to pull attributes out of session/applicaton and set action properties, i.e., dependency injection.


<action name="handleGeneralError" class="...">
<interceptor-ref name="scope">
<param name="key">FoglightError_</param>
<param name="session">exception,statusCode,originalRequestUri</param>
<param name="type">end</param>
</interceptor-ref>
<result .../>
</action>

key - key prefix
session - a list of action properties to be bound to session scope
type - 'end' means remove from session after action run; 'start' means it's a start action of the wizard-like action sequence and all session scoped properties are reset to their defaults; any other value or no value means that it's in-the-middle action that is set with session properties before it's executed, and it's properties are put back to session after execution.