Source

webwork / docs / migrationguide.html

Full commit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>OpenSymphony Wiki (Offline Version) :: WebWork2 Documentation</title>
  <link type="text/css" href="main.css" rel="STYLESHEET"/>
</head>
<body>
  <div id="page-logo">
    <a href="index.html">WebWork2 Documentation</a>
  </div>
    <div class="snip-title">
	  <h1 class="snip-name">WebWork 2 Migration Guide
  
  </h1>
  </div>
<div id="snip-content" class="snip-content">

 <div class="snip-attachments"></div>
 
 <a href="index.html">WebWork2</a> is not 100% backwards compatible with <a href="http://wiki.opensymphony.com/space/WebWork">WebWork</a>, hence this migration guide.<p class="paragraph"/><b class="bold">Note</b>: This guide is a work in progress. These are just the initial steps people have thought out and some are steps discovered in attempts to migrate apps. There has been no reported case of a successful migration.<p class="paragraph"/>Todo list: migration tool for JSPs/velocity. Attach compatibility classes to this document. SessionAwareInterceptor and other *Aware stuff?
<h3 class="heading-1">Migration Steps
</h3>
<ul class="star">
<li>ActionSupport has moved from <b class="bold">webwork.ActionSupport</b> to <b class="bold">com.opensymphony.xwork.ActionSupport</b></li>
<li>The syntax of the expression language has changed to <a href="http://wiki.opensymphony.com/space/OGNL">OGNL</a> syntax, so you will need to update ALL expressions in your views (ie foo/bar becomes foo.bar)</li>
<li>The new validation framework allows you to pull validation out of your actions into validator classes. doValidation is no longer called as part of the execute() of an Action. See the <a href="http://wiki.opensymphony.com/space/Xwork+Validation+Framework">Xwork Validation Framework</a> for more details on how to do this.</li>
<li>If you're doing funky things with pre/post processing on actions in a super class, you may want to consider moving these out into <a href="http://wiki.opensymphony.com/space/Xwork+Interceptors">Xwork Interceptors</a></li>
</ul>
<h3 class="heading-1">Convert your actions.xml/views.properties file to xwork.xml
</h3><p class="paragraph"/>If you're using an actions.xml file to configure your webwork 1, you can use the attached XSLT to convert the actions.xml file to a vanilla xwork.xml file.  
To apply this XSLT, you'll need to do the following:
<ul class="star">
<li>Get a copy of the XSLT.  You can find the latest version in CVS in <b class="bold">webwork2/src/etc/actions.xsl</b> .  Alternately, you can download a copy of it from <span class="nobr"><img src="http://wiki.opensymphony.com/images/external-link.png" alt="&gt;&gt;" border="0"/><a href="http://www.indigoegg.com/webwork/actions.xsl">&#104;ttp://www.indigoegg.com/webwork/actions.xsl</a></span> (you'll probably want to right click to download the link instead of viewing it directly)</li>
<li>Next, find yourself an XSLT rendering engine.  Xalan is a good choice and can be found at <span class="nobr"><img src="http://wiki.opensymphony.com/images/external-link.png" alt="&gt;&gt;" border="0"/><a href="http://xml.apache.org/xalan-j/index.html">&#104;ttp://xml.apache.org/xalan-j/index.html</a></span></li>
<li>Finally, do the conversion.</li>
</ul><p class="paragraph"/><div class="code"><pre>java org.apache.xalan.xslt.<span class="java&#45;object">Process</span> &#45;IN actions.xml &#45;XSL actions.xsl &#45;OUT xwork.xml</pre></div>
<ul class="star">
<li>Remember that you'll need to Xalan libraries in your classpath to run the above command.</li>
</ul><p class="paragraph"/>Here's an example of the output from the XSLT.
<ul class="star">
<li>Original actions.xml, <span class="nobr"><img src="http://wiki.opensymphony.com/images/external-link.png" alt="&gt;&gt;" border="0"/><a href="http://www.indigoegg.com/webwork/actions.xml">&#104;ttp://www.indigoegg.com/webwork/actions.xml</a></span></li>
<li>After XSLT applied, <span class="nobr"><img src="http://wiki.opensymphony.com/images/external-link.png" alt="&gt;&gt;" border="0"/><a href="http://www.indigoegg.com/webwork/out.xml">&#104;ttp://www.indigoegg.com/webwork/out.xml</a></span></li>
</ul><p class="paragraph"/>If you want to look at these pages directly in your browser, I recommend user Internet Explorer as it automagically formats XML documents reasonably.  There one caveat though.  WW1 had a way to shorten the declaration of actions by allowing you to specify a package prefix in webwork.properties file.  Since this information is outside the actions.xml file, the XSLT is unable to take advantage of it.  Consequently, you might need to edit the xwork.xml file to update the class names.
<h3 class="heading-1">Update your web.xml file
</h3>
<ul class="star">
<li>If you're using Velocity for views, you'll need to make sure you have the following snippet. Specifically note that the &#60;load-on-startup&#62; tag is now required so that the servlet can initialize some important Velocity properties.</li>
</ul>
<div class="code"><pre>&#60;servlet&#62;
    &#60;servlet&#45;name&#62;velocity&#60;/servlet&#45;name&#62;
    &#60;servlet&#45;class&#62;com.opensymphony.webwork.views.velocity.WebWorkVelocityServlet&#60;/servlet&#45;class&#62;
    &#60;load&#45;on&#45;startup&#62;1&#60;/load&#45;on&#45;startup&#62;
&#60;/servlet&#62;</pre></div>
<ul class="star">
<li>Set the property <b class="bold">webwork.velocity.configfile</b> in your <b class="bold">webwork.properties</b>. For example:</li>
</ul>
<div class="code"><pre>webwork.velocity.configfile=velocity.properties</pre></div><p class="paragraph"/>WebWork will use this file to initialize the Velocity engine. The search path for the file is:
<ol>
<li>context root (web root)</li>
<li>WEB-INF/</li>
<li>classpath</li>
</ol>
  </div>
</body>
</html>