<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CkYDQX86eCp7ImA9WxNVFUs.&quot;"><id>tag:blogger.com,1999:blog-19648744</id><updated>2009-10-26T07:29:30.110-05:00</updated><title>Alex Kotchnev's Blog</title><subtitle type="html">Clowning around with NetBeans, Groovy &amp;amp; Grails, Tapestry, and other cool stuff.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.troymaxventures.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>49</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><link rel="self" href="http://feeds.feedburner.com/akochnev" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry gd:etag="W/&quot;DEMNQXo_cSp7ImA9WxJXEE0.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-4802053931097107447</id><published>2009-06-02T22:43:00.010-05:00</published><updated>2009-06-03T00:21:30.449-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T00:21:30.449-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Quickly running a single Grails test in NetBeans</title><content type="html">&lt;p&gt;One thing in the current NetBeans Grails project is that out of the box, you can run all tests in the project from the project's context menu but you can't run individual tests. While that is all good and well when you only have a few tests, once the tests are piling up (or you just are interested in how a particular test works), it is much preferable to be able to execute a single test at a time. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SiYB4ZF__vI/AAAAAAAAAlI/JKY-OBhit1A/s1600-h/run_single_test.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 313px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SiYB4ZF__vI/AAAAAAAAAlI/JKY-OBhit1A/s320/run_single_test.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5342960076242026226" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;There is an &lt;a href="http://www.netbeans.org/issues/showvotes.cgi?issue_id=159833"&gt;existing issue&lt;/a&gt; to address this (so, go and vote for the issue if it seems useful, would ya?), but in the meantime, you still need to run your individual tests, right ? So, what should you do ? &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The trick is to just use the "Run Grails Command" feature in NetBeans and make it easily accessible so that you can run the test in a heartbeat. &lt;br /&gt;&lt;br /&gt;Here's what the feature looks like: &lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SiYF81BCAFI/AAAAAAAAAlQ/8nGOLixdU4Y/s1600-h/run_grails_command.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 192px; height: 320px;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SiYF81BCAFI/AAAAAAAAAlQ/8nGOLixdU4Y/s320/run_grails_command.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5342964550503366738" /&gt;&lt;/a&gt;&lt;br /&gt;Right click on the project and select the "Run Grails Command..." option&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li style="clear:both"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SiYGNXVggGI/AAAAAAAAAlY/e3aJpkoJcPc/s1600-h/run_single_command_dialog.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 262px;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SiYGNXVggGI/AAAAAAAAAlY/e3aJpkoJcPc/s320/run_single_command_dialog.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5342964834593964130" /&gt;&lt;/a&gt;&lt;br /&gt;In the dialog, type "test-app" in the Filter text box, and then type in "TestName -unit" for unit tests, or "TestName -integration" for integration tests. Note that here "TestName" is the test class name minus the "Tests" suffix for unit tests and minus the "IntegrationTests" for integration tests. &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style="clear:both"&gt;&lt;br /&gt;&lt;br /&gt;The good news is that NetBeans remembers the command options from the previous run (not the command though) and if you pull up the dialog you just have to type "test-app" and hit enter and it will execute your previous test class. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_GbeUi4pR7kA/SiYGNj2x4TI/AAAAAAAAAlg/bSwMA9qmup4/s1600-h/map_grails_shortcut_run_cmd.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 222px;" src="http://4.bp.blogspot.com/_GbeUi4pR7kA/SiYGNj2x4TI/AAAAAAAAAlg/bSwMA9qmup4/s320/map_grails_shortcut_run_cmd.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5342964837954740530" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style="clear:both"&gt;&lt;br /&gt;Thus, the only thing you have left it to make it easy to call the "Execute Grails Command" - so, we just need to map a shortcut. In order to do that, go to Tools-&gt;Options-&gt;Key Map tab. In the "Search" box, type "grails", the "Execute Grails Command" action is there, click in the Shortcut column, type in your shortcut (I picked Ctrl+Alt-C) and hit OK. &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Now, running your test the first time involves Ctrl-Alt-C, type "test-app", tab, type "FooBar -unit" and hitting enter. Kicking it off subsequently is Ctrl-Alt-C, type "test-app", hit enter and your tests are running !!! &lt;br /&gt;&lt;br /&gt;BEAUTY !!!&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-4802053931097107447?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/fyK0Bv8ImGM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/4802053931097107447/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2009/06/quickly-running-single-grails-test-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4802053931097107447?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4802053931097107447?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/fyK0Bv8ImGM/quickly-running-single-grails-test-in.html" title="Quickly running a single Grails test in NetBeans" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_GbeUi4pR7kA/SiYB4ZF__vI/AAAAAAAAAlI/JKY-OBhit1A/s72-c/run_single_test.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2009/06/quickly-running-single-grails-test-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0ANQH4-eCp7ImA9WxJQEUk.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-9175747913089605708</id><published>2009-05-13T02:10:00.014-05:00</published><updated>2009-05-24T01:16:31.050-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-24T01:16:31.050-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><title>RAD w/ Tapestry 5, NetBeans 6.7, Maven, and Jetty : Really !!!</title><content type="html">&lt;p&gt;One of the major upsides of using Tapestry 5 is the much touted &lt;a href="http://tapestry.apache.org/tapestry5/guide/reload.html"&gt;live class and template reloading&lt;/a&gt;. Up until recently, if you followed &lt;a href="http://www.troymaxventures.com/2008/05/tapestry5-netbeans-quickstart.html"&gt;my previous post&lt;/a&gt; on working with Tapestry 5 and NetBeans, you probably ended w/ a workable solution, but still not ideal , as the live template and class reloading wasn't exactly working as expected. As a result, whenever you wanted to see the changes that you made in the live app (after running mvn jetty:run) you had to do the following:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;mvn compile resources:resources&lt;br /&gt;.........&lt;br /&gt;-----------&lt;br /&gt;[INFO] BUILD SUCCESSFUL&lt;br /&gt;[INFO] ------------------------------------------------------------------------&lt;br /&gt;[INFO] Total time: 18 seconds&lt;br /&gt;[INFO] Finished at: Wed May 13 03:16:32 EDT 2009&lt;br /&gt;[INFO] Final Memory: 16M/71M&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The issue here was that NetBeans (in 6.1 and prior) did not support CopyOnSave or CompileOnSave properly in Maven projects (it did for NetBeans native projects, so if you had set up a NetBeans native project w/ explicit jar dependencies, etc it would work fine). The effect of running the above command was to compile your changes, and copy the compiled classes and modified resources into your &amp;lt;outputDirectory&amp;gt; (typically target/classes) . So, the 18 seconds above are not exactly something to lose sleep over, but it's still not the same like having the immediate Grails(or Rails)-like immediate feedback loop (that is, "Ctrl-S-&gt;Alt-Tab to browser-&gt;F5", which is "Save-&gt;Switch to Browser-&gt;Refresh"). &lt;br /&gt;&lt;br /&gt;In any case, help is on the way. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;In the most recent version of NetBeans (in the &lt;a href="http://bits.netbeans.org/download/trunk/nightly/latest/"&gt;6.7 daily builds&lt;/a&gt; ), the issues w/ CopyOnSave support has been fixed (well, almost fixed, see &lt;a href="http://www.netbeans.org/issues/show_bug.cgi?id=152974"&gt;the NetBeans IssuZilla issue&lt;/a&gt;), and now it transparently copies your modified resource files to target/[app-name]/WEB-INF/classes. Thus, with just a minor tweak, you can accomplish a Tapestry 5 Nirvana. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt; First, set up a new Maven project by File-&gt;New Project-&gt;Select Maven project type. Follow &lt;a href="http://www.troymaxventures.com/2008/05/tapestry5-netbeans-quickstart.html"&gt;my previous instructions&lt;/a&gt; on creating the actual project. Just a side note, for some reason the latest production T5 version (5.1) doesn't show up on the list of available archetypes in NetBeans. &lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt; Running the app is easy, the default project comes w/ the Jetty plugin set up, so you can just run "mvn jetty:run" on the console. &lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Alternatively, map a custom Maven goal in NetBeans by right clicking on the project, going to Custom-Goals and mapping jetty:run . See the screenshots for some extra help&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/Shjioy6p-HI/AAAAAAAAAko/J0w7moGS-80/s1600-h/maven_custom_goal1.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 255px;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/Shjioy6p-HI/AAAAAAAAAko/J0w7moGS-80/s320/maven_custom_goal1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5339266548738160754" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/ShjizwVDr1I/AAAAAAAAAkw/S9YDYpOnYZM/s1600-h/maven_custom_goal2.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 213px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/ShjizwVDr1I/AAAAAAAAAkw/S9YDYpOnYZM/s320/maven_custom_goal2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5339266737022152530" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_GbeUi4pR7kA/ShjjCAPREGI/AAAAAAAAAk4/XTnelzt47eY/s1600-h/maven_custom_goal3.png"&gt;&lt;img style="float:left; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 218px;" src="http://4.bp.blogspot.com/_GbeUi4pR7kA/ShjjCAPREGI/AAAAAAAAAk4/XTnelzt47eY/s320/maven_custom_goal3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5339266981810999394" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li style="clear:both"&gt;The default project setup comes with an Index page living in the web app context. Now that you ran Jetty, you should be able to just make changes to the template, and see them immediately. The secret here is that Jetty runs by default out of src/main/webapp, so T5 picks up the changes out of the box, no additional support by the IDE is needed. &lt;br /&gt;&lt;br /&gt;The problem here is that if you tried making changes to your page class (e.g. Index.java), they're not being picked up. Jetty runs from the classes in target/classes. The idea here is that we want to IDE to autocompile the changes, drop them into target/classes and have T5 pick up the new page classes. As mentioned at the beginning of the post, if you just ran the maven build again (e.g. mvn compiler:compile), but we need something better. &lt;br /&gt;&lt;br /&gt;OK, so, go to the project properties, go to the Build-Compile section. In the panel, select from the "Compile on Save" (COS) dropdown the "for both application and test execution". &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_GbeUi4pR7kA/ShjjWYeIO3I/AAAAAAAAAlA/lsUfyR4v13Y/s1600-h/deploy-on-save.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 229px;" src="http://4.bp.blogspot.com/_GbeUi4pR7kA/ShjjWYeIO3I/AAAAAAAAAlA/lsUfyR4v13Y/s320/deploy-on-save.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5339267331913169778" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The trick to remember here is that this only works for "supported servers" (e.g. I know that at least Tomcat and Glassfish are in that list) where the IDE would compile the new classes, and re-deploy them on the server. Jetty is not one of these supported servers, and in order for the Compile-on-save goodness to work, the IDE needs to know you ran the app so that it can activate COS. Now, although you probably don't want to run the app in Tomcat , go ahead and run the app, select to run it in Tomcat. Now that you ran the app in Tomcat, NetBeans activated COS for this app, and now if you make new changes to your Index.java, NetBeans copies out the compiled classes to target/classes, and Jetty picks up the changes. After you run the app, you can just stop Tomcat (and the COS feature will continue working). &lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;This is pretty close to perfect. Trouble is, if you have any page templates under src/main/resources, you're still out of luck, as the resources don't get copied out into target/classes after you do the initial jetty:run. But don't despair, there is just one more step that will get us there. &lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt; Add the following to your pom.xml&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;outputDirectory&amp;gt;${project.build.directory}/${project.build.finalName}/WEB-INF/classes&amp;lt;/outputDirectory&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Now, this is a bit of a hack. Basically, we're telling maven to use the target/[app-name]/WEB-INF/classes to do the initial and any subsequent builds, which is where both the classes from src/main (and whereever else) and src/main/resources end up. The trick here is that this is the same directory that "mvn package" uses, and it is also the same directory that NetBeans uses for the Compile-on-save functionality. Basically, when you make changes to your page template sin src/main/resources (and after you've run your app in Tomcat once), NetBeans continues to compile the classes and copy the modified resources from src/main/resources and drop them into the target/[app-name]/WEB-INF/classes. &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Considering that this is indeed a a hack, &lt;a href="http://www.netbeans.org/issues/show_bug.cgi?id=152974"&gt;I filed a patch&lt;/a&gt; for NetBeans to properly support this T5 setup in Maven project. However, what got into 6.7 is only the fix to properly copy resources into target/[app-name]/WEB-INF/classes (and not in target/classes). The develoeper on the issue has some other ideas on how this should go, hopefully the full fix will go into the NetBeans version after 6.7. In the meantime, either use this little hack, or I'll probably try to repackage my fix as a standalone plugin to support this out of the box.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-9175747913089605708?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/cn6sn258S88" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/9175747913089605708/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2009/05/rad-w-tapestry-5-netbeans-67-maven-and.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/9175747913089605708?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/9175747913089605708?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/cn6sn258S88/rad-w-tapestry-5-netbeans-67-maven-and.html" title="RAD w/ Tapestry 5, NetBeans 6.7, Maven, and Jetty : Really !!!" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_GbeUi4pR7kA/Shjioy6p-HI/AAAAAAAAAko/J0w7moGS-80/s72-c/maven_custom_goal1.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.troymaxventures.com/2009/05/rad-w-tapestry-5-netbeans-67-maven-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UDQXc4fip7ImA9WxJREUU.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-5673112230332670302</id><published>2009-05-05T23:45:00.016-05:00</published><updated>2009-05-12T23:34:30.936-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-12T23:34:30.936-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="legacy rails" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><title>Converting legacy Rails apps to Grails : The Views</title><content type="html">Alrighty, we're getting close to the finish line here. So far, we've covered &lt;a href="http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails.html"&gt;General Project Setup&lt;/a&gt;, &lt;a href="http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails_31.html"&gt;Migrating the Domain&lt;/a&gt;, &lt;a href="http://www.troymaxventures.com/2009/05/converting-legacy-rails-apps-to-grails.html"&gt;Migrating the Controllers&lt;/a&gt;, and now we'll talk about migrating the views. After that, if I have a little bit of life left in me, I'll briefly speak about replacing the existing plugins in the Rails app w/ equivalent Grails plugin, and that should be the end of this series. &lt;br /&gt;&lt;br /&gt;Now, on to the content. &lt;br /&gt;&lt;ol&gt;&lt;br /&gt;    &lt;li&gt;&lt;a href="#generalSetup"&gt;General Setup&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;&lt;a href="#layouts"&gt;Layouts&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;&lt;a href="#pageByPageMigration"&gt;Page-by-page migration&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;&lt;a href="#tags"&gt;Tags&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;&lt;a href="#conclusion"&gt;Conclusion&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;    &lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="generalSetup"&gt;1. General Setup&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SgEWEB197rI/AAAAAAAAAkI/BrEOZ3-o9JQ/s1600-h/rails_views_structure.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 240px; height: 291px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SgEWEB197rI/AAAAAAAAAkI/BrEOZ3-o9JQ/s320/rails_views_structure.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332567692253458098" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgEWNB2mArI/AAAAAAAAAkQ/LPAoqfCKo3E/s1600-h/grails_views_structure.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 221px; height: 320px;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgEWNB2mArI/AAAAAAAAAkQ/LPAoqfCKo3E/s320/grails_views_structure.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332567846874907314" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you're probably used to it by now, the Grails and the Rails app have very similar approaches to storing views and templates. As you can see on the screenshots, the Rails views are in the "Views" project node, whereas in the Grails project, they're located in the "View and Layouts" project node. Inside of this folder, the views are partitioned by controller, e.g. the views and templates for controller "FooController" in the Grails app, sit inside of the view/foo subfolder. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="layouts"&gt;2. Layouts&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another interesting folder in both Rails and Grails is the Layouts folder (in Grails, Views and Layouts - layouts project folder). There, the projects store the differet project layouts. The general idea here is mostly the same: different parts of the app will have different layout needs. Migrating the layouts from Rails to Grails involves mostly tag-for-tag conversion of the rhtml to gsp. A couple of useful facts about that process. &lt;br /&gt;&lt;br /&gt;1. As mentioned in the &lt;a href=""&gt;previous post&lt;/a&gt;, both frameworks have a reasonable set of defaults for the layout selection. I can't quite remember all the details about how Rails chooses its defaults, but the converted application mostly specified on a per-controller basis by specifying the element, e.g. : &lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;class FooController &lt;br /&gt;    layout "internal"&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This Rails snippet will use the views/layouts/internal.rhtml layout. &lt;br /&gt;&lt;br /&gt;There is no direct equivalent for specifying the desired layout inside of a controller in Grails. Instead, a user can add a layout with the same name as the controller (e.g. layouts/foo.gsp for FooController). Although I don't recall this being used in the Rails app, Grails also provides the ability to specify a template to use for rendering a view by specifying a &amp;lt;meta name="layout" content="landing"&amp;gt;&amp;lt;/meta&amp;gt;. Rendering a view that specifies the layout in this way will use the view/layouts/internal.gsp layout. &lt;br /&gt;&lt;br /&gt;2. Converting the Rails layouts&lt;br /&gt;The Rails layouts that I worked with used the following statements in the &amp;lt;head&amp;gt; element: &lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;%= stylesheet_link_merged :base %&amp;gt;&lt;br /&gt;&amp;lt;%= stylesheet_link_merged :print, 'media' =&amp;gt; 'print' %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;%= javascript_include_merged :base %&amp;gt;&lt;br /&gt;&amp;lt;%= javascript_include_merged :application %&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I can't quite say I know what all of the above statements do. I inspected the output the actual HTML output and replaced it with the following in my Grails template:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;  &amp;lt;head&amp;gt;&lt;br /&gt; &amp;lt;link rel="shortcut icon" href="${createLinkTo(dir:'images',file:'favicon.ico')}" type="image/x-icon" /&amp;gt;&lt;br /&gt; &amp;lt;link rel="stylesheet" href="${createLinkTo(dir:'stylesheets/active_scaffold',file:'stylesheet.css')}" media="screen" type="text/css" /&amp;gt;&lt;br /&gt; &amp;lt;link href="${createLinkTo(dir:'stylesheets',file:'styles.css')}" media="screen" rel="Stylesheet" type="text/css" /&amp;gt;&lt;br /&gt; &amp;lt;link href="${createLinkTo(dir:'stylesheets',file:'print.css')}" media="print" rel="Stylesheet" type="text/css" /&amp;gt;&lt;br /&gt; &amp;lt;link href="${createLinkTo(dir:'stylesheets/active_scaffold/default',file:'stylesheet.css')}" media="screen" rel="Stylesheet" type="text/css" /&amp;gt;&lt;br /&gt; &amp;lt;!--[if IE]&amp;gt;&lt;br /&gt;  &amp;lt;link href="${createLinkTo(dir:'stylesheets/active_scaffold/default',file:'stylesheet-ie.css')}" media="screen" rel="Stylesheet" type="text/css" /&amp;gt;&lt;br /&gt; &amp;lt;![endif]--&amp;gt;&lt;br /&gt; &amp;lt;g:layoutHead /&amp;gt;&lt;br /&gt; &amp;lt;g:javascript library="application" /&amp;gt;&lt;br /&gt; &amp;lt;g:javascript library="prototype" /&amp;gt;&lt;br /&gt; &amp;lt;g:javascript library="scriptaculous" /&amp;gt;&lt;br /&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;A couple of things to note here : &lt;br /&gt;* Using the ${createLinkTo()} tag inside of the stylesheet links : it is very convenient and makes the generation of the links pretty foolproof. &lt;br /&gt;* Using the &amp;lt;g:layoutHead /&amp;gt; statement : allows the inclusion of any elements from the &amp;lt;head&amp;gt; element of the "client" page (the page that is using the layout). &lt;br /&gt;&lt;br /&gt;Inside of the body of the template, the Rails template use the &amp;lt;%= yield%&amp;gt; statement to include the body of the client page. The equivalent statement in the Grails layout is the &amp;lt;g:layoutBody&amp;gt;&lt;br /&gt;&lt;br /&gt;Finally, Rails allows client views to contribute "additional" content into the final output. In other words, the template can define an "area" where the client template can contribute markup, in a way that the said markup shows up in the parts of the layout that are generally rendered by the template. For example, if the client pages need to contribute markup to the content of the "sidebar", then, the layout would use something like the following:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;    &amp;lt;% if !@content_for_sidebar.nil? %&amp;gt;&lt;br /&gt;        &amp;lt;div id="right_sidebar_content_main"&amp;gt;&lt;br /&gt;            &amp;lt;%= yield(:sidebar) %&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;% end %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The client template, contributes to the layout as follows: &lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;% content_for :sidebar do%&amp;gt;&lt;br /&gt; &amp;lt;div&amp;gt; This content will show up under the 'right_sidear_content_main' section in the final output &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In Grails, in order to implement the same feature, we have to resort to a less used and somewhat obscure feature of the underlying templating system that Grails users : Sitemesh. Here's the equivalent in the Grails project:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;    &amp;lt;g:if test="${pageProperty(name:'page.sidebar')!=null &amp;&amp; pageProperty(name:'page.sidebar')!=''}"&amp;gt;&lt;br /&gt;        &amp;lt;div id="right_sidebar_content_main"&amp;gt;&lt;br /&gt;            &amp;lt;g:pageProperty name="page.sidebar" /&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/g:if&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, in the "client" page, add content to the sidebar as follows: &lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;    &amp;lt;content tag="sidebar"&amp;gt;&lt;br /&gt;          &amp;lt;g:render template="course_notes_side_bar" /&amp;gt;&lt;br /&gt;    &amp;lt;/content&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There is some additional info on using this feature in the Grails docs' for &lt;a href="http://grails.org/doc/1.1/ref/Tags/pageProperty.html"&gt;pageProperty&lt;/a&gt; tag, but more so in the &lt;a href="http://www.opensymphony.com/sitemesh/index.html"&gt;Sitemesh user docs&lt;/a&gt; and just &lt;a href="http://weblogs.java.net/blog/zarar/archive/2006/01/passing_arbitra.html"&gt;random blogs&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="pageByPageMigration"&gt;3. Page-by-page migration&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;There is in most cases a 1-1 relationship between the views in both frameworks. Converting from the Rails views to the Grails views was mostly mechanical : see the Rails tag, find the equivalent Grails tag, and then figure out how to map the Rails tag attributes to the Grails tag attributes. In most cases, the two are similar enough and the conversion is fairly easy. At other times, Rails did provide some more features not present in Grails and migrating the pages did require some level of thought and effort. Even in that case, even for the tags that don't have a Grails equivalent, after the first couple of tags the conversion is always the same. Here's an example of an easy conversion: &lt;br /&gt;&lt;br /&gt;In Rails:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt; &amp;lt;%= link_to_remote "Upload File",&lt;br /&gt;       {:url =&amp;gt; { :controller =&amp;gt; 'activity_items', :action =&amp;gt; 'show_upload_form', :activity_id =&amp;gt; @act_id},&lt;br /&gt;          :before =&amp;gt; "Element.show('show_upload_form')" ,&lt;br /&gt;          :success =&amp;gt; "Element.hide('show_upload_form');",&lt;br /&gt;    :update =&amp;gt; { :success =&amp;gt; "upload_form", :failure =&amp;gt; "upload_form_errors" }}, &lt;br /&gt;        {:class =&amp;gt; "action", :title =&amp;gt;"Add a new file."} %&amp;gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In Grails: &lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;g:remoteLink controller='activityItems' action='show_upload_form'&lt;br /&gt;        params="[act_id:act_id]"&lt;br /&gt;        before="Element.show('show_upload_form')"&lt;br /&gt;        onSuccess="Element.hide('show_upload_form')"&lt;br /&gt;        update="[success:'upload_form', failure:'upload_form_errors']"&lt;br /&gt;        class="action" title="Add a new file"&amp;gt; Upload File &amp;lt;/g:remoteLink&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's another one. &lt;br /&gt;&lt;br /&gt;Rails:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;%= form_remote_tag :url =&amp;gt; {:action =&amp;gt; 'update',:controller =&amp;gt; "activities", :id =&amp;gt; @activity.id},&lt;br /&gt;:before =&amp;gt; "Element.show('form-indicator-activities')" ,&lt;br /&gt;:success =&amp;gt; "Element.hide('form-indicator-activities')" %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Grails:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;g:formRemote url="[action:'update', controller:'activities', id:activity.id]" name="editActivityForm"&lt;br /&gt;    before="Element.show('form-indicator-activities')"&lt;br /&gt;    onSuccess="Element.hide('form-indicator-activities')"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I found that because the Rails app assumed to be deployed at the root of the context (e.g. http://localhost:3000/), whereas the Grails app always assumes that it will be deployed to a non-root context path (e.g. /foo), in many cases I found myself replacing static image references with links created with ${createLinkTo()}&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;FROM: &lt;br /&gt;&amp;lt;img src="/images/indicator.gif" id='addurl' style='display:none;' /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TO:&lt;br /&gt;&amp;lt;img src="${createLinkTo(dir:"images",file:"indicator.gif")}" id='addurl' style='display:none;' /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's an example of a Rails tag that didn't have a direct equivalent in Grails. &lt;br /&gt;&lt;br /&gt;Rails:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;%= text_field_with_auto_complete(:course, :title, {:class=&amp;gt;"SearchTextBox", :value =&amp;gt; " type here, then hit enter", :onclick=&amp;gt;"this.value=(this.value == ' type here, then hit enter')?'':this.value;", :onblur =&amp;gt; "this.value=(this.value == '')?' type here, then hit enter':this.value;"}, completion_options = {})  %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In Grails, I created a template that contained the same html + javascript that the Rails tag produced:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;%-- The content below was migrated from the Rails app, could be improved if using a plugin providing a cleaner autocompletion setup --%&amp;gt;&lt;br /&gt;Search&lt;br /&gt;&lt;br /&gt;&amp;lt;style type="text/css"&amp;gt;&lt;br /&gt;  div.auto_complete {&lt;br /&gt; width: 350px;&lt;br /&gt; background: #fff;&lt;br /&gt;  }&lt;br /&gt;  div.auto_complete ul {&lt;br /&gt; border:1px solid #888;                         &lt;br /&gt; margin:0;&lt;br /&gt; padding:0;&lt;br /&gt; width:100%;&lt;br /&gt; list-style-type:none;&lt;br /&gt;  }&lt;br /&gt;  div.auto_complete ul li {&lt;br /&gt; margin:0;&lt;br /&gt; padding:3px;&lt;br /&gt;  }&lt;br /&gt;  div.auto_complete ul li.selected {&lt;br /&gt; background-color: #ffb;&lt;br /&gt;  }&lt;br /&gt;  div.auto_complete ul strong.highlight {&lt;br /&gt; color: #800;&lt;br /&gt; margin:0;&lt;br /&gt; padding:0;&lt;br /&gt;  }&lt;br /&gt;&amp;lt;/style&amp;gt;&lt;br /&gt;&amp;lt;input autocomplete="off" class="SearchTextBox" id="course_title" name="course.title" onblur="this.value=(this.value == '')?' type here, then hit enter':this.value;" onclick="this.value=(this.value == ' type here, then hit enter')?'':this.value;" size="30" value=" type here, then hit enter" type="text"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;div style="position: absolute; left: 1275px; top: 161px; width: 230px; display: none;" class="auto_complete" id="course_title_auto_complete"&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;//&amp;lt;![CDATA[&lt;br /&gt;var course_title_auto_completer = new Ajax.Autocompleter('course_title', 'course_title_auto_complete', "${createLink(controller:'courses', action:'auto_complete_for_course_title')}", {})&lt;br /&gt;//]]&amp;gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Finally, Rails definitely has some more advanced scaffolding features that Grails didn't support out of the box or did not have a direct equivalent. Similarly to the example above, I just used the html that the scaffold generated, stuffed that into a separate template and used that. &lt;br /&gt;&lt;br /&gt;Rails:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;%= render :active_scaffold =&amp;gt; "notes", :constraints =&amp;gt; {:user_id =&amp;gt; current_user.id, :course_id =&amp;gt; @course.id} %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In Grails, this became a standalone template (_notes_scaffold.gsp), which initially contained the static HTML generated by Rails, which I then rigged to support dynamically generate the needed markup (e.g. loop, etc). In the end, the call to the scaffold code above, becomes the following:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;   &amp;lt;g:render template="/notes/notes_scaffold" model="[notes:UserNote.findAllByUserAndCourse(user?:current_user(),course)]" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="tags"&gt;4. Helpers and Tags&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;In a couple of instances, the Rails app depended on the "helpers" - seemingly a collection o methods that are available to be executed either from the view or contoller. I ended up encapsulating some of these common operations into taglibs, so that the usage of the said tags in grails is as follows: &lt;br /&gt;&lt;br /&gt;Rails (a sample Helper located in the Helpers project node):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgE3-ECGwkI/AAAAAAAAAkY/TeJHqKQAR_I/s1600-h/rails_helpers.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 237px; height: 204px;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgE3-ECGwkI/AAAAAAAAAkY/TeJHqKQAR_I/s320/rails_helpers.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332604973157368386" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;require 'bluecloth'&lt;br /&gt;module ApplicationHelper&lt;br /&gt; include TagsHelper&lt;br /&gt;    def link_to_button(label)&lt;br /&gt;     "&amp;lt;table cellpadding=0 cellspacing=0 class=button_action_link&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td align=right style=\"background: url('/images/left_button_curve.gif') no-repeat; width: 8px; height: 23px;\"&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td nowarp=\"nowrap\" style=\"background: url('/images/center_button_bg.gif') repeat;\"&amp;gt; #{label} &amp;lt;/td&amp;gt;&amp;lt;td style=\"background: url('/images/right_button_curve.gif') no-repeat; width: 29px; height: 23px;\"&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;"&lt;br /&gt;   end      &lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgE4K8rrwOI/AAAAAAAAAkg/c1O4bDzFJp0/s1600-h/grails_taglib.png"&gt;&lt;img style="float:left; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 241px; height: 212px;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgE4K8rrwOI/AAAAAAAAAkg/c1O4bDzFJp0/s320/grails_taglib.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332605194522575074" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;In Grails, it becomes the following:&lt;br /&gt;class CosTagLib {&lt;br /&gt;&lt;br /&gt;    def linkToButton = { attrs -&gt;&lt;br /&gt;        out &amp;lt;&amp;lt; "&amp;lt;table cellpadding=0 cellspacing=0 class=button_action_link&gt;&amp;lt;tr&gt;&amp;lt;td align=right style=\"background: url('${createLinkTo(dir:"images",file:"left_button_curve.gif")}') no-repeat; width: 8px; height: 23px;\"&gt;&amp;lt;/td&gt;&amp;lt;td nowarp=\"nowrap\" style=\"background: url('${createLinkTo(dir:"images",file:"center_button_bg.gif")}') repeat;\"&gt; ${attrs.label} &amp;lt;/td&gt;&amp;lt;td style=\"background: url('${createLinkTo(dir:"images",file:"right_button_curve.gif")}') no-repeat; width: 29px; height: 23px;\"&gt;&amp;lt;/td&gt;&amp;lt;/tr&gt;&amp;lt;/table&gt;"&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;An alternative to adding common helper functionality in tag libraries is to add the same methods as public methods on the superclass. For example, the parent controller contains the following closure:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;    def current_user = {&lt;br /&gt;  if (this.currentUser==null &amp;&amp; session.user) {&lt;br /&gt;   this.currentUser = User.get(session.user.id)&lt;br /&gt;  }&lt;br /&gt;        println "Returning currentUser ${currentUser} "&lt;br /&gt;  return currentUser;&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then, in GSPs, one can use the closure as follows:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;   &lt;g:render template="/notes/notes_scaffold" model="[notes:UserNote.findAllByUserAndCourse(user?:current_user(),course)]" /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="conclusion"&gt;5. Conclusion&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It's interesting that the migration of views/templates is probably the least complicated part of migrating a Rails app to Grails. Yet, at the same time, together w/ migrating the controllers it was possibly the most time consuming task. Understandably, these artifacts represent ARE the web application. While there probably isn't a good way to automatically convert the controller code, the view code is much more amenable to such an automated conversion, tag-for-tag. &lt;br /&gt;&lt;br /&gt;For a lot of these repetitive tasks of converting the app UI tag by tag ( I didn't spend the time to create an auto-converter), I ended up creating a couple of NetBeans live templates that give me parameter and code completion of attributes, jumping between different params, etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-5673112230332670302?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/9jwUaUHC_KU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/5673112230332670302/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2009/05/converting-legacy-rails-apps-to-grails_05.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/5673112230332670302?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/5673112230332670302?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/9jwUaUHC_KU/converting-legacy-rails-apps-to-grails_05.html" title="Converting legacy Rails apps to Grails : The Views" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_GbeUi4pR7kA/SgEWEB197rI/AAAAAAAAAkI/BrEOZ3-o9JQ/s72-c/rails_views_structure.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.troymaxventures.com/2009/05/converting-legacy-rails-apps-to-grails_05.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UBRXs_cSp7ImA9WxJREUU.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-6050026609053975937</id><published>2009-05-05T16:37:00.013-05:00</published><updated>2009-05-12T23:34:14.549-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-12T23:34:14.549-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="legacy rails" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Converting legacy Rails apps to Grails : The Controllers</title><content type="html">So, you've already looked at the previous blog posts on &lt;a href='http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails.html'&gt;Setting up the Project&lt;/a&gt; and &lt;a href="http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails_31.html"&gt;Migrating the Domain Objects&lt;/a&gt;. The whole world must be wondering "What happened to this blog post series, did people just stop migrating from Rails to Grails?". Well, I've been in &lt;a href="http://tapestry.apache.org/tapestry5"&gt;Tapestry&lt;/a&gt; land for the last 6-7 months and haven't had much free time to finish my blogging endeavor to finish my series of articles. But, what do you know : all of a sudden the topic of migrating legacy Rails apps to Grails came back to the fore for me (work related, don't ask, it's top secret), and here I am. In a valiant effort, I will try to finish off the topic in one fell swoop (hopefully today) and bang out a couple of different articles that document in details the ups and downs of such a migration. &lt;br /&gt;&lt;br /&gt;Because this article is on the long side, here is the Table of Contents:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="#overviewOfControllers"&gt;Overview of Controllers&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="#generalLanguageIssues"&gt;General language related issues.&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="#inputProcessing"&gt;Input Processing&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="#inputValidationAndErrors"&gt;Input Validation and Error Reporting&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="#renderingResponses"&gt;Rendering Responses&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="#advancedAjaxiness"&gt;Advanced Ajaxiness : Dynamic Javascript&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="#conclusion"&gt;Conclusion&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="overviewOfControllers"&gt;1. Overview of controllers&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgD9rY6qaLI/AAAAAAAAAjo/z1bHr8O5yEc/s1600-h/rails_controllers.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 237px; height: 142px;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgD9rY6qaLI/AAAAAAAAAjo/z1bHr8O5yEc/s320/rails_controllers.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332540880671369394" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SgD915t_H6I/AAAAAAAAAjw/7j9D-oNX6eQ/s1600-h/grails_controllers.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 233px; height: 173px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SgD915t_H6I/AAAAAAAAAjw/7j9D-oNX6eQ/s320/grails_controllers.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332541061275262882" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, back to the meat and potatoes of this article : migrating the Rails controllers to Grails. It's no secret that Grails heavily borrowed ideas from Rails (and NO, Grails is not Groovy on Rails, there's no mass transit involved at all, it's the good ole cup that everyone wants) and as can be seen from the screenshot of the project setup, both framework keep the controllers in the Controllers NetBeans project folder. Creating Grails controllers is easy: just right click on the Controllers project folder and select "New Controller". NetBeans walks you through naming the Controller properly and creates the needed file and run the regular Grails "create-controller" task, which in creates a default view for the controller. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SgD-D2vjULI/AAAAAAAAAj4/3X0VHRHk-0Q/s1600-h/rails_controller_structure1.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 162px; height: 320px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SgD-D2vjULI/AAAAAAAAAj4/3X0VHRHk-0Q/s320/rails_controller_structure1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332541300994691250" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/SgD-Maz_FtI/AAAAAAAAAkA/9c3XpBh1wCs/s1600-h/grails_controller_structure.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 204px; height: 320px;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/SgD-Maz_FtI/AAAAAAAAAkA/9c3XpBh1wCs/s320/grails_controller_structure.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5332541448115918546" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The structure of the controllers themselves is very similar as well : in both cases, there is a one-to-one relationship between the Rails and Grails controllers. Inside the controller, in both cases, there is a class containing a bunch of closures , methods, and private member variables. In both cases, the closures in the controller become a part of the "public api" exposed by the controller, as all closures can be called from the URL (e.g. http://localhost:8080/app/controllerName/closure -&gt; http://localhost:8080/app/account/login). Private methods are not accessible to be invoked from the URL. For "old school" Java developers who might not be intimately familiar w/ Rails or Grails, it is interesting to note that the controllers are thread safe : that is, they can contain instance variables that will not be clobbered if two concurrent requests are sent to the same controller. A new controller instance is created for each Http request. &lt;br /&gt;&lt;br /&gt;OK, let's see what's inside the controller. Here's an example Rails controller: &lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;class ActivityItemsController &lt; ApplicationController    &lt;br /&gt;  def create&lt;br /&gt;    @activity_item = ActivityItem.new(params[:activity_item])    &lt;br /&gt;    if @activity_item.save      &lt;br /&gt;      // do whatever &lt;br /&gt;    else&lt;br /&gt;      // do whatever else&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Converting this same controller to Grails would look like this: &lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;class ActivityItemsController extends ApplicationController {&lt;br /&gt;    def activity_item;&lt;br /&gt;    &lt;br /&gt;    def create = {&lt;br /&gt;        this.activity_item = new ActivityItem(params.activity_item)&lt;br /&gt;        if (activity.save()) {&lt;br /&gt;            // do whatever&lt;br /&gt;        } else {&lt;br /&gt;            // do whatever else&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a name="generalLanguageIssues" href="#"&gt;2. General language related issues.&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;A lot of things to talk about here. First of all, just looking at the code it looks almost the same. The first superficial difference is the naming convention for the classes : in Rails user underscore_separated_file_names, whereas Groovy uses CamelCase. One notable difference is that in Grails, you do need to declare the class members, whereas in Rails (due to Ruby heritage), the properties can directly be assigned to when needed (e.g. @activity_item = ....). While the Ruby approach does save one line of code to declare the property, while migrating the code I found it very helpful to see the declarations at the top of the Groovy class. When you don't declare the class members upfront, it seems that it's quite easy to create a whole bunch of properties in the Ruby class w/o realizing how many you've created, which generally can lead to muddying the interface (mind you, the said properties are publicly accessible - e.g. from views, other closures, methods, etc).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="inputProcessing"&gt;3. Input processing&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;The second thing to note is the existence of the "params" map in both cases. In both cases, one can both read from and write to the params map using the accepted syntax : map[:key] in Ruby and map.key or map[key] in Groovy. So, nothing particularly interesting here. A bunch of other default objects are available in the Grails controller (probably quite familiar to Java Devs) such as servletContext, session, request, params, flash. Dealing with all is mostly the same in both frameworks and should be familiar to anyone done anything on the web.&lt;br /&gt;&lt;br /&gt;When processing input, in a number of places, Rails uses the following shortcut/idiom to bulk update the values of many attributes of an object from request parameters at once:&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;   class Foo &lt;br /&gt;   &lt;br /&gt;    def bar &lt;br /&gt;        @activity.update_attributes(params[:activity])&lt;br /&gt;    end&lt;br /&gt;   end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To cut the long story short, this take in the value of request parameters and binds them to values in the object (note, this has severe security implications but that's a different topic to discuss). Grails offers an equivalent statement with: &lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;   class Foo {&lt;br /&gt;        def activity&lt;br /&gt;        &lt;br /&gt;        def bar = {&lt;br /&gt;            bindData(activity,params.activity)&lt;br /&gt;        }&lt;br /&gt;   &lt;br /&gt;   }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If using the straight out &lt;a href="http://grails.org/doc/1.1/ref/Controllers/bindData.html"&gt;bindData&lt;/a&gt; method from Grails it accomplishes the same thing, with the same security implications. Whenever I actually bumped into examples like this, I tried to address some of the security issues by using the "more advanced" bindData method in Grails, which allows specifying parameters to exclude and a prefix of a property to use for binding, e.g. if I only wanted to bind the customer.name and customer.phone attributes from the request and I definitely wanted to prevent the customer.id attribute being affected, I'd use something like this:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;bindData(myCustomerObject,params,["id"], "customer")&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="inputValidationAndErrors"&gt;4. Input Validation and Error Reporting&lt;/a&gt;&lt;/span&gt;  &lt;br /&gt;In both framework, a large part of validating the input that is written to the domain model is done by specifying constraints in the domain model itself (e.g. see &lt;a href="http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails_31.html"&gt;the article&lt;/a&gt; about the Rails-&gt;Grails domain migration). Thus, in both frameworks, code like this is pretty common: &lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;if @activity.save&lt;br /&gt;    // do whatever on success&lt;br /&gt;else&lt;br /&gt;   flash[:error]= @activity.errors.full_messages.join("&lt;br/&gt;") &lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In Grails, the code looks very similar:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;if (activity.save()) {&lt;br /&gt;    // do whatever on success&lt;br /&gt;} else {&lt;br /&gt;    flash.error = activity.errors&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;One minor difference here is that (at least in this app), the Rails just concatenated the error messages as text and placed them in the "error" property in flash scope. In contrast, Grails assigns the actual "errors" object to the same flash property, then allowing the view to render these error objects as it wishes (e.g. using the &lt;a href="http://grails.org/doc/1.1/ref/Tags/renderErrors.html"&gt;g:renderErrors&lt;/a&gt; tag), which would allow rendering an error for a particular property, etc.&lt;br /&gt;&lt;br /&gt;In both frameworks, validation of can happen in the controller itself, and errors can be added to the relevant error property (in the appropriate scope). &lt;br /&gt;&lt;br /&gt;One more advanced feature of Grails that I found very useful later on in the conversion are the Grails are the form beans that you can use to populate values from the request (thus shielding from the security issues referred to further up), validating the input in a domain-class style approach, and generating errors in a nice and easy manner. So, here's the form object:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;public class ChangePasswordForm {&lt;br /&gt; String oldPassword;&lt;br /&gt; String password;&lt;br /&gt; String passwordConfirmation;&lt;br /&gt;&lt;br /&gt; static constraints = {&lt;br /&gt;  oldPassword(nullable:false,blank:false)&lt;br /&gt;  password(nullable:false, blank:false, size:4..40)&lt;br /&gt;  passwordConfirmation(nullable:false, blank:false, size:4..40,&lt;br /&gt;   validator: { oldPw, chgPwdCmd -&gt;&lt;br /&gt;    if (oldPw!=chgPwdCmd.password) {&lt;br /&gt;     return "notsame.message"&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;  )&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You'll note the declarative syntax familiar from domain object validation, it's a beauty !!!&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&amp;lt;g:formRemote url="[action:'change_password']" name="ChangePasswordForm"&lt;br /&gt;       before="Element.show('form-indicator-pwd')"&lt;br /&gt;       onSuccess="Element.hide('form-indicator-pwd')"&amp;gt;&lt;br /&gt;                   &lt;br /&gt;&amp;lt;/g:formRemote&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Add the following to your grails-app/i18n/messages.properties for custom error messages:&lt;br /&gt;&lt;pre name="code"&gt;&lt;br /&gt;#Custom messages&lt;br /&gt;forms.ChangePasswordForm.passwordConfirmation.notsame.message=Password confirmation not the same as password&lt;br /&gt;wrong.password.message.forms.ChangePasswordForm.password=Old password is wrong, please enter again&lt;br /&gt;forms.ChangePasswordForm.password.blank.message={0} cannot be blank&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Finally, using the form in the controller when submitted:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;def change_password = { ChangePasswordForm changePasswordForm -&gt;   &lt;br /&gt;        if (!changePasswordForm.hasErrors()) {   &lt;br /&gt;            // accessing the values from the form&lt;br /&gt;            def pwdValue = changePasswordForm.password&lt;br /&gt;            // adding a custom error to the form for an error not enforced in constraints&lt;br /&gt;            if (whateverRandomReasonYouWantToRejectAField) {&lt;br /&gt;                changePasswordForm.errors.rejectValue("password","wrong.password.message")&lt;br /&gt;            }&lt;br /&gt;            // do whatever &lt;br /&gt;        } else {&lt;br /&gt;            // do whatever else&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Finally, it seemed like a pretty common idiom in the Rails app to use dynamic javascript (I will talk about that plugin later ) to render errors back to the client:&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;      if (@activity.save) &lt;br /&gt;            // do whatever on success &lt;br /&gt;      else&lt;br /&gt;        flash[:error] = "#{@activity.errors.full_messages.join('&lt;br/&gt;')}"&lt;br /&gt;          render :update do |page|&lt;br /&gt;            page.replace_html "errors_div", :partial =&gt; "common/errors_flash",:layout=&gt;false&lt;br /&gt;            // do whatever else to the page&lt;br /&gt;          end&lt;br /&gt;      end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In essense, this takes the validation errors, renders them using the "errors_flash" template, and replaces the content of the "errors_div" in the page with the rendering result. This approach caused me a lot of grief initially, but after a little bit of work it turned into the following in my Grails app: &lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;    if (activity_item.save()) {&lt;br /&gt;        // do whatever on success &lt;br /&gt;    } else {&lt;br /&gt;        js_error(activity_item.errors)&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Where the js_error method in the controller superclass, looks something like this (using the dynamic javascript plugin that will be discussed later): &lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;def js_error = { errors -&gt;&lt;br /&gt;    flash.error = errors&lt;br /&gt;    log.debug "Sending errors back to client: ${errors}"&lt;br /&gt;    renderJavascript {&lt;br /&gt;        update 'errors_div', [text:g.render(template:"/common/errors_flash")]&lt;br /&gt;        callFunction "Element.show" , 'errors_div'&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="renderingResponses"&gt;5. Rendering Responses&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;Converting the response rendering from Rails to Grails was pretty straightforward, here's the Rails example:&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;  def new&lt;br /&gt;    render :partial =&gt; "new", :layout =&gt; false&lt;br /&gt;  end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In Grails, this becomes:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;    def _new = {&lt;br /&gt;        render(template:"new")&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;One tricky thing to note here is that because "new" is a Groovy keyword, I could not use the same closure name, NBD. The &lt;a href="http://grails.org/doc/1.1/ref/Controllers/render.html"&gt;render controller method&lt;/a&gt; is pretty much the best thing since sliced bread and can render a whole bunch of things like regular pages, templates, XML, or JSON. Grails uses a convention that partial pages (templates) are named starting w/ an underscore. Thus, when you do:&lt;br /&gt;&lt;pre name="code" style="java"&gt;&lt;br /&gt;   render(template:"fooTemplate")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Grails finds the _footemplate.gsp file and renders it (equivalent to the Rails render :partial =&gt; "footemplate" which renders _footemplate.rhtml). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One other common idiom in the Rails app was to issue redirects from the controller: &lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;redirect_to  :action =&gt; 'show', :controller =&gt; 'activities', :id=&gt; params[:act_id]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Grails supports this idiom pretty nicely with the &lt;a href="http://grails.org/doc/1.1/ref/Controllers/redirect.html"&gt;redicect controller method&lt;/a&gt; with pretty much the same parameters:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;redirect(controller:'activities', action:'show', id:params.act_id)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This particular project was using both script-centered and content-centered AJAX, and not much data-centered AJAX, so I didn't get to use JSON or XML rendering much; however, I always found the automatic marshalling to JSON or XML pretty cool: &lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;// Automatic marshalling of XML and JSON&lt;br /&gt;import grails.converters.*&lt;br /&gt;…&lt;br /&gt;render Book.list(params) as JSON&lt;br /&gt;render Book.get(params.id) as XML&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Finally, one cool feature of Rails that I initially missed was the ability to specify the default layout per controller :&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;class ActivitiesController &lt; ApplicationController&lt;br /&gt;  layout "internal"&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The statement above sets the default layout for this controller in the controller itself. Grails supports specifying the layout either by convention (e.g. grails-app/views/layouts/CONTROLLER.gsp or grails-app/views/layouts/CONTROLLER/ACTION.gsp , effectively equivalent to specifying layout="internal" in the controller)  or explicitly in the template by specifying a meta tag (&amp;lt;meta name="layout" content="internal"&amp;gt;&amp;lt/meta&amp;lt;) in the template. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="advancedAjaxiness"&gt;6. Advanced Ajaxiness : Dynamic Javascript&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;I was planning to discuss Rails plugins in a separate article; however, there is one particular Grails plugin that was extremely useful to cover a portion of Rails that Grails doesn't cover out of the box. More specifically, I'm talking about the Rails script centered AJAX w/ dynamic javascript, e.g. : &lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;render :update do |page|&lt;br /&gt;    page.replace_html "errors_div", :partial =&gt; "common/errors_flash",:layout=&gt;false&lt;br /&gt;    page.replace_html "show_activities", :partial=&gt;"show", :layout=&gt;false&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As explained before, this replaces the content of the "errors_div" in the page w/ the rendered "errors_flash" template (which basically renders the flash errors in a list or something like that), and then replaces the content of the "show_activities" div w/ the content of the partial template. &lt;br /&gt;&lt;br /&gt;My initial approach was to change the actual pages to process the response and update the right div w/ the returned content, but it was a big PITA, considering how much the Rails app used this. Finally, after some searching on the net, I found the &lt;a href="http://www.grails.org/Dynamic+Javascript+Plugin"&gt;Dynamic Javascript&lt;/a&gt; plugin. It had most of the features I needed to implement this Rails idiom with something like this: &lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;renderJavascript {&lt;br /&gt;    update 'errors_div', [text:g.render(template:"/common/errors_flash")]&lt;br /&gt;    callFunction "Element.show" , 'errors_div'&lt;br /&gt;    update 'show_activities', [text:g.render(template:"show_activities")]&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, in places where I needed to update multiple elements on the page, I ended up using this style of code in the controller itself. However, the majority of the uses were the following:&lt;br /&gt;* Render an error div&lt;br /&gt;* Replace a content div w/ the content of a template&lt;br /&gt;* A combination of the two. &lt;br /&gt;&lt;br /&gt;As a result, I moved the following code into the parent class of my controllers: &lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;def js_error = { errors -&gt;&lt;br /&gt;    flash.error = errors&lt;br /&gt;    log.debug "Sending errors back to client: ${errors}"&lt;br /&gt;    renderJavascript {&lt;br /&gt;        update 'errors_div', [text:g.render(template:"/common/errors_flash")]&lt;br /&gt;        callFunction "Element.show" , 'errors_div'&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;def js_render = { replaceDiv,replaceContent -&gt;&lt;br /&gt;    renderJavascript {&lt;br /&gt;        replace replaceDiv, [text:replaceContent]&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;def js_error_and_replace = { errors, replaceDiv,replaceContent -&gt;&lt;br /&gt;    flash.error = errors&lt;br /&gt;    println "Found errors ${errors}"&lt;br /&gt;    renderJavascript {&lt;br /&gt;        update 'errors_div', [text:g.render(template:"/common/errors_flash")]&lt;br /&gt;        callFunction "Element.show" , 'errors_div'&lt;br /&gt;        replace replaceDiv, replaceContent&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Which significantly simplified the code in the actual controllers, e.g. : &lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;if (this.user.authenticate(user.login, changePasswordForm.password)) {&lt;br /&gt;    if (this.user.save()) {&lt;br /&gt;        flash.notice = "Password Changed"&lt;br /&gt;        js_render("change_password", g.render(template:"change_password_form"))&lt;br /&gt;    } else {&lt;br /&gt;        flash.notice = "Password could not be changed"&lt;br /&gt;        js_error(user.errors)&lt;br /&gt;    }&lt;br /&gt;} else {&lt;br /&gt;    println "Didn't authenticate w/ password"   &lt;br /&gt;    js_error_and_replace(changePasswordForm.errors,"change_password",[text:g.render(template:"change_password_form")])&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As mentioned above (and as expected), Grails support redirects pretty nicely. However, Javascript redirects , though not necessarily tricky, still required an extra piece of code to the parent controller:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;def js_redirect = { redirectUrl -&gt;&lt;br /&gt;    def jsRedirect = "document.location = \'$redirectUrl\'"    &lt;br /&gt;    renderJavascript {&lt;br /&gt;        appendJavascript jsRedirect;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;At which point, the code in the controller is really straightforward:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;js_redirect(createLink(controller:'activities', action:'show',id:params.id))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;However, one of the use cases involved a form executing in a frame (an upload form that did some status updates in a frame), which depending on the content returned in the frame, needed to redirect the whole browser window whenever the upload was done. In Rails it was handled as such: &lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;responds_to_parent do&lt;br /&gt;    render :update do |page|&lt;br /&gt;      flash[:notice] = "File Uploaded Sucessfully"&lt;br /&gt;      page.redirect_to :action =&gt;'show', :controller=&gt;'activities', :id=&gt;params[:activity_id]&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The code in the parent controller to support this idiom is as follows:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;def parent_redirect = { redirectUrl -&gt;    &lt;br /&gt;    render (text : "&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;"+&lt;br /&gt;        "&amp;lt;script type='text/javascript' charset='utf-8'&amp;gt;"+&lt;br /&gt;            "var loc = document.location;"+&lt;br /&gt;            "with(window.parent) {"+&lt;br /&gt;            " setTimeout(function() { "+&lt;br /&gt;                    "window.eval(document.location = \'$redirectUrl\'); loc.replace('about:blank'); "+&lt;br /&gt;                "}, 1)"+&lt;br /&gt;            "}"+&lt;br /&gt;        "&amp;lt;/script&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;")&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;One final note on the Dynamic Javascript plugin : the plugin that is uploaded on the Grails wiki is version 0.1 . The plugin appears to not be maintained actively; however, the linked author's blog (http://blog.peelmeagrape.net/2007/10/9/dynamic-javascript-plugin-for-grails) has version 0.2 of the plugin. Still, when I was heavily using this plugin, I ran into some issues with it and had to patch it as follows (in plugins/dynamic-javascript-0.2/src/groovy/JavascriptBuilder.groovy , commented out code is the broken part):&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;    private String renderTemplate(Map options)&lt;br /&gt;    {&lt;br /&gt;//        StringWriter s = new StringWriter()&lt;br /&gt;//        GrailsWebRequest webRequest = (GrailsWebRequest)RequestContextHolder.currentRequestAttributes();&lt;br /&gt;//        HttpServletResponse response = webRequest.getCurrentResponse();&lt;br /&gt;//        def writer = (RoutablePrintWriter)webRequest.getOut()&lt;br /&gt;        return controller.g.render(options);&lt;br /&gt;//        writer.destination.out.toString();&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I posted on the author's blog w/ the proposed change, and later on received a notification that he liked the change and that he would incorporate it into the plugin. However, it appears that the plugin on his page is still at version 0.2 and my comment has disappeared from the blog. Oh, well... &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;a href="#" name="conclusion"&gt;Conclusion&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;It was quite a journey so far. None of the problems in migrating controllers are particularly difficult or mind bending; however, there are just a lot of different issues to deal with if you're starting from scratch. So, now that you have all this good info, &lt;span style="font-weight:bold;"&gt;START MIGRATING THAT RAILS APP THAT YOU'VE BEEN EYEING, WOULD YA !!???!!!&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-6050026609053975937?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/_Jvt1mku0c8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/6050026609053975937/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2009/05/converting-legacy-rails-apps-to-grails.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6050026609053975937?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6050026609053975937?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/_Jvt1mku0c8/converting-legacy-rails-apps-to-grails.html" title="Converting legacy Rails apps to Grails : The Controllers" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_GbeUi4pR7kA/SgD9rY6qaLI/AAAAAAAAAjo/z1bHr8O5yEc/s72-c/rails_controllers.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://www.troymaxventures.com/2009/05/converting-legacy-rails-apps-to-grails.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYBR3s8fSp7ImA9WxJSFUk.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-6550335578525453645</id><published>2008-10-31T23:18:00.019-05:00</published><updated>2009-05-05T13:12:36.575-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-05T13:12:36.575-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Converting legacy Rails apps to Grails : The Domain</title><content type="html">&lt;span style="font-weight: bold;font-size:100%;" &gt;A little story about legacies...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;(skip this if you're not interested in hearing a sobbing sentimental story and just want to get to the good stuff)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First a short story about my usage of "legacy" in the title of the post. So, here it is : a few years ago, Rails explodes on the scene. Everybody around you who knows a thing or two about web apps start thinking and asking whether your next app should be in Rails instead of XXX [substitute your framework here]. Nevermind that you'll be writing an "enterprise application" that would most likely need to integrate with the rest of your infrastructure (Java, PHP, whatever), or that the said application might have some performance requirements (e.g. it actually needs to DO something, instead of just pushing a few form feelds from and to the database).&lt;br /&gt;&lt;br /&gt;Alright, so, Ruby is cool, Ruby is all the rage. You bring in that intern that seems to be a Rails wizard, he totally blinded you with how he put together an app w/ 3-4 forms in less than an hour. Nobody on your existing team can do that : they want to "think about the problem", "understand what needs to be done", put some thought into how to do it, and only then start writing the code. Not so w/ your superstar intern : he's banging out page after page, form after form, it's glitzy and it's Ajaxy, your heart is about to melt from the love towards your unexpected intern saviour.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Fast forward to a few years later. Your intern is gone, he's onto his next new and exciting gig. Your loyal developers have learned a few tricks from the now "old and crusty" Rails app, you got the next version of your Java web framework and your devs are doing quite better with giving you the "quick forms" when you need them. Your customers, initially raving about how quickly they got their app, are now increasingly annoyed that when they ask for what is seemingly simple feature (e.g. hook into this other database that's not mysql, talk to that 'other app' that's been there for a while) and your estimates are way too high ('cause you have to write all that stuff from scratch). To make things worse, your developers actually popped the hood on the Rails app, and it's a big happy bowl of spaghetti : the controllers have their hands in everything : poking around the database, spitting back dynamic javascript groping the glitzy UI in the most unbelievable places (and btw, your devs don't want to touch it with a ten foot pole). When your company scored that big customer, everybody was enamoured by the cha-ching of the cash register, but nobody thought that all those new users will want to use your intern's app (which btw, turned out to not know much about web apps in general, as Rails was the first thing he learned), and now both new and existing customers are not so happy that it takes longer and longer for the app to service them. On top of that, there are very few people who do understand all the magic that happens under the hood in the Rails app, and there are yet fewer people who know how to scale it to the level you need.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.archives.gov.on.ca/english/exhibits/christmas03/pics/3772_locomotive_820.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 820px; height: 522px;" src="http://www.archives.gov.on.ca/english/on-line-exhibits/christmas-03/pics/3772_locomotive_820.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;That's the place where the phrase "Legacy Rails" really starts making sense. Sure, there are new releases that promise a little more glitz to your app, the framework is still being actively developed, and nearly everyone out there has heard of Rails by now. But now that you're in this situation, can you really put your job on the line that just this next release will have the promised silver bullet ? Or would it maybe be better to just move the game back into your home court, where you set the rules, your dev team knows the ins and outs of the technology like the back of their hand, it scales well, integrates with EVERYTHING you could imagine ? That's when you really want that little Rails locomotive to let off some steam and disappear into the distance just as quickly as it arrived.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Anyway, I digress :-) Back to what I was talking about : how do you migrate the app to Grails.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Now The Goodies&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Below is a sample Rails model class that we'll use to talk about the migration:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;class Activity &lt; ActiveRecord::Base&lt;br /&gt;  has_many :activity_items&lt;br /&gt;  has_many :user_notes  &lt;br /&gt;  belongs_to :competency_group&lt;br /&gt;  belongs_to :course&lt;br /&gt;  &lt;br /&gt;  has_many :activity_item_assets&lt;br /&gt;   &lt;br /&gt;  belongs_to :created_by, :class_name =&gt; "User", :foreign_key =&gt; "created_by"&lt;br /&gt;  belongs_to :updated_by, :class_name =&gt; "User", :foreign_key =&gt; "updated_by"&lt;br /&gt;  &lt;br /&gt;  validates_presence_of :title, :instruction_text, :competency_group_id&lt;br /&gt;  validates_length_of :title, :maximum  =&gt; AdminType::COURSE_TITLE_LENGTH&lt;br /&gt;  validates_uniqueness_of :title, :scope =&gt; [:competency_group_id]&lt;br /&gt;  &lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And the equivalent Grails domain object:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;class Activity {&lt;br /&gt;&lt;br /&gt;String title, instructionText&lt;br /&gt;Date createdAt, updatedAt&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;static hasMany = [activityItems : ActivityItem, userNotes : UserNote, activityItemAssets:ActivityItemAsset]&lt;br /&gt;static belongsTo = [competencyGroup:CompetencyGroup, course : Course, createdBy : User, updatedBy : User]&lt;br /&gt;&lt;br /&gt;static constraints = {&lt;br /&gt;   title(nullable:false,blank:false,size:1..AdminType.COURSE_TITLE_LENGTH,unique:['competencyGroup'])&lt;br /&gt;   instructionText(nullable:false, blank:false)&lt;br /&gt;   createdAt(nullable:true)&lt;br /&gt;   updatedAt(nullable:true)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static mapping = {&lt;br /&gt;   table 'activities'&lt;br /&gt;   createdBy column:'created_by'&lt;br /&gt;   updatedBy column:'updated_by'&lt;br /&gt;   version false&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Location &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Both Rails and Grails have a specific place where you can keep your domain objects. In Rails, you keep it in the app/models directory (the Models directory in your NetBeans project), whereas in Grails it's in grails-app/domain directory (the Domain Classes folder in the NetBeans project).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Purpose &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In both cases, the purpose of the domain objects represent the most important concepts in your application. Additionally, they typically are "persistence capable" (e.g. you can persist an instance w/ a single call), and they provide for a fairly simple specification of relationships w/ other domain objects, as well as allow for specifying validation rules.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQztC77HyQI/AAAAAAAAAgw/AYBZir0XTjM/s1600-h/grails_new_domain_class.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 400px; height: 259px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQztC77HyQI/AAAAAAAAAgw/AYBZir0XTjM/s400/grails_new_domain_class.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5263842699190454530" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQzuS3-zYXI/AAAAAAAAAg4/F3TyGF4wTYQ/s1600-h/grails_new_domain_class_wizard.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 220px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQzuS3-zYXI/AAAAAAAAAg4/F3TyGF4wTYQ/s320/grails_new_domain_class_wizard.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5263844072521687410" /&gt;&lt;/a&gt;&lt;br /&gt;NetBeans provides fairly basic support for creating the domain objects : you get a little wizard that asks for the name of the domain object and it creates the Groovy class for you. One of the cool things about how NetBeans handles Grails is that it doesn't create any new metadata (e.g. there's no project directory created), and because the NetBeans project system is based on Ant, the NetBeans project simply delegates the creation of the domain class to the Grails Ant scripts. &lt;br /&gt;&lt;br /&gt;Note that when you're looking at the differences between the Grails and the Rails classes, you will notice that (by design), the Grails class is much more focused on the domain, whereas the Rails class is much closer to the database. Thus, for example, you will notice that in the last line of the Rails validation, it references the "competency_group_id". I would imagine this is where my lack of knowledge of the Rails CoC (convention over configuration) bit me in the back, but in a number of places (that I'll mention), the Rails code is allowed to reference "assumed" column names (based on the CoC), which is generally confusing, and also seems to be very refactoring unfriendly (e.g. what if at some point in life, I needed to have a slightly different colum name - would I have to hunt down &lt;span style="font-weight: bold;"&gt;all&lt;/span&gt; references to that column)???&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. Class properties &amp;amp; Relationships&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;class Activity {&lt;br /&gt;&lt;br /&gt;   String title, instructionText&lt;br /&gt;   Date createdAt, updatedAt&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   static hasMany = [activityItems : ActivityItem, userNotes : UserNote, activityItemAssets:ActivityItemAsset]&lt;br /&gt;   static belongsTo = [competencyGroup:CompetencyGroup, course : Course, createdBy : User, updatedBy : User]&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Migrating the class properties &amp;amp; relationships is pretty straightforward. For each "simple" property in the Rails class, you can declare a corresponding one in the Groovy class. Declaring the equivalent relationships in the Grails class is also quite straightforward, as the relationship names are pretty much the same. Although there is nothing in Groovy that prevents you from using the Rails naming conventions for properties (e.g. user_name), the Groovy convention is very much like in Java - CamelCase.&lt;br /&gt;&lt;br /&gt;This is probably due to my Java background, but I found the ability to declare a class member variable anywhere in the Ruby class much less readable than the equivalent Groovy class. What I mean is that, in the example above, the ":title" property is not mentioned anywhere before the validation constraint. Thus, in order to figure out the properties, you need to examine not only the relationships but also all validation constraints. Although in the Groovy class, the declaration of the relationships similarly defines properties in the class, but at least in validation, mapping, etc. you definitely need to refer to properties that are declared somewhere. I guess this probably comes down to preference, but in my opinion, looking at the Grails class, I can see all the available properties at a glance.&lt;br /&gt;&lt;br /&gt;In a very similar manner, I find that even the relationship declarations are very much more readable in Grails. One glance, and I can recognize all relationship types (e.g. one to one, many-to-one, whatever) and the properties corresponding to those relationships. In contrast, although the same can be accomplished in the Rails declarations (e.g. if you specify all has_one mentions one after another), not all Rails model classes that I had to look at followed such a convention.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. Validation &lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;static constraints = {&lt;br /&gt;   title(nullable:false,blank:false,size:1..AdminType.COURSE_TITLE_LENGTH,unique:['competencyGroup'])&lt;br /&gt;   instructionText(nullable:false, blank:false)&lt;br /&gt;   createdAt(nullable:true)&lt;br /&gt;   updatedAt(nullable:true)&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Once again, migrating the Rails validations is pretty straightforward, although not all Rails validations had a 1:1 translation in Grails. This is where &lt;a href="http://grails.org/doc/1.0.x/guide/single.html#7.%20Validation"&gt;the validation section of the Grails manual &lt;/a&gt; came in very handy, expecially during the first steps in the conversion when I wasn't really sure how to convert from one constraint in Rails to its Grails counterpart.&lt;br /&gt;&lt;br /&gt;One thing to notice that is subtle but different between the Grails and Rails validations. In Grails, if a class property is not explicitly declared as "nullable", it is by default required. On quite a few occasions during the conversion, after initially migrating the explicit Rails constraints, I found myself going back to the domain class in order to make some of the Grails domain class fields optional.&lt;br /&gt;&lt;br /&gt;One final point on validation is the  title uniqueness constraint. In Rails it looks like :&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;validates_uniqueness_of :title, :scope =&gt; [:competency_group_id]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And in Grails it is :&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;title(nullable:false,blank:false,size:1..AdminType.COURSE_TITLE_LENGTH,unique:['competencyGroup'])&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The thing to notice here is that Rails directly goes to the colum name, whereas Grails just uses the property name declared in the class.&lt;br /&gt;&lt;br /&gt;Once again, I find the Grails validation section much more readable, as all constraints are organized in one section, and they're organized around the concepts that a user cares about. Thus, when I'm thinking about the validations that apply to a title, I can specify all constraints in the title constraints, compared to the Rails style, where the declarations are focused around the constraints (e.g. when you are thinking about a concept in the domain, do you think "Hm, let me figure out which properties of this class might need a format constraint?", or do you think "Hm, let me see, a title, what kind of constraints might it need, maybe a format constraint?"&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5. Mapping into the database &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;static mapping = {&lt;br /&gt;   table 'activities'&lt;br /&gt;   createdBy column:'created_by'&lt;br /&gt;   updatedBy column:'updated_by'&lt;br /&gt;   version false&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As you see in the "mapping" section of the Grails class, there were a few attributes that needed to mapped explicitly. The reason I had to do this is that at least during the initial migration, it was preferable that the Rails and Grails app work off the same database schema, so that the two apps can be tested side-by-side on the same data.&lt;br /&gt;&lt;br /&gt;The mapping of the Grails app into the Rails database was pretty straightforward, as they follow very similar naming conventions for naming the database columns. First, Rails has the habit of converting the domain class names to plural for the table names, thus I had to add the mapping in the Grails app to point to the same tables. Additionally, the Rails class explicitly stated that the foreign keys that connect the user and activity are "created_by" and "updated_by", whereas the default Grails naming convention for the foreign keys would have been "created_by_id" and "updated_by_id", hence the additional mapping.&lt;br /&gt;&lt;br /&gt;You will additionally notice the explicit disabling of the "version" column in the Grails class. The issue here is that by default, Grails uses a "version" column in order to allow Hibernate to do optimistic locking in transactions. Note that removing the version column from the Grails  app has its penalties; however, at least in the initial implementation it was more important to have the same database schema, than to focus on performance. Although initially (before disabling the column) Grails very gracefully handled the addition of the new "version" column to the database, it became an issue when the column was added on a populated database, and the version would receive a null default value. Thus, had I decided to keep it for each table, I would have had to update the version column manually to contain 0 (so that Grails could increment as necessary, otherwise a NPE came up when Grails pulled a null from the database).&lt;br /&gt;&lt;br /&gt;It is recommended that such a version column is restored after the initial migration period in order to allow Hibernate to make use of its optimistic locking performance optimizations.&lt;br /&gt;&lt;br /&gt;6. Non persistent attributes&lt;br /&gt;By default, all attributes defined in the class are persisted in the database. Now, in the example of the User class below, the cleartext password really shouldn't be persisted. Rails gets around it by  declaring it as a virtual attribute:&lt;br /&gt;&lt;pre name="code" class="ruby"&gt;&lt;br /&gt;class User &lt; ActiveRecord::Base  &lt;br /&gt;  # Virtual attribute for the unencrypted password&lt;br /&gt;  attr_accessor :password&lt;br /&gt;  &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The Grails domain class takes a slightly different approach, where the field is still declared, but is also mentioned in a special class attribute to indicate to Grails that the field shouldn't be persisted , and the 'password false' in the mapping section to indicate that a column shouldn't be created in the database.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;class User {&lt;br /&gt;    static mapping = {&lt;br /&gt;       table 'users'&lt;br /&gt;       password false&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    static transients = [ "password"]&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;7. Persistence events&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;class Foo {&lt;br /&gt;    def beforeInsert = {&lt;br /&gt;        makeActivationCode()&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As mentioned above, Rails supports the ability to automatically hook into the persistence events , in the case above, to execute the specified closure at a particular point in the persistence lifecycle. Grails doesn't support this out of the box, but it is extremely easy to accomplish the same functionality by installing the Grails &lt;a href="http://docs.codehaus.org/display/GRAILS/Hibernate+Events+Plugin"&gt;Hibernate Events Plugin&lt;/a&gt;, and then specify a couple of specially named closures&lt;br /&gt;&lt;br /&gt;All in all, throughout the whole conversion I had the feeling that when the Grails folks sat down to figure out how to do things, they put a little bit of thought into how developers actually work with domain classes, what's readable, and what's not, whereas the Rails approach has a little bit more of a "hacked up" feel to it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-6550335578525453645?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/QbYTTVl1n6s" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/6550335578525453645/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails_31.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6550335578525453645?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6550335578525453645?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/QbYTTVl1n6s/converting-legacy-rails-apps-to-grails_31.html" title="Converting legacy Rails apps to Grails : The Domain" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQztC77HyQI/AAAAAAAAAgw/AYBZir0XTjM/s72-c/grails_new_domain_class.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails_31.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcMRno4eip7ImA9WxVSFU4.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-6271821059087895391</id><published>2008-10-23T22:23:00.009-05:00</published><updated>2009-01-09T14:41:27.432-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-09T14:41:27.432-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Converting legacy Rails apps to Grails (with NetBeans) : General Project Setup</title><content type="html">It is hard to describe the pleasure of writing the title above, especially the "legacy" part :-) Although lately the jumping up and down of Ruby &amp; Rails fanboys has subsided a little, after &lt;a href="http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html"&gt;people started realizing&lt;/a&gt; that Rails is not going to kill anything (much less Java, hell if PHP people start going back to PHP that says A LOT!!!). So, a few years later I got a chance to chime in on the subject. &lt;br /&gt;&lt;br /&gt;Anyway, the specific reason for writing this post is that I had a chance to take an existing Rails app, and move it to Grails. Some of the reasons for even attempting is that as much effort and hype has gone into Ruby and Rails, the (C)Ruby is not even close in being able to integrate with everything else like Java can. When you throw into the mix that even JRuby is starting to be faster than (C)Ruby, and that Groovy kicks the pants out of JRuby, there's also a performance story to be told for Grails. Finally, when you throw in the existence of a clear migration path in performance sensitive Groovy/Grails components directly into java (e.g. moving Groovy controllers to Spring MVC controllers, or Groovy services to Java services), migrating from Rails to Grails for integration for performance purposes is just a no brainer. &lt;br /&gt;&lt;br /&gt;Anyway, enough of this high level stuff. I'm sure that if some Rails fanboys get a hold of this article, I'll probably get flamed with claims how Ruby &amp; Rails can perform, and who knows what else, but I'll just leave the high level stuff at what I said above, and I'll focus on on comparing what I saw in Rails from the point of view of a  Grails (and long term Java) developer. Additionally, I will be using a daily NetBeans 6.5 build (very close to RC1) to illustrate the steps I take along the way. &lt;br /&gt;&lt;br /&gt;So, let's get started. &lt;br /&gt;&lt;br /&gt;1. First, getting started with a project. In both Grails and Rails it's very simple to get started with the facilities NetBeans provides. For both Grails and Rails , NetBeans 6.5 provides wizards for creating a new project. &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQFKvqCflfI/AAAAAAAAAfU/0qWocCcgZ1Q/s1600-h/new_grails_project_setup.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 134px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQFKvqCflfI/AAAAAAAAAfU/0qWocCcgZ1Q/s320/new_grails_project_setup.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5260568022344504818" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQFK5-d6RGI/AAAAAAAAAfc/p_h9WxMGshw/s1600-h/new_rails_project_setup2.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 132px;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQFK5-d6RGI/AAAAAAAAAfc/p_h9WxMGshw/s320/new_rails_project_setup2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5260568199626900578" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now, a few comments on the contents of the screenshots. First of all, NetBeans 6.5 ships directly with Groovy &amp; Grails support for the "Java" packaged download (e.g. from http://download.netbeans.org/netbeans/6.5/rc/). In contrast, for the Ruby/Rails support, you have to either download the Ruby package from the same location, or after downloading the Java installer / package, you have to go to the plugin center and install the Ruby/Rails plugin (either way, quite easy). Secondly, when you look at the options for Ruby/Rails projects, you might think that there are more options w/ Ruby and Rails, but it is actually quite deceiving. The reason that there are no separate options to create a "new Grails app w/ existing sources" is that NetBeans totally rocks and can directly open an existing Grails project without having to add any additional project data. On the Groovy front, you can just add Groovy scripts and classes into any Java project, so the extra options in the project menu are just not needed. &lt;br /&gt;&lt;br /&gt;So, at first glance, very marginally and despite the outstanding NetBeans Ruby/Rails support, Grails scores the first point for me. &lt;br /&gt;&lt;br /&gt;2. Second, I had to figure out what the general setup of a Rails app. Here's what a typical project structure looks like in both Grails and Rails: &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/SQFNfYC-VGI/AAAAAAAAAfk/Av4lROz8QE4/s1600-h/grails_project_setup.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 285px; height: 312px;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/SQFNfYC-VGI/AAAAAAAAAfk/Av4lROz8QE4/s320/grails_project_setup.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5260571041171657826" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_GbeUi4pR7kA/SQFNmutiLrI/AAAAAAAAAfs/u3Ktrd9A1XE/s1600-h/rails_project_setup1.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 234px; height: 320px;" src="http://4.bp.blogspot.com/_GbeUi4pR7kA/SQFNmutiLrI/AAAAAAAAAfs/u3Ktrd9A1XE/s320/rails_project_setup1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5260571167514832562" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now, comparing the two project structures, it's very easy to get around the Rails app if you're familiar w/ a Grails project layout. A couple of things to note in the Rails project structure : &lt;br /&gt;* The root of the web app is in the "Public" directory in the Rails app, while in the Grails project it's in the "Web Application" project folder. &lt;br /&gt;* There is a "helpers" folder in the Rails app, which initially puzzled me. In most general terms, the helpers folder contains "controller helpers". Roughly speaking, the functionality that existed in "helpers" in the Rails app eventually founds its way in taglibs in the Grails app. Although I'm not 100% certain of the convention and usage of these helper methods in the Rails app, it seemed like the Rails active scaffold seemed to use some parts of what's in the helpers (however, i could be wrong). &lt;br /&gt;* There is the "Migrations" folder in the Rails project, which seems to be generally useful and not present in the Grails app. Now, I would imagine that such a database centric functionality might not be that relevant in a Grails app, as a Grails app really isn't as aware of the database (as it deals w/ the domain model and not database columns as the Rails app does). Still, it seems like because Grails apps end up very much data driven, some method of managing the schema modifications could be generally useful (although, I really don't have any specific suggestions of what such a tool might be). &lt;br /&gt;* (although you don't see this in the screenshots) If you had plugins installed into your Grails app, you would have a "Plugins" folder, which is roughly equivalent to the Rails "Vendors" foler. &lt;br /&gt;* Finally, the Grails app has a folder called "Services" for creating transactional services , for which the Rails app doesn't have an explicit counterpart. More on transaction handling later. &lt;br /&gt;&lt;br /&gt;All in all, in the rest of the project layout, they're very similar, and if one knows the one framework, it's pretty straightforward to grok the other one. &lt;br /&gt;&lt;br /&gt;Alright, this is the general setup stuff so far. I have a lot more to write about : plugins, ajax support, services, transactions, the whole nine yards. Just to give you a sneak preview, the bottom line is that migrating a Rails app to Grails works very nicely, although not without a few minor hurdles to jump over. More on that in the next post, stay tuned...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-6271821059087895391?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/cLOrU40WGP8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/6271821059087895391/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6271821059087895391?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6271821059087895391?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/cLOrU40WGP8/converting-legacy-rails-apps-to-grails.html" title="Converting legacy Rails apps to Grails (with NetBeans) : General Project Setup" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_GbeUi4pR7kA/SQFKvqCflfI/AAAAAAAAAfU/0qWocCcgZ1Q/s72-c/new_grails_project_setup.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/10/converting-legacy-rails-apps-to-grails.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkEFQn4zeyp7ImA9WxdWF0o.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-4049835707454928147</id><published>2008-07-08T06:04:00.006-05:00</published><updated>2008-07-11T05:03:33.083-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-07-11T05:03:33.083-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="testing" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Switch your test to Groovy ? Maybe not (yet).</title><content type="html">When I attended the No Fluff Just Stuff conference last year, all speakers were pushing Groovy as an excellent choice for everybody's unit testing needs. And it is true that Groovy does bring a number of cool features to the testing party : expressiveness, ability to test private methods, mocks are almost built in the language.. So it's cool, no question about it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In order for a tool to be effective as a unit testing tool, two things need to be true of the tool:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; The tool has to be expressive when reading and writing the tests. In other words, the way the test are written should clearly express the purpose of the test. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt; When tests fail, the failures should very clearly pinpoint the reason for the failure and should help the developer immediately know the cause of the failure&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, how does Groovy measure up ?&lt;br /&gt;&lt;br /&gt;One of the big advantages of using an integrated framework like Grails (when I say integrated, I mean a framework that give you out of the box the whole stack : Ajax, web layer / controller, service layer, persistence) is that it is extremely easy to start writing tests. You just write "grails create-test" on the command line, and you already have the shell for the test. Then, when you want to run the test, you can easily run the test by just running "grails test-app", and voilla, all your unit and integration tests are off and running.&lt;br /&gt;&lt;br /&gt;So, on the first criteria, Groovy really shines. Expressing the intent of the test with Groovy or verifying a particular test condition is way much better than doing the same in plain on Java. Often, reading a test written in Groovy is so much easier to understand what the test writer had in mind, it takes way less code to write and maintain. All in all, Groovy rocks here.&lt;br /&gt;&lt;br /&gt;Now, the second part, pinpointing the cause of the error, I can't say much beyond what the stacktrace below says. Here are a couple of questions on the stacktrace below:&lt;br /&gt;&lt;br /&gt;1. Can you make out where exactly the test fails ?&lt;br /&gt;2. If this was a stack trace out of an error, would you be able to make out where the error occured ?&lt;br /&gt;3. Can you figure out what classes are collaborating in your test ?&lt;br /&gt;&lt;br /&gt;I think the answer to all three questions is probably a "no", or "it's not easy". For me, this is quite a show stopper for moving all my tests to Groovy (which might have previously been in Java). One thing about plain Java is just that : it's plain and simple to follow along. You see a stacktrace, and you immediately know what, how, who went wrong. Now, I could certainly agree that if you take Java, weave in some aspects, or throw in some interceptors (as in the case of EJB), the stacktrace can easily resemble what's below.&lt;br /&gt;&lt;br /&gt;P.S. One final thing about &lt;a href="http://www.nofluffjuststuff.com/"&gt;NFJS&lt;/a&gt; and the push to use Groovy everywhere : it really bugs me that all of smart people who spoke in favor of using Groovy as a testing tool, just kept quiet about things like this. It bugs me very much that when an alternative like this was suggested, I was just given the positive side of the story, and the negatives were not mentioned at all (and mind you, there were definitely questions like "When would you not use Groovy for testing?). So, there seem to be two disappointing options here : either the speakers had not really used Groovy for testing and were pushing without having done any testing in Groovy themselves, or even worse, knew about these warts but intentionally kept shtumm on it&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Cannot cast object 'com.company.foobar.RandomClassToTest@194e3fe' with class 'com.company.foobar.RandomClassToTest' to class 'java.util.List'&lt;br /&gt;&lt;br /&gt;org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.company.foobar.RandomClassToTest@194e3fe' with class 'com.company.foobar.RandomClassToTest' to class 'java.util.List'&lt;br /&gt;at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:340)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:628)&lt;br /&gt;at config.foo.WorkflowConfigTests.transitionsWithStatus(WorkflowConfigTests.groovy:90)&lt;br /&gt;at config.foo.WorkflowConfigTests.this$5$transitionsWithStatus(WorkflowConfigTests.groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at config.foo.WorkflowConfigTests.validateSingleTransition(WorkflowConfigTests.groovy:64)&lt;br /&gt;at config.foo.WorkflowConfigTests.this$5$validateSingleTransition(WorkflowConfigTests.groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:867)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at config.foo.WorkflowConfigTests$_testExistingTransitionRules_closure1.doCall(WorkflowConfigTests.groovy:56)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:305)&lt;br /&gt;at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1041)&lt;br /&gt;at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1018)&lt;br /&gt;at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:51)&lt;br /&gt;at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:54)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:765)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at config.foo.WorkflowConfigTests.testExistingTransitionRules(WorkflowConfigTests.groovy:55)&lt;br /&gt;at org.codehaus.groovy.grails.support.GrailsTestSuite.runTest(GrailsTestSuite.java:72)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:765)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at TestApp_groovy$_run_closure8_closure18_closure19_closure20.doCall(TestApp_groovy:222)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at TestApp_groovy$_run_closure8_closure18_closure19_closure20.doCall(TestApp_groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:287)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeClosure(ScriptBytecodeAdapter.java:598)&lt;br /&gt;at TestApp_groovy$_run_closure10_closure27_closure28.doCall(TestApp_groovy:353)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:48)&lt;br /&gt;at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:72)&lt;br /&gt;at $Proxy20.doInTransaction(Unknown Source)&lt;br /&gt;at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:765)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at TestApp_groovy$_run_closure10_closure27.doCall(TestApp_groovy:365)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at TestApp_groovy$_run_closure10_closure27.call(TestApp_groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeClosure(ScriptBytecodeAdapter.java:598)&lt;br /&gt;at TestApp_groovy$_run_closure8_closure18_closure19.doCall(TestApp_groovy:220)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:305)&lt;br /&gt;at org.codehaus.groovy.runtime.DefaultGroovyMethods.withStream(DefaultGroovyMethods.java:8161)&lt;br /&gt;at org.codehaus.groovy.runtime.DefaultGroovyMethods.withOutputStream(DefaultGroovyMethods.java:7738)&lt;br /&gt;at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:51)&lt;br /&gt;at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:54)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:765)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at TestApp_groovy$_run_closure8_closure18.doCall(TestApp_groovy:195)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:305)&lt;br /&gt;at org.codehaus.groovy.runtime.DefaultGroovyMethods.withStream(DefaultGroovyMethods.java:8161)&lt;br /&gt;at org.codehaus.groovy.runtime.DefaultGroovyMethods.withOutputStream(DefaultGroovyMethods.java:7738)&lt;br /&gt;at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:51)&lt;br /&gt;at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:54)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:765)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at TestApp_groovy$_run_closure8.doCall(TestApp_groovy:194)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at TestApp_groovy$_run_closure8.call(TestApp_groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeClosure(ScriptBytecodeAdapter.java:598)&lt;br /&gt;at TestApp_groovy$_run_closure10.doCall(TestApp_groovy:338)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:94)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at TestApp_groovy$_run_closure10.doCall(TestApp_groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at groovy.lang.Script.invokeMethod(Script.java:87)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:934)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:881)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:94)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrent0(ScriptBytecodeAdapter.java:109)&lt;br /&gt;at TestApp_groovy$_run_closure3.doCall(TestApp_groovy:116)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:94)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at TestApp_groovy$_run_closure3.doCall(TestApp_groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at groovy.lang.Script.invokeMethod(Script.java:87)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:934)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:881)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:94)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrent0(ScriptBytecodeAdapter.java:109)&lt;br /&gt;at TestApp_groovy$_run_closure1.doCall(TestApp_groovy:62)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:94)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at TestApp_groovy$_run_closure1.doCall(TestApp_groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:292)&lt;br /&gt;at groovy.lang.Closure.call(Closure.java:287)&lt;br /&gt;at groovy.lang.Closure.run(Closure.java:368)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:142)&lt;br /&gt;at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:79)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:195)&lt;br /&gt;at gant.Gant.dispatch(Gant.groovy:271)&lt;br /&gt;at gant.Gant.this$2$dispatch(Gant.groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:675)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at gant.Gant.invokeMethod(Gant.groovy)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at gant.Gant.processTargets(Gant.groovy:436)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:77)&lt;br /&gt;at gant.Gant.processArgs(Gant.groovy:372)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)&lt;br /&gt;at org.codehaus.groovy.grails.cli.GrailsScriptRunner.callPluginOrGrailsScript(GrailsScriptRunner.groovy:204)&lt;br /&gt;at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)&lt;br /&gt;at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)&lt;br /&gt;at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1094)&lt;br /&gt;at groovy.lang.ExpandoMetaClass.invokeStaticMethod(ExpandoMetaClass.java:957)&lt;br /&gt;at org.codehaus.groovy.runtime.InvokerHelper.invokeStaticMethod(InvokerHelper.java:800)&lt;br /&gt;at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeStaticMethodN(ScriptBytecodeAdapter.java:212)&lt;br /&gt;at org.codehaus.groovy.grails.cli.GrailsScriptRunner.main(GrailsScriptRunner.groovy:124)&lt;br /&gt;at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:140)&lt;br /&gt;at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:169)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-4049835707454928147?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/reqa4RzkX3I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/4049835707454928147/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/07/switch-your-test-to-groovy-maybe-not.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4049835707454928147?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4049835707454928147?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/reqa4RzkX3I/switch-your-test-to-groovy-maybe-not.html" title="Switch your test to Groovy ? Maybe not (yet)." /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/07/switch-your-test-to-groovy-maybe-not.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cASXY-cSp7ImA9WxRbGEQ.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-6127277507107329490</id><published>2008-05-15T01:41:00.017-05:00</published><updated>2008-12-10T03:50:48.859-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-10T03:50:48.859-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><title>Tapestry5 NetBeans Quickstart</title><content type="html">I have been following the development of Tapestry 5 closely for the last couple of months, and I even got the first Tapestry 5 book that came out. I'm a big Tapestry fan, and I've been looking forward to the new Tapestry 5 release. I even lucked out and had a chance to talk to &lt;a href="http://tapestryjava.blogspot.com/"&gt;Howard&lt;/a&gt; in person:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/SCveQnOb0UI/AAAAAAAAAUU/8pm_V7zUJ7w/s1600-h/nfjs_howard.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/SCveQnOb0UI/AAAAAAAAAUU/8pm_V7zUJ7w/s400/nfjs_howard.jpg" alt="" id="BLOGGER_PHOTO_ID_5200494571718168898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;One of the cool things that keeps drawing me towards Tapestry is the goal to make it really easy and intuitive to work with. One of the goals that I remember hearing for Tapestry 5 was to make it that easy, that it would compete more w/ Grails &amp;amp; Rails and not so much w/ traditional Java Web app frameworks (e.g. Struts, Struts2, etc)&lt;br /&gt;&lt;br /&gt;However, when I first took a look at Tapestry 5, I was a little disappointed by the six line Maven command that one had to type in when starting a new project (e.g. see http://tapestry.apache.org/tapestry5/tutorial1/first.html):&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;mvn archetype:create&lt;br /&gt;-DarchetypeGroupId=org.apache.tapestry&lt;br /&gt;-DarchetypeArtifactId=quickstart&lt;br /&gt;-DgroupId=org.apache.tapestry&lt;br /&gt;-DartifactId=tutorial1&lt;br /&gt;-DpackageName=org.apache.tapestry.tutorial&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Compare that with Grails:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;grails create-app&lt;br /&gt;&lt;br /&gt;Welcome to Grails 1.0 - http://grails.org/&lt;br /&gt;Licensed under Apache Standard License 2.0&lt;br /&gt;Grails home is set to: /usr/local/java/grails&lt;br /&gt;Application name not specified. Please enter:&lt;br /&gt;FooApp&lt;br /&gt;---------------&lt;br /&gt;[propertyfile] Updating property file: /home/polrtex/temp/FooApp/application.properties&lt;br /&gt;Created Grails Application at /home/polrtex/temp/FooApp&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It is true that one doesn't create an application all that often, and copy-and-pasting&lt;br /&gt;these initial 5-6 lines would not be that big of a deal. However, for a newcomer, the Tapestry 5 experience has to be really smooth and starting a new app should be a breeze.&lt;br /&gt;&lt;br /&gt;So, you would say, what does this have to do with NetBeans ?&lt;br /&gt;&lt;br /&gt;Here it comes. As usual, NetBeans rocks everyone's socks, by lowering the entry barrier into starting an application. Here are the first steps (equivalent to the first two pages of the Tapestry tutorial : http://tapestry.apache.org/tapestry5/tutorial1/env.html). Here is what you need to do:&lt;br /&gt;( Assuming that you already have a good install of NetBeans 6.1).&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Install the NetBeans Maven plugin by going into Tools -&gt; Plugins . Type "maven" in the upper-left corner search box and install the plugin. The result should look something like this:&lt;pre&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SCvgiXOb0WI/AAAAAAAAAUk/rS9Y8nDnDQ0/s1600-h/t5_netbeans_maven_plugin.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SCvgiXOb0WI/AAAAAAAAAUk/rS9Y8nDnDQ0/s400/t5_netbeans_maven_plugin.png" alt="" id="BLOGGER_PHOTO_ID_5200497075684102498" border="0" /&gt;&lt;/a&gt;&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Create a new Maven project   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/SCvhjnOb0XI/AAAAAAAAAUs/aMcOjEkD-So/s1600-h/t5_netbeans_getting_new_project_pg1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/SCvhjnOb0XI/AAAAAAAAAUs/aMcOjEkD-So/s400/t5_netbeans_getting_new_project_pg1.png" alt="" id="BLOGGER_PHOTO_ID_5200498196670566770" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Expand the "Archetypes from remote Maven repositories" and scroll down to find the Tapestry5 quickstart archetype . You might want to pay close attention to the description and select the latest archetypes (in my case, for 5.0.11)&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/SCvidHOb0YI/AAAAAAAAAU0/6EQ4X3Vu0r8/s1600-h/t5_netbeans_getting_new_project_pg2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/SCvidHOb0YI/AAAAAAAAAU0/6EQ4X3Vu0r8/s400/t5_netbeans_getting_new_project_pg2.png" alt="" id="BLOGGER_PHOTO_ID_5200499184513044866" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Now that you have the nice wizard, fill out the configuration attributes to specify the group id, the location of the project, the name of the project, etc. &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/SCvi6nOb0ZI/AAAAAAAAAU8/DXMqCAuMw8w/s1600-h/t6_netbeans_getting_new_project_pg3.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/SCvi6nOb0ZI/AAAAAAAAAU8/DXMqCAuMw8w/s400/t6_netbeans_getting_new_project_pg3.png" alt="" id="BLOGGER_PHOTO_ID_5200499691319185810" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;When you hit Finish, Maven will start downloading all the dependencies and setting up your project.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Your new and shiny project is ready to go. Go into the project Properties and select your desired server to deploy to:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SCvj9XOb0aI/AAAAAAAAAVE/Ir1_l8GJXvY/s1600-h/t5_netbeans_select_server.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SCvj9XOb0aI/AAAAAAAAAVE/Ir1_l8GJXvY/s400/t5_netbeans_select_server.png" alt="" id="BLOGGER_PHOTO_ID_5200500838075453858" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Run the project from the project context menu and you're up and running !!!! &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SCvkxXOb0cI/AAAAAAAAAVU/xPBVno6BcqQ/s1600-h/t9_netbeans_new_project_run0.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SCvkxXOb0cI/AAAAAAAAAVU/xPBVno6BcqQ/s320/t9_netbeans_new_project_run0.png" alt="" id="BLOGGER_PHOTO_ID_5200501731428651458" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One very cool option that makes the Tapestry 5 setup almost identical to the Grails setup is the ability to run the application in Jetty by going to the command line and running:&lt;br /&gt;mvn jetty:run&lt;br /&gt;&lt;br /&gt;The upside of doing this is that after you run it, there is no deployment step. Tapestry supports reloading of the page templates as well as the page classes. As a result, whenever you make a change to a page, you can save it, refresh the browser and see the changes . Similarly, when you make a change to a class, compile it and the changes are immediately visible to the application. Such a setup really cuts down on waiting for the app to deploy. &lt;br /&gt;&lt;br /&gt;So now, looking back a little bit, this setup is indeed very competitive w/ the Grails setup. In Grails, you would download the Grails distribution, and then would run the "grails create-app" command to create the new project. Grails would then prompt you for some properties (e.g. project name) and you're done. For Tapestry, it's quite similar; however, instead of downloading the Tapestry distribution, you would simply download Maven2 (or in the case of NetBeans, you would install the NetBeans plugin). Even better for Tapestry, if you already have Maven install, then starting a new app becomes a zero cost operation : you just specify the command line args (or better yet, use NetBeans to create the new app) and you're on your way, all dependencies already in place. &lt;br /&gt;&lt;br /&gt;So, so far it's a tie between Grails and Tapestry. Grals vs Tapestry = 1:1&lt;br /&gt;&lt;br /&gt;Enjoy your shiny and new Tapestry 5 app in NetBeans !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-6127277507107329490?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/ZiaXJ3O3fqk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/6127277507107329490/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/05/tapestry5-netbeans-quickstart.html#comment-form" title="11 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6127277507107329490?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6127277507107329490?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/ZiaXJ3O3fqk/tapestry5-netbeans-quickstart.html" title="Tapestry5 NetBeans Quickstart" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_GbeUi4pR7kA/SCveQnOb0UI/AAAAAAAAAUU/8pm_V7zUJ7w/s72-c/nfjs_howard.jpg" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">11</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/05/tapestry5-netbeans-quickstart.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQGQH8_eip7ImA9WxZaF0U.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-2860095315227702766</id><published>2008-05-02T22:35:00.003-05:00</published><updated>2008-05-02T22:45:21.142-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-02T22:45:21.142-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="plugins" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><title>Quick File Chooser in NetBeans 6.1</title><content type="html">I'm on a roll today, but I thought I'd drop this tip as well.&lt;br /&gt;&lt;br /&gt;I'm a big fan of the NetBeans Quick File Chooser plugin, it makes it oh-so-easy to open up a file without having to detach my fingers from the keyboard. So, if you Google for the plugin, you'll find &lt;a href="http://blogs.sun.com/tor/entry/netbeans_plugins_i_use_part1"&gt;Tor's recommendation&lt;/a&gt;  of the same; however, you can't find it on the &lt;a href="http://plugins.netbeans.org/"&gt;Plugin Center&lt;/a&gt; . So, what if you really wanted to use the Quick File Chooser, in NetBeans 6.1, what should you do ? In the past, I've always copied the plugin with my netbeans preferences from the previous version that I've used, and it's worked OK. However, I decided on a clean NetBeans install on my home laptop, and I couldn't get my hands on it.&lt;br /&gt;&lt;br /&gt;So, I followed a tip from &lt;a href="http://blogs.sun.com/octav/entry/bleeding_edge_plugins"&gt;Octavian's blog&lt;/a&gt;    , added the Netbeans Latest Build update center, and ... voila, the Quick File Chooser is in the list of available plugins. Since it doesn't depend on any of the features of 6.1+ code, it works great in 6.1 as well.   &lt;a href="http://plugins.netbeans.org/"&gt;&lt;span style="display: block;" id="formatbar_Buttons"&gt;&lt;span class="on" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-2860095315227702766?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/MKJFGRIZpNE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/2860095315227702766/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/05/quick-file-chooser-in-netbeans-61.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2860095315227702766?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2860095315227702766?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/MKJFGRIZpNE/quick-file-chooser-in-netbeans-61.html" title="Quick File Chooser in NetBeans 6.1" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/05/quick-file-chooser-in-netbeans-61.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEERHY7cCp7ImA9WxZaF0U.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-8456863582435812162</id><published>2008-05-02T14:14:00.005-05:00</published><updated>2008-05-02T22:00:05.808-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-02T22:00:05.808-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="blogger" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Groovy HTML Encode</title><content type="html">I kinda thought that in the past I had used a special Groovy method to encode something as HTML. I mostly need that when I need to post something to Blogger (which completely baffles me - why isn't there a better way of copy-and-pasting html/xml in blogger content ???) . I do know that in Grails, there are &lt;a href="http://grails.codehaus.org/Dynamic+Encoding+Methods"&gt;a couple of special methods&lt;/a&gt; that you can use if you want to encode something as html, json, or something else. However, I'm not using Grails right now, so that's not always the best option.&lt;br /&gt;&lt;br /&gt;After wasting 15 minutes trying to remember exactly how I did it in the past, I realized that I was using &lt;a href="http://commons.apache.org/lang/apidocs/org/apache/commons/lang/StringEscapeUtils.html"&gt;StringEscapeUtils&lt;/a&gt; from Apache commons-lang. So, having remembered that, it just works like magic, here is what I use to convert my xml/html samples in order to post them on Blogger:&lt;br /&gt;&lt;br /&gt;this.class.classLoader.rootLoader.addURL(new File("/usr/local/java/grails-1.0/lib/commons-lang-2.1.jar").toURL())&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;xml = '''&lt;br /&gt;&amp;lt;module id=&amp;quot;id&amp;quot; version=&amp;quot;0.0.1&amp;quot; package=&amp;quot;package&amp;quot;&amp;gt; &amp;lt;/module&amp;gt;&lt;br /&gt;'''&lt;br /&gt;org.apache.commons.lang.StringEscapeUtils.escapeHtml(xml).split("\n").each() {println it }&lt;br /&gt;&lt;br /&gt;, which outputs the following :&lt;br /&gt;&amp;amp;lt;module id=&amp;amp;quot;id&amp;amp;quot; version=&amp;amp;quot;0.0.1&amp;amp;quot; package=&amp;amp;quot;package&amp;amp;quot;&amp;amp;gt; &amp;amp;lt;/module&amp;amp;gt;&lt;br /&gt;&lt;br /&gt;, which is what I paste into blogger and it works like magic !!!&lt;br /&gt;&lt;br /&gt;No more running around like a headless chicken trying to find some service online that will convert my html/xml snippets !&lt;br /&gt;&lt;br /&gt;&lt;formatter usefile="false" type="brief"&gt;&lt;br /&gt;&lt;/formatter&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-8456863582435812162?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/4IADTC3MMRM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/8456863582435812162/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/05/groovy-html-encode.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/8456863582435812162?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/8456863582435812162?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/4IADTC3MMRM/groovy-html-encode.html" title="Groovy HTML Encode" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/05/groovy-html-encode.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cASH85fip7ImA9WxRbGEQ.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-3166605318957869556</id><published>2008-05-02T12:26:00.009-05:00</published><updated>2008-12-10T03:50:49.126-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-10T03:50:49.126-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="junit" /><title>Freeform projects NetBeans JUnit test results : binding output to source code</title><content type="html">As I had mentioned in a &lt;a href="http://www.troymaxventures.com/2007/05/junit-results-in-free-form-projects.html"&gt;prior post&lt;/a&gt; a while back, it is pretty straightforward to bind the output of a Freeform Project JUnit task to the NetBeans JUnit test results. However, there are a couple of minor tweaks that I find myself making and forgetting, so, I thought I'd drop a blog entry, even just as a reminder for myself.&lt;br /&gt;&lt;br /&gt;First, make sure that the JUnit task as a showoutput="true" attribute and has a formatter that explicitly states that doesn't use a file, e.g.&lt;br /&gt;&lt;br /&gt;&amp;lt;&lt;span style="font-weight: bold;"&gt;formatter usefile="false" &lt;/span&gt;type="brief"/&amp;gt;&lt;br /&gt;&lt;br /&gt;Emphasis on not using a file : e.g. you can use an xml formatter and it would work; however, if you don't specify the usefile="false" attribute, everything goes to the file and NetBeans doesn't get a chance to capture the output and display the results in a nice JUnit test results tree. As a result, the best combination ends up being a combination of a xml formatter that outputs to a file, and a brief formatter that doesn't, e.g. :&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;junit fork="yes" printsummary="withOutAndErr" &lt;span style="font-weight: bold;"&gt;showoutput="true"&lt;/span&gt;                  errorProperty="test.failed"            failureProperty="test.failed" filtertrace="false"&amp;gt;&lt;br /&gt;         &amp;lt;formatter type="xml"&amp;gt;&lt;br /&gt;         &lt;span style="font-weight: bold;"&gt;&amp;lt;formatter usefile="false" type="brief" /&amp;gt;&lt;/span&gt;&lt;br /&gt;         &amp;lt;classpath refid="whatever-path-id"&amp;gt;&lt;br /&gt;&amp;lt;/classpath&amp;gt;&lt;br /&gt;&amp;lt;/junit&amp;gt;&lt;br /&gt;&lt;br /&gt;The second important part of working with the JUnit results in NetBeans is to make sure that when a test fails, when you click on the failure in the JUnit results, you want NetBeans to take you to the right line in the source code:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/SBtQ6nbLeUI/AAAAAAAAAT0/3Sz1KBQp7t8/s1600-h/netbeans_junit_beauty.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/SBtQ6nbLeUI/AAAAAAAAAT0/3Sz1KBQp7t8/s320/netbeans_junit_beauty.png" alt="" id="BLOGGER_PHOTO_ID_5195835563047614786" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In order to accomplish that, make sure that you properly set the output directory for your test cases in your NetBeans project with the UI or project.xml:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;In the Project Properties UI&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_GbeUi4pR7kA/SBtnfXbLeVI/AAAAAAAAAT8/y8woSAfcAiE/s1600-h/junit_output_project_props.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_GbeUi4pR7kA/SBtnfXbLeVI/AAAAAAAAAT8/y8woSAfcAiE/s320/junit_output_project_props.png" alt="" id="BLOGGER_PHOTO_ID_5195860383663618386" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;In the nbproject/project.xml&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;...&lt;br /&gt;&amp;lt;java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2"&amp;gt;\n            ....&lt;br /&gt;&amp;lt;compilation-unit&amp;gt;&lt;br /&gt; &amp;lt;package-root&amp;gt;test/integration&amp;lt;/package-root&amp;gt;&lt;br /&gt;          &amp;lt;unit-tests/&amp;gt;&lt;br /&gt; &amp;lt;classpath mode="compile"&amp;gt;${test.completion.classpath}&amp;lt;/classpath&amp;gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;     &amp;lt;built-to&amp;gt;dest/test/unit&amp;lt;/built-to&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;lt;source-level&amp;gt;1.5&amp;lt;/source-level&amp;gt;&lt;br /&gt;&amp;lt;/compilation-unit&amp;gt;&lt;br /&gt;....&lt;br /&gt;&amp;lt;/java-data&amp;gt;&lt;br /&gt;....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-3166605318957869556?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/MtuYc2_XdYo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/3166605318957869556/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/05/freeform-projects-netbeans-junit-test.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/3166605318957869556?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/3166605318957869556?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/MtuYc2_XdYo/freeform-projects-netbeans-junit-test.html" title="Freeform projects NetBeans JUnit test results : binding output to source code" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_GbeUi4pR7kA/SBtQ6nbLeUI/AAAAAAAAAT0/3Sz1KBQp7t8/s72-c/netbeans_junit_beauty.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/05/freeform-projects-netbeans-junit-test.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMERnk5eip7ImA9WxZaF0U.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-8609304366187317750</id><published>2008-04-26T13:08:00.017-05:00</published><updated>2008-05-02T22:46:47.722-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-02T22:46:47.722-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="symantec" /><category scheme="http://www.blogger.com/atom/ns#" term="antivirus" /><category scheme="http://www.blogger.com/atom/ns#" term="rants" /><title>Symantec Horror Story : "The Symantec Experience"</title><content type="html">After a 6 months hiatus in the antivirus subscription of one of the laptops at the house, I finally decided to bite the bullet and either get the upgrade or subscribe to the antivirus updates. I was quite reluctant to do it for quite a bit ( I just absolutely hate being blackmailed into buying a product), but after listening to &lt;a href="http://www.grc.com/securitynow.htm"&gt;Security Now&lt;/a&gt;, I finally decided that it's not worth risking a security breach of the windows machine (btw, I'm entirely embarrassed to admit that I do own a Windows machine) .  &lt;a href="http://tandoorisjourney.blogspot.com/"&gt;My Better Half&lt;/a&gt; is too attached to her ICQ client (despite the million better alternatives) and a few other pieces of software that she never uses, and so far I haven't been able to convince her to switch to Linux. On the positive side, my son has been a Linux user since he's 3 years old and he's happily playing a whole bunch of nice games like SuperTux, PPRacer, and many more others..).&lt;br /&gt;&lt;br /&gt;Anyway, I digress. So, I finally decided to bit the bullet and part with 50 of my hard earned dollars. So, I go to the Symantec website (I did have a trial version that came with my access point), and here my woes really started.&lt;br /&gt;&lt;br /&gt;First, while I'm ordering the software, they try to sell me "A Service" where they'd keep my download for a year. I figured, hey, I could download it and burn it to a CD, and I don't need to shell out $10.  So , I happily click on the link and download an executable, I get a setup.exe and I start it up. Lo and behold, it's not the software, it's a "Download Manager" !!! In a later part of the saga, I asked their tech support what the service is all about and I can store the little download manager and reinstall the software 6 months from now, and they gladly told me that I could just download the trial version and use my registration code and I'd be good. So, WHY did they recommend the "Download Service" for 10 bucks ??? Hm, first signs of fishiness start showing...&lt;br /&gt;&lt;br /&gt;Alright, so I downloaded the software, and started it up. As I mentioned before, the download manager started doing its job and in about half an hour the whole deal was downloaded. Now, while I was waiting for half an hour for the download to finish, why not make myself useful and see if I can clean up some of the old software from the machine. At one  time the Norton Internet antivirus decided that it was done downloading and it has to start installing &lt;b&gt;now&lt;/b&gt;! Well, as bad luck would have it, at the same time I was uninstalling an older JRE version. So, Norton decides to die and tell me that it can't install while something else is installing. I said fine, continued w/ my JRE uninstall, thinking that, stupid me, I'll just restart the Download Manager and it will resume the install.&lt;br /&gt;&lt;br /&gt;Not that easy !!! I start the setup.exe again and it just tells me that the download is finished and just closes. WHAT?!!??? Did I just pay fifty bucks for &lt;b&gt;this&lt;/b&gt;?? I didn't exactly order a download manager, I just wanted the damn software, but hey, they're smart and decided to give me a download manager instead. Alright, that works too, but at least make sure that the download manager knows how to start the installer, puh-puh-please !&lt;br /&gt;&lt;br /&gt;So, next action. What can I do ? Phone, internet suport forum, online chat ? I decide to go with the online chat. However, Symantec decides to be fresh again ! Instead of just firing up some AJAX little gizmo to just exchange a couple of words with their technician, what do I have to do ? Of course, I have to download and install an application, that would install and register an ActiveX in my system, so that when I go into their "live chat" feature, it can look as if it is running in the web browser. Not only that, but the little piece of crappy software only happens to work in Internet Explorer !!! Is this coming from a company that is claiming that will protect my security ? "Oh, just install this little piece of software, we're just going to chat, disregard all the security warnings about ActiveX and such". What a bunch of losers !!&lt;br /&gt;&lt;br /&gt;So, I once again stoop to their level and download the ActiveX and install the thing. By now, I'm quite pissed, I'm running IE, allowing ActiveX garbage on my machine. I finally get to the chat page, and you'd think with the ActiveX it would be something really fancy and slick. Nope. Just a text field for me to enter my comments, and a text area for the current conversation. The crown jewel of this work of art are three radio buttons to select what the technican can do "Nothing", "View Only" and "Full Control". You might think that a security company would be concerned and would give the users some choice to protect themselves . No such luck. The default is on "Full Control". And I thought that best practice in security would have been to give the user a choice and let them choose if someone else would poke around their machine, and worse off, I thought Symantec would have thought of that. Another level of disappointment reached !&lt;br /&gt;&lt;br /&gt;So, I start talking to the dude (Krishnan) who takes his sweet time to answer my questions. I type in 5 things, wait for 10 minutes and only then he decides that I'm worth his attention. First, I ask him a couple of things about how disappointing the experience is so far, and then I get to the meat of things : I ask him why I can't install the product. The solution turns out to be "easy" : I just go to the Symantec site and download and run a tool (yup, an .exe), and what do you think it does ?? Ta-da !! It cleans up whatever the Download Manager downloaded so that I can start the Download Manager again and let it download for another half hour. Isn't this brilliant ?? Anybody with a brain stem would have figured this out : hey, why not include the "Download Cleanup" functionality into the Download Manager ? I mean, it's not like they shipped the product to me 6 months ago and don't have a chance to patch in this functionality : I downloaded the Download Manager 10 minutes ago !&lt;br /&gt;&lt;br /&gt;Alright, next phase in the saga. I clean up my download, start the download again (yep, another 30 minutes down the drain) and I'm chattling w/ Krishnan about how I can leave some feedback to Symantec to help them improve their product. I could certainly just bitch about it (like I'm doing now) and and let them continue having a crappy product, but hey, I decided I'll give them a shout. So, while I'm still chatting w/ the dude, I went to their feedback page (of course still in IE7) and then... IE CRASHES and BURNS !!! Now, I'd guess it wasn't just a fault of IE, for some reason it's the ActiveX that I was using (of course, this is just speculation, I was so mad I didn't go digging through logs and such). Now I'm just flipping out : I'm using IE, ActiveX running, with a product that just goes out of its way trying to prevent me from using it, after being blackmailed for fifty bucks to run a shitty OS on my sweetheart's laptop, and it just died !!!&lt;br /&gt;&lt;br /&gt;At this point, I'm lost for words. On one side, I could go and talk to tech support again, and possibly lose another hour dealing with them, or I could just try doing it on my own. But I'm suffiiently disappointed and I really want to try and ask them if I can cancel my order. Note, I said "ask them if I can", not "tell them to cancel". So, I go back into their online chat support center (ActiveX and all), and I start talking to a new dude (hm, was it Prasad??). I explained the problem that I had and I ask him to tell me what the options are to cancel my order. I specifically told him "Don't cancel the order yet, just tell me what the options are". I give him address and order number to look up the info. Once again, Dude takes his time, no hurry for him, he's getting paid for his time. Just as I'm about to ask him what's going on, he cheerfully informs me that... I'm all set, my order is cancelled and that it might take a few days for the refund to process. WHAT ???!!?? I specifically told the dude, DON'T cancel the order. Just as I'm explaining to the dude that I didn't want to cancel the order, he disconnects and reconnects from the chat session a couple of times, not mentioning a thing about it (no sorry, I got disconnected, nothing).&lt;br /&gt;&lt;br /&gt;So, let me recap here. I'm working in Windows, that sucks. I part with my money to fix the crummy OS and prevent it from being 0wn3d every other day, and the antivirus company tries to take my dough for a useless download service (by default), so I'm even more bummed out. Then, I try to install something that should be a total no brainer, it doesn't care about installing the software, it cares about downloading it only. Hm... I'm fuming ! Then, the security company makes me jump through 100 insecure hoops including installing ActiveX-s who want full control by default of my desktop, running executables just downloaded from the web (albeit from their site, supposedly secure), and giving full remote control to a dude I don't know sitting somewhere in India. I'm starting to flip out now !!! How many times did I give somebody a chance to r00t my machine, I wonder ? Somewhere along the way, the antivirus company's software crashes my browser, and to top it off, the customer support people just blow me off, take their sweet time in addressing my issues, and in the end just cancel the order despite the fact that I told them not to !!!!&lt;br /&gt;&lt;br /&gt;So, I ask , WHY ? I can see that my fifty bucks are not going to break a billion dollar company (or however big it is, it is big). But is that a reason to totally dis me and let it be known that they don't care ? Is that a reason to introduce glaring security issues along the way (ActiveX, executables, giving full control to my box by default) just based on the fact that they are "the security experts" - e.g. what if someone compromised THEIR site, how many of their customers would be compromised along the way ? Is that a reason for the customer support to not pay attantion to what I'm saying and disrespect me by just answering once every 5 minutes ?&lt;br /&gt;&lt;br /&gt;Anyway, that's my story. I just blows me away that such a large industry is built on the side of a bug ridden OS, and to make it all more perverse, the culprit of the whole situation is also in the same industry (e.g. Microsoft OneCare product charges for services that prevent attackers from exploiting bugs in the OS that Microsoft itself built). Now, wouldn't it make sense that if one bought a Microsoft product, such protection would come as a part of the OS, instead of selling you a faulty OS, and then selling you a service to fix it. It's an interesting conflict of interest : would Microsoft make more money if they fix the OS and make it less exploitable (thus losing money on Antivirus support), or would they make more money selling a crummy defect-ridden OS and then selling Antivirus products for it ?&lt;br /&gt;&lt;br /&gt;This is the end of my story. My conclusion : I'm so glad I use Linux !! Rock on &lt;a href="http://www.fedoraproject.org/"&gt;Fedora&lt;/a&gt;, I'm looking forward to Fedora 9 !!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-8609304366187317750?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/NMgR4EbMt5I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/8609304366187317750/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/04/symantec-horror-story-symantec.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/8609304366187317750?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/8609304366187317750?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/NMgR4EbMt5I/symantec-horror-story-symantec.html" title="Symantec Horror Story : &quot;The Symantec Experience&quot;" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/04/symantec-horror-story-symantec.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QNQ3Y4fSp7ImA9WxZUF00.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-9112326945869070527</id><published>2008-04-07T21:24:00.009-05:00</published><updated>2008-04-08T20:43:12.835-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-08T20:43:12.835-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="iphone" /><category scheme="http://www.blogger.com/atom/ns#" term="rants" /><category scheme="http://www.blogger.com/atom/ns#" term="apple" /><title>Apple Brainwashing puzzle</title><content type="html">I write software for a living. As a result a lot of my favorite software developers at work and in my communities (e.g. Tapestry, Grails, NetBeans) are Mac users. On one hand, I accept the fact that, hey, they like their Mac, just as much as I am passionate and like my NetBeans for example. However, there are a couple of things that I haven't been able to grasp yet.&lt;br /&gt;&lt;br /&gt;All of the people I'm talking about are very smart and very independent. Yet, at the same time, Apple has managed to run some kind of brainwashing trick, where anything Apple comes up with and anything Apple says is taken at face value. Here are a couple of glaring examples:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A year or however long time ago, Apple decides to do their iPhone thing. Great, nice device, cool glitzy graphics, all that. All of a sudden, everyone from a large number of my coworkers to the people on the Oscars buys an iPhone. That is all well, but the more puzzling part is how most people just swallow the garbage coming from Apple without questioning it. For example, I bet that 90% of the iPhone users still think that iPhone was the first device that had a full blown browser that doesn't need the content to be specifically formatted for mobile devices ( while I've been happily browsing on my Nokia E61 for 1-2 years before the iPhone came out, mind you with the E61 happily running a KHTML derived browser, the same browser that Safari extends as well).&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Apple decides to release their SDK and to allow 3rd party Devs to distribute their apps for iTunes. That is all great, nice thinking, good way to screw the walled garden of the network operators (ironically, by creating a new walled garden, this time controlled by Apple). So,  all of a sudden, everyone believes ( I spoke to a very smart coworker of mine, listened to the Java Posse) that this is the first attempt where a non-operator sets up a distribution mechanism where 3rd party devs can certify and distribute their apps. Rewind to 2-3 years before the iPhone SDK launch, and I was happily exploring the Nokia Catalogs (on my phone) that has a whole bunch of free and commercial applications for download (that have nothing to do with the operator, the same "independent" software distribution channel that Apple claims to have invented).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The list can go on and on. What really puzzles me is that Apple can throw these outrageously false claims, and all of these smart and independently thinking people that I know just eat it up, without questioning it for a second.  What drove me over the edge was when I was listening to a Java Posse interview where they were discussing the release of the iPhone SDK and how Apple supposedly "owned" the device and that Apple was within their right to lock the device as much as they want and go to great lengths to restrict what kind of software could be on it (e.g. starting from the "locked" phones, going through the clauses in the iPhone dev kit that prohibits its usage for creation of VMs, including Java). That is the biggest steaming pile of BS that I've heard . Yeah, I know that when you get the software you don't actually "own" it, you license it, but I can't believe my ears : if I had spent $400-$500 on a device you better believe it that I will want to have as much control over it, I OWN the goddamn thing. Now, if it was someone other than Apple (e.g. think Microsoft), all of these smart people would be up in arms calling for boycotts of the device and the company and who knows what else. But when it's Apple, people just suck it up.&lt;br /&gt;&lt;br /&gt;So, people, let get our senses back and start thinking a little bit more critically about the garbage that comes out of Apple's brainwashing machine. I know they make nice products and all, but let's not lose our senses every time they say something and examine it for what it really is : a company pushing their products and very selfishly looking out for its own interests.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-9112326945869070527?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/_Wv-afkSLaE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/9112326945869070527/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/04/apple-brainwashing-puzzle.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/9112326945869070527?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/9112326945869070527?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/_Wv-afkSLaE/apple-brainwashing-puzzle.html" title="Apple Brainwashing puzzle" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/04/apple-brainwashing-puzzle.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04FSX84cCp7ImA9WxZXEkw.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-4102299623478871275</id><published>2008-02-28T10:25:00.003-05:00</published><updated>2008-02-28T12:31:58.138-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-02-28T12:31:58.138-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="j2me" /><category scheme="http://www.blogger.com/atom/ns#" term="my thesis" /><title>Thesis presentation</title><content type="html">Below is the content of the presentation that I gave on my thesis about a year ago. It clearly is missing a lot of the content to explain what each slide is all about, but it nicely gives the general idea of what the solution is like:&lt;br /&gt;&lt;br /&gt;&lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;&lt;object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' height='Height in Pixels' width='Width in Pixels'&gt;&lt;br /&gt; &lt;param value='lt' name='salign'/&gt;&lt;br /&gt; &lt;param value='high' name='quality'/&gt;&lt;br /&gt; &lt;param value='noscale' name='scale'/&gt;&lt;br /&gt; &lt;param value='transparent' name='wmode'/&gt;&lt;br /&gt; &lt;param value='http://ghs.troymaxventures.com/MVP_Presentation2.swf' name='movie'/&gt;&lt;br /&gt; &lt;embed wmode='transparent' src='http://ghs.troymaxventures.com/MVP_Presentation2.swf' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' salign='LT' scale='noscale' quality='high' height='600' width='800'&gt;&lt;br /&gt; &lt;br /&gt; &lt;/embed&gt;&lt;br /&gt;&lt;/object&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-4102299623478871275?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/ITKef5LUbkY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/4102299623478871275/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2008/02/test-swf.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4102299623478871275?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4102299623478871275?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/ITKef5LUbkY/test-swf.html" title="Thesis presentation" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2008/02/test-swf.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UDSX85eyp7ImA9WB9RFUg.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-915393248666298624</id><published>2007-10-16T02:09:00.000-05:00</published><updated>2007-10-16T12:21:18.123-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-16T12:21:18.123-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mobile video" /><category scheme="http://www.blogger.com/atom/ns#" term="j2me" /><category scheme="http://www.blogger.com/atom/ns#" term="my thesis" /><title>Starting to publish thesis</title><content type="html">After a long time for thinking and deciding what I'm doing with my thesis, I decided to go ahead and start publishing it little by little. Overall, I could post the whole thing in one swooop; however, I have to do some conversion into HTML; thus, I plan to publish it chapter by chapter. &lt;br /&gt;&lt;br /&gt;Here (as a test) is the content of the thesis abstract:&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://ghs.troymaxventures.com-a.googlepages.com/J2ME_Streaming_Inc_Abstract.html" width="90%" height="1200"   name="content"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-915393248666298624?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/I6qlUUdT_qY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/915393248666298624/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/10/starting-to-publish-thesis.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/915393248666298624?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/915393248666298624?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/I6qlUUdT_qY/starting-to-publish-thesis.html" title="Starting to publish thesis" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/10/starting-to-publish-thesis.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYGQ3w9fCp7ImA9WxZaF0U.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-6234320116629079806</id><published>2007-09-14T22:16:00.003-05:00</published><updated>2008-05-02T21:52:02.264-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-02T21:52:02.264-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="grapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><title>Grapestry view and controller resolvers</title><content type="html">This is a posting that I had started quite a while ago (right when I was starting w/ Grapestry), and I never posted it. Anyway, I thought that the content might be useful to someone trying to use hivemind with Tapestry 4. It would be very interesting when I will get a chance to try the same using the new and shiny Tapestry 5.&lt;br /&gt;&lt;br /&gt;--------------------&lt;br /&gt;&lt;br /&gt;The first couple of steps from the Grapestry wish list is to make the templates and pages be located in the same spot where the standard Grails gsp-s and controllers are (e.g. in grails-app/views and grails-app/controllers respectively).&lt;br /&gt;&lt;br /&gt;First to set up the stage to what I'll talk about. For starters, I knew that HiveMind is what makes Tapestry tick. Secondly, I knew that Tapestry is very flexible and customizable, and I expected to fairly easy be able to make it look in all the right places.&lt;br /&gt;&lt;br /&gt;So, first stop was the &lt;a href="http://tapestry.apache.org/tapestry4.1/usersguide/configuration.html"&gt;Tapestry User Guide&lt;/a&gt; configuration section. At the bottom of the page it says that there is a "configuration point" for org.apache.tapestry. specification-resolver-delegate and org.apache.tapestry. template-source-delegate - the explanations seem to point out that this is exactly what I need. So, I start thinking : how hard could it be to implement a couple of interfaces to just point to the directories I want and have it do it's magic. Well, it turns out, not as easy as it sounds.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt; So, for the template resolver, I only need to implement this one interface, that should be easy&lt;br /&gt;&lt;pre language="java"&gt;&lt;br /&gt;public ComponentTemplate findTemplate(IRequestCycle cycle, IComponent component, Locale locale) { }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;Alright, I got right on it. Now, I only need to figure out how to produce a ComponentTemplate. I start digging through the Tapestry core source code, So, the constructor for ComponentTemplate looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre language="java"&gt;&lt;br /&gt;  public ComponentTemplate(char[] templateData, TemplateToken[] tokens) {}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;OK, I can figure out how to produce a char array from a file, but these TemplateToken-s... At this point, I started realizing that this is not something that I should try to figure out from the top of my head, but rather go out and find an example that already implements the ITemplateSourceDelegate interface, surely somebody has done this before.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;  So, I start digging around for an example. This is where it started getting scary. The first couple of &lt;a href="http://www.mail-archive.com/users@tapestry.apache.org/msg07190.html"&gt;links that come up &lt;/a&gt; talk about how nobody has really posted a good example of how this is done. Overall, the problem is that there is a boatload of "helper" objects (e.g. DefaultParserDelegate, TemplateParser, ComponentSpecificationResolverImpl, etc. the list goes for quite a bit) that you need to create before you can actually create an instance of this ComponentTemplate. On one hand, it all makes sense: Tapestry is a very modular framework, and you could potentially replace each one of it's pieces with some other component that implements the contract. On the downside, if you don't know much about the guts of Tapestry (e.g. for someone like me), digging into the guts is not that much fun.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt; So, I say, I'll give the code that was posted on the mailing list, that should certainly work, especially since the responders say that they do work. Great, I copy-paste-compile.. and when I run my test Tapestry app (with a similar structure to a grails app - e.g. with WEB-INF/grails-app/views, etc)... a NullPointerException.. Luckily, Tapestry is open source, I dig into the source and I realize that I get the NPE when it's trying to log something.. So, do I need to inject a log into every object that I create ???&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;  This is when I realized that I just need to use the facilities that Tapestry uses to inject it's dependencies - namely, Hivemind. The thing is, I know nothing about it.. After reading up about it, it turns out that it uses these configuration points that you can use as well. So, my task moved from "copy and paste an example from the mailing list" to "figure out how this HiveMind thing works and then make it work for my ITemplateSourceDelegate implementation. I have read 2 books on Tapestry, but neither of them says anything about HiveMind (I admit, one was older, on Tapestry 3.0, the other one more focused on Tapestry itself, not its infrastructure). So, here is what I ended up using for my hivemind config file:&lt;br /&gt;&lt;pre language="xml"&gt;&amp;lt;module id=&amp;quot;id&amp;quot; version=&amp;quot;0.0.1&amp;quot; package=&amp;quot;package&amp;quot;&amp;gt;&lt;br /&gt;   &amp;lt;implementation service-id=&amp;quot;tapestry.page.SpecificationResolverDelegate&amp;quot;&amp;gt;&lt;br /&gt;       &amp;lt;invoke-factory&amp;gt;&lt;br /&gt;           &amp;lt;construct class=&amp;quot;com.troymaxventures.grapestry.framework.ViewsSpecificationResolverDelegate&amp;quot;&amp;gt;&lt;br /&gt;               &amp;lt;set property=&amp;quot;pagePath&amp;quot; value=&amp;quot;grails-app/controllers&amp;quot;/&amp;gt;&lt;br /&gt;               &amp;lt;set property=&amp;quot;componentPath&amp;quot; value=&amp;quot;grails-app/views&amp;quot;/&amp;gt;&lt;br /&gt;           &amp;lt;/construct&amp;gt;&lt;br /&gt;       &amp;lt;/invoke-factory&amp;gt;&lt;br /&gt;   &amp;lt;/implementation&amp;gt;&lt;br /&gt;  &lt;br /&gt;   &amp;lt;implementation service-id=&amp;quot;tapestry.parse.TemplateSourceDelegate&amp;quot;&amp;gt;&lt;br /&gt;       &amp;lt;invoke-factory&amp;gt;&lt;br /&gt;           &amp;lt;construct class=&amp;quot;com.troymaxventures.grapestry.framework.ViewsTemplateSourceDelegate&amp;quot;&amp;gt;&lt;br /&gt;               &amp;lt;set property=&amp;quot;grailsAppPath&amp;quot; value=&amp;quot;WEB-INF&amp;quot;/&amp;gt;&lt;br /&gt;               &amp;lt;set-service property=&amp;quot;parser&amp;quot; service-id=&amp;quot;tapestry.parse.TemplateParser&amp;quot; /&amp;gt;&lt;br /&gt;               &amp;lt;set-object property=&amp;quot;contextRoot&amp;quot; value=&amp;quot;infrastructure:contextRoot&amp;quot; /&amp;gt;&lt;br /&gt;               &amp;lt;set-service property=&amp;quot;componentSpecificationResolver&amp;quot; service-id=&amp;quot;tapestry.page.ComponentSpecificationResolver&amp;quot; /&amp;gt;&lt;br /&gt;               &amp;lt;set-object property=&amp;quot;componentPropertySource&amp;quot; value=&amp;quot;infrastructure:componentPropertySource&amp;quot; /&amp;gt;&lt;br /&gt;               &amp;lt;set-object property=&amp;quot;rootOverride&amp;quot; value=&amp;quot;app-property:grapestry-webapp-root-override&amp;quot; /&amp;gt;&lt;br /&gt;           &amp;lt;/construct&amp;gt;&lt;br /&gt;       &amp;lt;/invoke-factory&amp;gt;&lt;br /&gt;   &amp;lt;/implementation&amp;gt;&lt;br /&gt;&amp;lt;/module&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;     This hivemind configuration almost works for what I needed it to do in Grapestry. Unfortunately, it didn't get too far as the Grails test / development configurations work slightly differently than in production.&lt;br /&gt;&lt;br /&gt;     The general conclusion on the technology / Hivemind : it definitely seems like a cool dependency injection solution, especially in the way that it can dynamically aggregate modules and create a configuration on the fly (e.g. compared to Spring, where you have to explicitly say what goes into the config and how the different configs will interact). However, as with anything else, the high level of decomposition, where each class does only one job, and the many dependencies between the classes, make it sometimes difficult to figure out : e.g. if for a simple change like this, you have to track down 10 dependencies, that might have dependencies on their own, it sometimes makes you wish that the software you're trying to use wasn't as clean.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-6234320116629079806?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/LTFFDWlK8Hc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/6234320116629079806/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/09/grapestry-view-and-controller-resolvers.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6234320116629079806?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6234320116629079806?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/LTFFDWlK8Hc/grapestry-view-and-controller-resolvers.html" title="Grapestry view and controller resolvers" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/09/grapestry-view-and-controller-resolvers.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQBR305eCp7ImA9WB5aEk4.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-2551557075595594762</id><published>2007-09-08T00:24:00.001-05:00</published><updated>2007-09-08T00:45:56.320-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-08T00:45:56.320-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="grapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><title>Grapestry progress and wishlist</title><content type="html">I've been making some progress in making the Grapestry Grails plugin more integrated into Grails. Overall, it hasn't been quite a walk in the park, mostly due to the way Tapestry works. Here are a couple of things that would really be nice-to-have before Grapestry can really be usable as a Grails plugin:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt; Tapestry templates (pages and components) should show up directly under the grails-app/views directory. Overall, the idea is that that's where Grails GSPs typically show up, and it would be most natural for Grapestry to do the same &lt;/li&gt;&lt;br /&gt;&lt;li&gt; Tapestry page and component classes should live directly under grails-app/controllers. Overall, in Grails, the controllers are what process the requests. Since the page and component classes have the corresponding duty in Tapestry, so it would make sense to keep them there&lt;/li&gt;&lt;br /&gt;&lt;li&gt; Since Grails emphasizes convention over configuration, creating pages should default to &lt;b&gt;no&lt;/b&gt; page specification files. Everything that a page spec does should be accomplished using annotations (totally acceptable in regular Tapestry) &lt;/li&gt;&lt;br /&gt;&lt;li&gt; Add groovy scripts and templates that would set up a default page template and page classes, e.g. something like 'grails create-grapestry-page' and 'grails create-grapestry-component' &lt;/li&gt;&lt;br /&gt;&lt;li&gt; Add scaffolding similar to the one that exists in Grails controllers. It seems totally possible that there could be default methods like 'list', 'edit', etc on a grapestry page that would do the equivalent job of the Grails controllers with dynamic or static scaffolding&lt;/li&gt;&lt;br /&gt;&lt;li&gt; Have some NetBeans support (hopefully coming in NetBeans 6.0) for Grails and Tapestry to make editing the Tapestry components in Groovy at least on par with doing them in Java&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;I did make some progress in accomplishing the first couple of bullets above. I kinda thought I had that down; however, it turns out that the "Development" grails configuration doesn't quite obey the same rules (it uses some resouce loaders that load resources directly from the ${app_dir}/grails-app/view and controllers directory), so I'm working on some workarounds for that. &lt;br /&gt;&lt;br /&gt;Just yesterday, I got the Grails plugin account, but I still need to take a look at a standard grails plugin structure before I put anything out there.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-2551557075595594762?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/Z7ADHxXKFhc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/2551557075595594762/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/09/grapestry-progress-and-wishlist.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2551557075595594762?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2551557075595594762?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/Z7ADHxXKFhc/grapestry-progress-and-wishlist.html" title="Grapestry progress and wishlist" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/09/grapestry-progress-and-wishlist.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cASH0-fip7ImA9WxRbGEQ.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-7953459628946034422</id><published>2007-08-26T23:18:00.000-05:00</published><updated>2008-12-10T03:50:49.356-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-10T03:50:49.356-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="grapestry" /><category scheme="http://www.blogger.com/atom/ns#" term="grails" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Grails +  Tapestry = Grapestry ? Part 1 (of n)</title><content type="html">I've been quite intrigued by the approach Grails takes to developing web apps. It really is very nice that Grails offers and end-to-end solution that provides the framework for the front end, services, and back end. &lt;br /&gt;&lt;br /&gt;At the same time, I've been a big Tapestry fan, as it seems that it is the best web framework that I know about. I did read up about how Grails handles the front end, and although it provides decent support for developing the front end (with some cool integration into the whole Grails framework), but still not as nice as what Tapestry has. After all, the Grails front end is just a part of the puzzle; whereas, with Tapestry, that is it's primary goal (not to mention the whole difference between developing a "page-oriented" application with Grails compared with developing an application with a component based framework like Tapestry). &lt;br /&gt;&lt;br /&gt;The bottom line is that Tapestry is perfect for quickly developing the front end of the app, and Grails is excellent in quickly developing everything else. The primary draw of Grails is it's use of GORM; yet, the whole integration with Spring, is also very nice. So, bottom line is, &lt;b&gt;I need to have a Tapestry front end and a Grails back end&lt;/b&gt;. &lt;br /&gt;&lt;br /&gt;I kinda had this idea in my head for a while, but the lucky event was that I stumbled on a &lt;a href="http://graemerocher.blogspot.com/2007/05/grails-wicket-wonders-of-grails-plug-in.html"&gt; blog post by Grame Rocher&lt;/a&gt; about integrating Wicket into Grails. It seemed straightforward enough, I asked him if he thought if Tapestry would be much different, he said "no", so, I thought, "Great, I'm going to rock on and build a cool Tapestry plugin for Grails". &lt;br /&gt;&lt;br /&gt;As usual, it's easier said than done. It's probably been a couple of weeks since I've been able to get even close to having Grails and Tapestry work together. So, here are the steps, that I took along the way. When I come close to rounding this up, I'll probably release it somewhere (dev.java.net, sourceforge, google code, I'll have to see, I'm open to suggestions). Btw, my preliminary name for the plugin is &lt;b&gt;Grapestry&lt;/b&gt;, it's temporary, but I have this idea about a logo that has a big juicy grape on top of a cake or something like that (get it, "Grape Pastry"? :-) ) . Btw, just to mention that the work so far really did take about half an hour to do (just like Graeme said). The "other stuff" is what took me much longer that I thought it would: maybe another couple of hours to understand where each grails-app subdirectory ends up when the app is packaged, a couple of hours on researching existing Grails plugin and figuring out how the whole Grails magic works , and then a LARGE number of hours actually doing the integration between Tapestry and Grails (the stuff that I'm going to blog about in the next posting)... &lt;br /&gt;&lt;br /&gt;So, first things first. I followed Graeme's instructions on how to set up a plugin and how to do the basic plugin setup. &lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Do the &lt;code&gt; grails create-plugin &lt;/code&gt; to set up the basic directory structure, etc. &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Add the jars from the tapestry distribution into the plugin lib directory. Interesting problem that I had to deal with there was that Grails (the actual distribution, inside of $GRAILS_HOME/lib) had some common jars with Tapestry. Unfortunately, Tapestry 4.1.2 required later versions of those jars, so I had to copy those particular jars from the tapestry distribution into $GRAILS_HOME/lib, and remove (or temporarily rename the jars inside of the Grails lib directory). From the feedback that I got on the Grails forum, it seems like Grails doesn't have a way to dealing with dependency conflicts between what the plugin requires and what Grails requires. I am slightly negatively surprised by this, as Grails comes with a whole bundle of dependencies (it's 20+ Megs), and the chance that Grails might conflict with another jar version seems quite high. Oh, well, moving on for now, this is just one more item on my Grapestry ToDo list &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;I edited the canned Groovy file that configures the plugin, and gives it a chance to do it's modifications inside of web.xml, the spring config, and whatever else (there are a bunch of ToDos here as well, I'll write more about this later). A couple of things to point out in the source: &lt;br /&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt; The ejection of the controllers plugin : I'm not sure if this is necessary, it implies that if someone is using this plugin, they are totally not interested in using the Grails standard action handling. It seems that most Grails plugins are complementary to Grails, so, is this the right way to go ? I don't know, I'm not convinced.... Also, it seems that if this is a correct assumption, the whole Grails web layer (e.g. controllers, taglibs, AJAX) can be ripped out since it will not be necessary any more, all handled by Tapestry&lt;/li&gt;&lt;br /&gt; &lt;li&gt; The setup inside of web.xml is pretty standard, it's just a translation of a standard Tapestry web.xml into the Groovy xml builder format&lt;/li&gt;&lt;br /&gt; &lt;li&gt; The other interesting method that will most likely get some action is the doWithApplicationContext and doWithDynamicMethods. I looked at the controllers plugin, and that's where a lot of the Grails magic happens (e.g. dynamic scaffolding, a lot of default methods, etc), all things that are a must for my Grapestry plugin. &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;class Grapestry2GrailsPlugin {&lt;br /&gt; def version = 0.1&lt;br /&gt; def dependsOn = [:]&lt;br /&gt; // This removes the Grails standard controllers plugin, which means that standard Grails actions and such would not work anymore.&lt;br /&gt; def evicts=['controllers']&lt;br /&gt;&lt;br /&gt; def doWithSpring = {&lt;br /&gt;  // TODO Implement runtime spring config (optional)&lt;br /&gt; }   &lt;br /&gt; def doWithApplicationContext = { applicationContext -&gt;&lt;br /&gt;  // TODO Implement post initialization spring config (optional)  &lt;br /&gt; }&lt;br /&gt; def doWithWebDescriptor = { xml -&gt;&lt;br /&gt;           def servlets = xml.servlet[0]&lt;br /&gt;&lt;br /&gt;           servlets + {&lt;br /&gt;               servlet {&lt;br /&gt;                   'servlet-name'('tapestryapplication')&lt;br /&gt;                   'servlet-class'('org.apache.tapestry.ApplicationServlet')&lt;br /&gt;    &lt;br /&gt;                   'init-param' {&lt;br /&gt;                       'param-name'('org.apache.tapestry.disable-caching')&lt;br /&gt;                       'param-value'('true')&lt;br /&gt;                   }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                   'init-param' {&lt;br /&gt;                        'param-name'('org.apache.tapestry.application-specification')&lt;br /&gt;                        'param-value'('tapestryapplication.application')&lt;br /&gt;&lt;br /&gt;                   }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                   'load-on-startup'(1)&lt;br /&gt;               }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;           def mappings = xml.'servlet-mapping'[0]&lt;br /&gt;               mappings + {&lt;br /&gt;                 'servlet-mapping' {&lt;br /&gt;                       'servlet-name'('tapestryapplication')&lt;br /&gt;                       'url-pattern'('/app')&lt;br /&gt;                  }&lt;br /&gt;                   'servlet-mapping' {&lt;br /&gt;                       'servlet-name'('tapestryapplication')&lt;br /&gt;                       'url-pattern'('*.html')&lt;br /&gt;                  }&lt;br /&gt;                  'servlet-mapping' {&lt;br /&gt;                       'servlet-name'('tapestryapplication')&lt;br /&gt;                       'url-pattern'('*.direct')&lt;br /&gt;                  }&lt;br /&gt;                   'servlet-mapping' {&lt;br /&gt;                       'servlet-name'('tapestryapplication')&lt;br /&gt;                       'url-pattern'('*.sdirect')&lt;br /&gt;                  }&lt;br /&gt;                   'servlet-mapping' {&lt;br /&gt;                       'servlet-name'('tapestryapplication')&lt;br /&gt;                       'url-pattern'('*.svc')&lt;br /&gt;                  }&lt;br /&gt;                   'servlet-mapping' {&lt;br /&gt;                       'servlet-name'('tapestryapplication')&lt;br /&gt;                       'url-pattern'('/assets/*')&lt;br /&gt;                  }&lt;br /&gt;               }&lt;br /&gt;&lt;br /&gt;           def filter = xml.filter[0]&lt;br /&gt;&lt;br /&gt;    filter + {&lt;br /&gt;        'filter-name'('redirect')&lt;br /&gt;        'filter-class'('org.apache.tapestry.RedirectFilter')  &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    def filterMapping = xml.'filter-mapping'[0]&lt;br /&gt;    filterMapping + {&lt;br /&gt;        'filter-name'('redirect')&lt;br /&gt;        'url-pattern'('/')&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; def doWithDynamicMethods = { ctx -&gt;&lt;br /&gt;  // TODO Implement additions to web.xml (optional)&lt;br /&gt; } &lt;br /&gt; def onChange = { event -&gt;&lt;br /&gt;  // TODO Implement code that is executed when this class plugin class is changed  &lt;br /&gt;  // the event contains: event.application and event.applicationContext objects&lt;br /&gt; }                                                                                  &lt;br /&gt; def onApplicationChange = { event -&gt;&lt;br /&gt;  // TODO Implement code that is executed when any class in a GrailsApplication changes&lt;br /&gt;  // the event contain: event.source, event.application and event.applicationContext objects&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;li&gt; The next step is to actually, build some Tapestry artifacts to get the puppy going: a Tapestry page in Groovy, a page specification, and an html template&lt;br /&gt;   &lt;ul&gt;&lt;br /&gt;     &lt;li&gt; First, the Tapestry page implementation. Not much to talk about, just one persistent property to make sure that the annotations work, one simple action that makes sure that event dispatching works OK, and that one last action to make sure that GORM style object retrieval, etc works. Here is the pudding:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;package com.troymaxventures.grapestry.pages;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; *&lt;br /&gt; * @author akochnev&lt;br /&gt; */&lt;br /&gt;import org.apache.tapestry.annotations.Persist;&lt;br /&gt;import org.apache.tapestry.html.BasePage;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public abstract class Home extends BasePage {&lt;br /&gt;    @Persist&lt;br /&gt;    public abstract int getCounter();&lt;br /&gt;    public abstract void setCounter(int counter);&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    public void doClick(int increment) {&lt;br /&gt;        int counter = getCounter();&lt;br /&gt;        &lt;br /&gt;        counter += increment;&lt;br /&gt;        &lt;br /&gt;        setCounter(counter);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    public void doClear()     {&lt;br /&gt;        setCounter(0);&lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;    public void saveSomething() {&lt;br /&gt;/*&lt;br /&gt;        def b = new Foo(name:"Foo",url:"http://foo.bar.baz")&lt;br /&gt;        b.save()&lt;br /&gt;&lt;br /&gt;        println "Saved Bookmark2: " + Foo.get(1)&lt;br /&gt;  */&lt;br /&gt;        println "Called saveSomething"&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;    &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;    &lt;li&gt; The Tapestry page template , just some trivial markup with something to call into Tapestry:&lt;br /&gt;&lt;br /&gt;    &lt;pre language='xml'&gt;&lt;br /&gt;&amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.01 Transitional//EN&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;    &amp;lt;head&amp;gt;&lt;br /&gt;        &amp;lt;title&amp;gt;My First Tapestry Page&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;/head&amp;gt;&lt;br /&gt;    &amp;lt;body&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;h1&amp;gt;My First Tapestry Page 3&amp;lt;/h1&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        Date: &amp;lt;div jwcid=&amp;quot;@Insert&amp;quot; value=&amp;quot;ognl:new java.util.Date()&amp;quot;&amp;gt;June 26 2005&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            The current value is: &lt;br /&gt;            &amp;lt;span style=&amp;quot;font-size:xx-large&amp;quot;&amp;gt;&amp;lt;span jwcid=&amp;quot;@Insert&amp;quot; value=&amp;quot;ognl:counter&amp;quot;&amp;gt;37&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt; &lt;br /&gt;        &lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            &amp;lt;a href=&amp;quot;#&amp;quot; jwcid=&amp;quot;clear@DirectLink&amp;quot; listener=&amp;quot;listener:doClear&amp;quot;&amp;gt;clear counter&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            &amp;lt;a href=&amp;quot;#&amp;quot; jwcid=&amp;quot;@PageLink&amp;quot; page=&amp;quot;Home&amp;quot;&amp;gt;refresh&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            &amp;lt;a href=&amp;quot;#&amp;quot; jwcid=&amp;quot;by1@DirectLink&amp;quot; listener=&amp;quot;listener:doClick&amp;quot; parameters=&amp;quot;ognl:1&amp;quot;&amp;gt;increment counter by 1&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            &amp;lt;a href=&amp;quot;#&amp;quot; jwcid=&amp;quot;by5@DirectLink&amp;quot; listener=&amp;quot;listener:doClick&amp;quot; parameters=&amp;quot;ognl:5&amp;quot;&amp;gt;increment counter by 5&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            &amp;lt;a href=&amp;quot;#&amp;quot; jwcid=&amp;quot;by10@DirectLink&amp;quot; listener=&amp;quot;listener:doClick&amp;quot; parameters=&amp;quot;ognl:10&amp;quot;&amp;gt;increment counter by 10&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            &amp;lt;a href=&amp;quot;#&amp;quot; jwcid=&amp;quot;saveSomething@DirectLink&amp;quot; listener=&amp;quot;listener:saveSomething&amp;quot; &amp;gt;Save Something&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt;&lt;br /&gt;    &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;    &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/li&gt; &lt;br /&gt;  &lt;br /&gt;    &lt;li&gt; Finally, the page spec: &lt;br /&gt;&lt;br /&gt;    &lt;pre language='xml'&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE page-specification PUBLIC &amp;quot;-//Apache Software Foundation//Tapestry Specification 4.0//EN&amp;quot; &lt;br /&gt;    &amp;quot;http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;page-specification class=&amp;quot;com.troymaxventures.grapestry.pages.Home&amp;quot; &amp;gt;&lt;br /&gt;    &amp;lt;!--property name=&amp;quot;counter&amp;quot; persist=&amp;quot;true&amp;quot; /--&amp;gt;&lt;br /&gt;&amp;lt;/page-specification&amp;gt;&lt;br /&gt;&lt;br /&gt;    &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/li&gt;&lt;br /&gt;   &lt;/ul&gt;&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;li&gt;&lt;br /&gt;   Add a tapestryapplication.application application specification file to the web-app/WEB-INF folder, here's what it looks like for me:&lt;br /&gt;  &lt;pre language="xml"&gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE application PUBLIC &amp;quot;-//Apache Software Foundation//Tapestry Specification 4.0//EN&amp;quot; &lt;br /&gt;    &amp;quot;http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;application name=&amp;quot;tapestryapplication&amp;quot;&amp;gt;    &lt;br /&gt;    &amp;lt;meta key=&amp;quot;org.apache.tapestry.page-class-packages&amp;quot; value=&amp;quot;com.troymaxventures.grapestry.pages&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;lt;/application&amp;gt;&lt;br /&gt;  &lt;/pre&gt;&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;li&gt;&lt;br /&gt;&lt;br /&gt;OK, so far so good, this is all the right stuff we need to get it up and running. I was initially not looking forward to the magic that I'd have to do in order to get Tapestry work with the Groovy classloaders (as the &lt;a href='http://groovestry.sourceforge.net/'&gt;Groovestry project (that might be dead)&lt;/a&gt;  seems to do). Fortunately, Grails takes care of all that by compiling the Groovy classes into Good-Old-Java .class files, and so Tapestry doesn't have to know that the page is done in Groovy. Beautiful, isn't it ? &lt;br /&gt;&lt;br /&gt;I'm just going to wave my hands at this a little bit and just say that temporarily, we'll place the Home.java class in the com.troymaxventures.grapestry.pages package (and also mentioned in a tapestryapplication.application application config file). We'll also drop the Home.page specification, and the Home.html template into the $GRAPESTRY_HOME/web-app/WEB-INF directory. I know, that doesn't sound particularly fitting to the Grails philosophy of putting pages in the grails-app/views and controllers in grails-app/controllers , but there will be more on that in another blog post. &lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;li&gt;&lt;br /&gt;  Finally, do 'grails run-app' on the command line to get the app running, and go to http://localhost:8080/grapestry/app . That should pop a window that looks like this:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/RtJsGExCAkI/AAAAAAAAAMc/wK4H1nFFvdw/s1600-h/grapestry_first_page.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/RtJsGExCAkI/AAAAAAAAAMc/wK4H1nFFvdw/s320/grapestry_first_page.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5103260179378602562" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;  Beauty divine !!! The standard Tapestry app should work, you should be able to click on some links, and see the persistent counter being updated. &lt;br /&gt; &lt;li&gt;&lt;br /&gt; &lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-7953459628946034422?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/A3oKYORwpj4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/7953459628946034422/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/08/grails-tapestry-grapestry-part-1-of-n.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/7953459628946034422?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/7953459628946034422?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/A3oKYORwpj4/grails-tapestry-grapestry-part-1-of-n.html" title="Grails +  Tapestry = Grapestry ? Part 1 (of n)" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_GbeUi4pR7kA/RtJsGExCAkI/AAAAAAAAAMc/wK4H1nFFvdw/s72-c/grapestry_first_page.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/08/grails-tapestry-grapestry-part-1-of-n.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4BQnkycSp7ImA9WB5VFE0.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-7513279784630948564</id><published>2007-08-04T00:28:00.000-05:00</published><updated>2007-08-06T09:02:33.799-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-08-06T09:02:33.799-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jemmy" /><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>Groovy + Jemmy GUI automation</title><content type="html">This is something that I came up at work, I thought other people outside of work could make use of it as well. If you're wondering about the obscure references to BizApp and such, this is because I removed the name of the actual app from the text.&lt;br /&gt;&lt;br /&gt;OK, so we established that  &lt;a title="Groovy" href="http://groovy.codehaus.org/"&gt;Groovy&lt;/a&gt; rocks. Now, I've worked at the company long enough to know that there exists a GUI application that kinda does what I need. I know it works, since I can build the GUI app, run it, push the buttons on it, and it creates all the outputs that I need. Now, the only problem is that I'd like to generate a decent amount of these outputs so that I can have a realistic testing scenario.&lt;br /&gt;&lt;br /&gt;Now, I'm certain that there is a "cleaner" and "more proper" way of creating these test outputs. However, my colleague who wrote the BizApp app already figured out how to accomplish what the application needs to do (including all the nitty gritty technical details). Would it be nice if I had access to a simple action that does that ? Certainly. Do I have it now ? Nope. When do I need the outputs to test my client app ? YESTERDAY !! So, what should I do ???&lt;br /&gt;&lt;br /&gt;Enter the combination of &lt;a title="Groovy" href="http://groovy.codehaus.org%20/"&gt;Groovy&lt;/a&gt; and &lt;a title="Jemmy" href="http://jemmy.netbeans.org/"&gt;Jemmy&lt;/a&gt;. We know what Groovy is, now what is Jemmy??? From their site, it's a library that allows GUI driven testing. In effect, it allows me to programmatically specify the actions that I need on the GUI, and execute them. Great !! Step 1 compete !&lt;br /&gt;&lt;br /&gt;Now, step 2. Jemmy is a Java library, I don't quite know exactly how to use the API, and I don't quite know the exact sequence of actions that I'll need to perform through Jemmy. So, if I had to write a Java app to exercise BizApp through Jemmy, there'll be a lot of trial and error hindered by compilation. So, what should I do ?? Groovy is an excellent way to explore a particular API, but how can I plug in Groovy and Jemmy together in order to get this job done ?&lt;br /&gt;&lt;br /&gt;Alright, alright, enough of the round-about way of explaining things, here is what to do:&lt;br /&gt;&lt;br /&gt;* Setup a NetBeans Groovy scripting project. For that, you need a recent &lt;a title="NetBeans" href="http://www.netbeans.org/"&gt;NetBeans&lt;/a&gt; setup, with the  &lt;a title="Coyote" href="http://coyote.dev.java.net/"&gt;Coyote&lt;/a&gt; plugin installed. The same can certainly be achieved with an Groovy Eclipse plugin as well, but since I don't dig Eclipse, I'll show it in NetBeans. After Coyote is installed, you just set up a new project&lt;br /&gt;&lt;br /&gt;&lt;img src="" alt="" /&gt;&lt;br /&gt;&lt;div style="padding: 1em 0pt; text-align: left;"&gt;&lt;img src="http://docs.google.com/File?id=dfsmd7s6_28cxvg5bhq" /&gt;&lt;/div&gt; * Add the BizApp dependencies in the project. In my case, they're in d:JDevelopBuildsBizApp Add all jars from that directory into the project build. Notice the Jemmy libary at the bottom of the screenshot : it can be added either using the NetBeans update center, or by just downloading the Jemmy library and adding the jar as a dependency in the project. &lt;br /&gt;&lt;br /&gt;&lt;div style="padding: 1em 0pt; text-align: left;"&gt;&lt;div style="padding: 1em 0pt; text-align: left;"&gt;&lt;img src="http://docs.google.com/File?id=dfsmd7s6_31hfkk9xhj" /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;* Add the Groovy/Jemmy bootstrap script and add the content below, inserting the correct main class for the application. This script will launch BizApp, and will then fire up a blank Groovy console where we can execute our little script in. Right click on the Coyote project, and select "Run Project".&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import org.netbeans.jemmy.*;&lt;br /&gt;import org.netbeans.jemmy.explorer.*;&lt;br /&gt;import org.netbeans.jemmy.operators.*;&lt;br /&gt;&lt;br /&gt;// Fire up the BizApp Application&lt;br /&gt;new ClassReference("com.mycompany.MyAppMainClass").startApplication();&lt;br /&gt;&lt;br /&gt;// Get a reference to the BizApp JFrame and put it into the console's script binding.&lt;br /&gt;mainFrame = new JFrameOperator("BizApp"); &lt;br /&gt;def bind = new Binding()&lt;br /&gt;bind.setProperty("testScript",this)&lt;br /&gt;bind.setProperty("mainFrame",mainFrame)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Fire up the Groovy console.&lt;br /&gt;def console = new groovy.ui.Console(this.class.classLoader,bind)&lt;br /&gt;console.run() &lt;br /&gt;Thread.sleep(600000)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;* Now, we have both BizApp and the Groovy Console running side by side. Inside of the Groovy console, we can use Jemmy to programmatically manipulate the GUI (e.g. press buttons, select from checkboxes, etc). The Jemmy statements would look something like the script below. You can sometimes get away without firing a new thread, but if you don't the Groovy console script might block the UI and prevent Jemmy from executing it's input on BizApp&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;t = new Thread() {&lt;br /&gt;       // do whatever you need to do with Jemmy, push buttons, select combos, type into text fields, etc.&lt;br /&gt;}&lt;br /&gt;t.start()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding: 1em 0pt; text-align: left;"&gt;&lt;div style="padding: 1em 0pt; text-align: left;"&gt;&lt;img src="http://docs.google.com/File?id=dfsmd7s6_32hczgv9hd" /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;* Finally, figure out what you need to do with the GUI app you're working with and script it.  Pseudocode looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;       select from merchant dropdown&lt;br /&gt;       select from vendor dropdown&lt;br /&gt;       hit the "Process" button&lt;br /&gt;       hit the "Back" button twice (to get to the main screen)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;* The Groovy setup script looks something like the one below. I usually execute this first, so that my Groovy console has references to the combos and buttons so that I don't have to import the Jemmy classes every time (e.g. the Groovy console doesn't remember the imports that you might have done in previous executions, but it will remember the variables that you might have declared&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// Import Jemmy specific classes&lt;br /&gt;import org.netbeans.jemmy.*;&lt;br /&gt;import org.netbeans.jemmy.explorer.*;&lt;br /&gt;import org.netbeans.jemmy.operators.*;&lt;br /&gt;&lt;br /&gt;// Get references to all UI widgets so that we don't have to re-import&lt;br /&gt;// the Jemmy classes every time. The names of these variables will be&lt;br /&gt;// stored in the "binding" and can be accessed in subsequent script/snippet&lt;br /&gt;// executions&lt;br /&gt;merchantOp = new JComboBoxOperator(mainFrame,0)&lt;br /&gt;vendorOp = new JComboBoxOperator(mainFrame,1)&lt;br /&gt;processButtonOp = new JButtonOperator(mainFrame,"Process")&lt;br /&gt;backButtonOp = new JButtonOperator(mainFrame,"Back")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;* Write put the script that will actually do the work. The script is typically derived by executing the statements one by one and seeing that they do the right things. The script below processes an order for the first merchant and vendor and then comes back. See the Jemmy API for details on available widgets operators, etc.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;t = new Thread() {&lt;br /&gt;       merchantOp.selectItem(0)&lt;br /&gt;       vendorOp.selectItem(0)&lt;br /&gt;       processOpButton.push()&lt;br /&gt;       backButtonOp.push()&lt;br /&gt;       backButtonOp.push()&lt;br /&gt;}&lt;br /&gt;t.start()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;* Finally, the last step is to typically put something together that will do what you need repetitively. My script is below, I have it saved in the Coyote project directory, and I load it up from the Groovy console when it fires up. Note that I typically just hightlight and run the first part of the code first (to get references to all the buttons, etc), and then only run the second part when I need to run BizApp for a long time.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// Import Jemmy specific classes&lt;br /&gt;import org.netbeans.jemmy.*;&lt;br /&gt;import org.netbeans.jemmy.explorer.*;&lt;br /&gt;import org.netbeans.jemmy.operators.*;&lt;br /&gt;&lt;br /&gt;// Get references to all UI widgets so that we don't have to re-import&lt;br /&gt;// the Jemmy classes every time. The names of these variables will be&lt;br /&gt;// stored in the "binding" and can be accessed in subsequent script/snippet&lt;br /&gt;// executions&lt;br /&gt;merchantOp = new JComboBoxOperator(mainFrame,0)&lt;br /&gt;vendorOp = new JComboBoxOperator(mainFrame,1)&lt;br /&gt;processButtonOp = new JButtonOperator(mainFrame,"Process")&lt;br /&gt;backButtonOp = new JButtonOperator(mainFrame,"Back")&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Creating orders for a merchant involves creating orders for each vendor for the merchant.&lt;br /&gt;def processMerchantVendor(count,merchants) {&lt;br /&gt;   t = new Thread() {&lt;br /&gt;       count.times {&lt;br /&gt;                       try {&lt;br /&gt;                               merchants.each { merchantIndex -&amp;gt;&lt;br /&gt;                                       merchantOp.selectItem(merchantIndex)&lt;br /&gt;                                       if (merchantOp.selectedItem == "some_merchant") return&lt;br /&gt;                                       (0..vendorOp.itemCount).each { vendorIndex -&amp;gt;&lt;br /&gt;                                               if (merchantOp.itemCount &amp;gt; merchantIndex &amp;amp;&amp; vendorOp.itemCount &amp;gt; vendorIndex) {                                               &lt;br /&gt;                                                       Thread.sleep(50)&lt;br /&gt;                                                       vendorOp.selectItem(vendorIndex)&lt;br /&gt;                                                       Thread.sleep(50)&lt;br /&gt;                                                       processButtonOp.push()&lt;br /&gt;                                                       Thread.sleep(50)&lt;br /&gt;                                                       backButtonOp.push()&lt;br /&gt;                                                       Thread.sleep(50)&lt;br /&gt;                                                       backButtonOp.push()&lt;br /&gt;                                               }&lt;br /&gt;                                       }&lt;br /&gt;                               }&lt;br /&gt;                       } catch (Exception e) {  }&lt;br /&gt;               }   &lt;br /&gt;   }&lt;br /&gt;   t.start()&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// This creates test orders for all merchants, 10 times in a row.&lt;br /&gt;processMerchantVendor(10,(1..merchantOp.itemCount))&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-7513279784630948564?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/KDFgAUSFB0M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/7513279784630948564/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/08/groovy-jemmy-gui-automation-this-is.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/7513279784630948564?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/7513279784630948564?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/KDFgAUSFB0M/groovy-jemmy-gui-automation-this-is.html" title="Groovy + Jemmy GUI automation" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/08/groovy-jemmy-gui-automation-this-is.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEEESHkyeSp7ImA9WxZaF0U.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-4776199254933057037</id><published>2007-06-15T00:09:00.002-05:00</published><updated>2008-05-02T22:50:09.791-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-02T22:50:09.791-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="scripting" /><title>CDJUG June meeting</title><content type="html">I was at the &lt;a title="Capital District Java User Group (CDJUG)" href="http://www.cdjdn.com/"&gt;Capital District Java User Group (CDJUG)&lt;/a&gt; meeting yesterday and it was quite an interesting experience. For starters, I wasn't sure if I was going to the meeting until the last minute, and I didn't even know if I was going to stay the whole time. Secondly, at the last minute I was pleasantly surprised that there were going to be 2 presentations at the meeting.&lt;br /&gt;&lt;br /&gt;Anthony will be posting the presentation slides in the next few days on the site, but in the meantime, I'll write a few notes from the meeting.&lt;br /&gt;&lt;br /&gt;THe first presentation was on the &lt;a title="Sleep (JVM) scripting language" href="http://sleep.hick.org/"&gt;Sleep (JVM) scripting language&lt;/a&gt; by &lt;a href="http://rsmudge.livejournal.com/"&gt;Raphael Mudge&lt;/a&gt;. He was a very energetic guy, and it was quite a bit of fun just listening to him. Good work Raphael ! Now, the presentation was great, but I personally am far from being convinced that this is something that I will be investing my time into. Here's the deal:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;I've already dabbled into at least a couple of JVM scripting languages (Jython in the past, and now Groovy). THere is a couple of dozen more scripting languages on the JVM which are all interesting to mess around with. Thus, in order to convince a developer to spend time with the language, a scripting language needs to have a number of different characteristics. Granted, Raphi has quite an interesting character, the conversation with him before the presentation was very engaging. At the same time, as with any open source project, the key factor in whether the project will survive is the size of the community. Now, I know Raphi said that there were a bunch of people using the scripting language; however, as it is with a bunch of other open source projects, typically the top 1-2 contenders in the space gather 90+% of the developer attention and community. Although the other languages are not necessarily doomed to fail, they have to find their own niche and a set of committed developers in order to survive. Granted, it seemed like SLeep already has a niche by being used in jIRCii; however, it appeared that Raphi was the sole significant developer. So, the question is, what happens when/if he loses interest ? &lt;/li&gt;&lt;li&gt;Raphi specifically mentioned that he's not trying to be all things to all people, and considering that it is a much smaller project and community than the other scripting languages, that is a very reasonable goal. However, in order to win developer mindshare, it seems to me that having a decent size standard library with utility functions and being able to call into the JVM for everything else, it's not enough any more. I'm judging from my personal experience: one of the major selling points of Groovy to me was that it DID have the convenient, easy xml processing, JDBC access, command line interface, etc. etc. etc, all on top of its seamless integration with the JVM.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now, this is just me, but I never grokked the Perl syntax. Seriously, this was probably the first language that I looked at when I was first trying to understand what web programming was all about (10 years ago).. and today, I'm still looking at the syntax and it can never fit into my skull...&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A couple of notes on the presentation:&lt;/li&gt;&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;        I didn't quite get it if slee was able to extend the classpath at runtime. Raphi showed thate there was an interactive console (big plus in my opinion, Groovy still kinda sucks in this area); however, one big selling point for me was that at any point I could throw in a couple more jars to the classloader and start loading classes from there.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Raphi mentioned that it was his intent to have a clear separation between the sleep program and where it calls into Java; however, for me personally, that was a downside. I found the method calls to be kinda cryptic ( I couldn't quite follow what was happening in a couple of nested method calls - I admit, it might just be my fault, as I haven't seen Objective-C syntax on which the Sleep syntax is based). At the same tie, I didn't see any type of bean properties (e.g. instead of doing foo.setBar('baz'), doing foo.bar='baz'), which for a scripting language is a must in my opinion.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The documentation seemed to be excellent&lt;/li&gt;&lt;li&gt;All the time when I was looking at the presentation, I was thinking that after NetBeans 6.0 comes out, he should have a Schliemann module for Sleep syntax. :-)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Runtime size was pretty small , big plus for embedding uses...&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Now, the second presentation was the main reason why I went to the meeting. It was about NetBeans by the author of  &lt;a title="Pro NetBeans IDE 5.5 Enterprise Edition" href="http://www.pronetbeans.com/"&gt;Pro NetBeans IDE 5.5 Enterprise Edition&lt;/a&gt;, Adam Myatt.  I was really thrilled to meet him as I had heard from Anthony that he lives in the Capital District area, and that he's a big NetBeans supporter. I was also really looking forward to checking out his book as I had read a couple of good reviews. Adam did an excellent presentation, he was on his game, and I have rarely seen someone present so many things in such a tight and organized manner. He did an excellent job at presenting NetBeans to the people who had gathered and received a very positive response - one of my coworkers actually re-installed NetBeans the next day and was trying stuff out with it. Way to go , Adam ! One thing that totally blew me away during the presentation was the relatively small footprint of NetBeans. When he was doing the demo of NB 5.5.1, the memory rarely went above 100 MB, and I was quite impressed since he was doing quite a bit (and his laptop was not the greatest to begin with). Considering that he did everything from UML diagrams to Visual Web Pack demos, I was VERY impressed. Then, when he was doing the NetBeans 6.0 preview, I was even more impressed as it hovered around 50 MB - AMAZING !&lt;br /&gt;&lt;br /&gt;I was personally a bit disappointed that I didn't learn too much from the presentation. I understand that I was  not the target audience for it, as I've been a NetBeans user for quite a long time, and I knew 99% of the stuff that Adam talked about. He was covering a lot of ground (more width than depth) as was necessary to present to the majority of the audience. But all in all, I liked the presentation and I'm looking forward to the next time we meet up : maybe we might even get a chance to talk a bit..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-4776199254933057037?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/THur3LcHfkQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/4776199254933057037/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/06/i-was-at-capital-district-java-user.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4776199254933057037?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/4776199254933057037?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/THur3LcHfkQ/i-was-at-capital-district-java-user.html" title="CDJUG June meeting" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/06/i-was-at-capital-district-java-user.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIMRn8_eip7ImA9WxZaF0U.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-6639139213158442689</id><published>2007-06-13T23:08:00.001-05:00</published><updated>2008-05-02T22:49:47.142-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-02T22:49:47.142-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="netbeans rcp" /><title /><content type="html">I posted the same message to the NetBeans users mailing list and so far I haven't gotten any responses on it (http://www.netbeans.org/servlets/ReadMsg?list=nbusers&amp;amp;msgNo=93210). I'm re-posting it here again, just in case somebody follows my blog and maybe has ideas about how this is handled best ...&lt;br /&gt;&lt;br /&gt;----------------- NetBeans Users maling list post ----------&lt;br /&gt;&lt;br /&gt;Can anybody point me to any resources that describe best practices in&lt;br /&gt;managing dependencies between multiple NetBeans modules and suites ?&lt;br /&gt;&lt;br /&gt;Overall, here is my problem:&lt;br /&gt;&lt;br /&gt;I have a module suite (e.g. MySuite1)  that uses a couple of external&lt;br /&gt;libraries e.g. foo1.jar and foo2.jar .  I know that NB provides a library&lt;br /&gt;wrapper module, so, I create library wrappers for each one of these&lt;br /&gt;external jars e.g. foo1-lib and foo2-lib . As I understand, when I create&lt;br /&gt;the library wrapper modules, the foo1.jar and foo2.jar are copied into a&lt;br /&gt;private directory for the module e.g.&lt;br /&gt;${foo1-lib}/release/modules/ext/foo1jar .&lt;br /&gt;&lt;br /&gt;Then, I create a second module suite : MySuite2, which happens to need the&lt;br /&gt;same two external jars.&lt;br /&gt;- Should I create 2 new library wrapper modules for foo1.jar and foo2.jar&lt;br /&gt;so that I can add the new library wrapper modules to MySuite2, or should I&lt;br /&gt;just use the library wrapper modules that I created for MySuite1 ?&lt;br /&gt;- The problem there is that if I don't create new library wrapper modules&lt;br /&gt;and simply add foo1-lib and foo2-lib modules to MySuite2, then they will&lt;br /&gt;be removed from MySuite1 (and when I want to work on MySuite1, I have to&lt;br /&gt;move them back to MySuite).&lt;br /&gt;- If I create new library wrapper modules for MySuite2  (e.g. foo1-lib2&lt;br /&gt;and foo2-lib2 modules), then there is going to be yet another copy of the&lt;br /&gt;original jars in the new module's releas/modules/ext/foo1.jar, which then&lt;br /&gt;becomes a pain to manage (e.g. if a jar is used in 10 different modules,&lt;br /&gt;each one will have a private copy. Then if I build a new version of the&lt;br /&gt;jar, I need to update all 10 private copies in each module).&lt;br /&gt;-  Finally, if I have multiple modules in different suites wrapping the&lt;br /&gt;same jar, if I install 2 different modules suites into the same IDE, amd I&lt;br /&gt;going to have multiple copies of the same jar, or will the IDE figure out&lt;br /&gt;that they are the same (e.g. if all have the same version numbers and code&lt;br /&gt;name base) and only install one of them ?&lt;br /&gt;&lt;br /&gt;I would appreciate any tips on how this is handled best.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-6639139213158442689?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/M2GBlvT1VG4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/6639139213158442689/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/06/i-posted-same-message-to-netbeans-users.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6639139213158442689?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/6639139213158442689?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/M2GBlvT1VG4/i-posted-same-message-to-netbeans-users.html" title="" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/06/i-posted-same-message-to-netbeans-users.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cASHkzeip7ImA9WxRbGEQ.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-2553877953158979063</id><published>2007-05-31T18:04:00.002-05:00</published><updated>2008-12-10T03:50:49.782-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-10T03:50:49.782-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="junit" /><title>JUnit results in free form projects</title><content type="html">At work, I'm working with a couple of colleagues on a project. Now, as is probably usual in many other environments, we all use different tools to work on the project: I use NetBeans, and the other two guys use Eclipse and Emacs. Thus, we have agreed that the Ant build scripts will be "the truth" : they have to be maintained and kept as the main tool for building, testing, and running the application.&lt;br /&gt;&lt;br /&gt;So, all of that is great; however, I really like my NetBeans IDE, and I just couldn't continue living life without being able to use all of it's goodness. The best thing about NetBeans is that it is Ant based and it has the smarts/hooks to understand what you're trying to do (even in a freeform project), so that it can help you best. Here are the steps that I took to get my testing configuration going for a freeform project:&lt;br /&gt;&lt;br /&gt;1. The first thing I did is to review the &lt;a href='http://www.netbeans.org/kb/41/freeform-config.html'&gt;NetBeans Advanced Free Form Project Configuration &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. I added a compile selected item and debug project tasks (the debug task was quite useful since the code I was trying to understand was kinda convoluted and the debugger was invaluable in understanding how it works):&lt;br /&gt;&lt;br /&gt;Here is what I added to my nbproject/project.xml (the ide-actions section): &lt;br /&gt;&lt;pre language="xml"&gt;&lt;br /&gt; &amp;lt;action name='debug'&amp;gt;&lt;br /&gt;                    &amp;lt;script&amp;gt;nbproject/ide-file-targets.xml&amp;lt;/script&amp;gt;&lt;br /&gt;                    &amp;lt;target&amp;gt;debug-nb&amp;lt;/target&amp;gt;&lt;br /&gt;                &amp;lt;/action&amp;gt;&lt;br /&gt;                &amp;lt;action name='compile.single'&amp;gt;&lt;br /&gt;                    &amp;lt;script&amp;gt;nbproject/ide-file-targets.xml&amp;lt;/script&amp;gt;&lt;br /&gt;                    &amp;lt;target&amp;gt;compile-selected-files-in-test&amp;lt;/target&amp;gt;&lt;br /&gt;                    &amp;lt;context&amp;gt;&lt;br /&gt;                        &amp;lt;property&amp;gt;files&amp;lt;/property&amp;gt;&lt;br /&gt;                        &amp;lt;folder&amp;gt;test&amp;lt;/folder&amp;gt;&lt;br /&gt;                        &amp;lt;pattern&amp;gt;\.java$&amp;lt;/pattern&amp;gt;&lt;br /&gt;                        &amp;lt;format&amp;gt;relative-path&amp;lt;/format&amp;gt;&lt;br /&gt;                        &amp;lt;arity&amp;gt;&lt;br /&gt;                            &amp;lt;separated-files&amp;gt;,&amp;lt;/separated-files&amp;gt;&lt;br /&gt;                        &amp;lt;/arity&amp;gt;&lt;br /&gt;                    &amp;lt;/context&amp;gt;&lt;br /&gt;                &amp;lt;/action&amp;gt;&lt;br /&gt;                &amp;lt;action name='test.single'&amp;gt;&lt;br /&gt;                    &amp;lt;script&amp;gt;nbproject/ide-file-targets.xml&amp;lt;/script&amp;gt;&lt;br /&gt;                    &amp;lt;target&amp;gt;run-selected-files-in-test&amp;lt;/target&amp;gt;&lt;br /&gt;                    &amp;lt;context&amp;gt;&lt;br /&gt;                        &amp;lt;property&amp;gt;classname&amp;lt;/property&amp;gt;&lt;br /&gt;                        &amp;lt;folder&amp;gt;test&amp;lt;/folder&amp;gt;&lt;br /&gt;                        &amp;lt;pattern&amp;gt;\.java$&amp;lt;/pattern&amp;gt;&lt;br /&gt;                        &amp;lt;format&amp;gt;java-name&amp;lt;/format&amp;gt;&lt;br /&gt;                        &amp;lt;arity&amp;gt;&lt;br /&gt;                            &amp;lt;one-file-only&amp;gt;&amp;lt;/one-file-only&amp;gt;&lt;br /&gt;                        &amp;lt;/arity&amp;gt;&lt;br /&gt;                    &amp;lt;/context&amp;gt;&lt;br /&gt;                &amp;lt;/action&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My ide-file-targets.xml additions look like this: &lt;br /&gt;&lt;pre language="xml"&gt;&lt;br /&gt;&amp;lt;target name='compile-selected-files-in-test'&amp;gt;&lt;br /&gt;        &amp;lt;fail unless='files'&amp;gt;Must set property 'files'&amp;lt;/fail&amp;gt;&lt;br /&gt;        &amp;lt;mkdir dir='${test.classes.dir}'&amp;gt;&amp;lt;/mkdir&amp;gt;&lt;br /&gt;        &amp;lt;javac srcdir='test' source='1.6' includes='${files}' destdir='${test.classes.dir}'&amp;gt;&lt;br /&gt;            &amp;lt;classpath refid='run.test.class.path'&amp;gt;&amp;lt;/classpath&amp;gt;&lt;br /&gt;        &amp;lt;/javac&amp;gt;&lt;br /&gt;    &amp;lt;/target&amp;gt;&lt;br /&gt;    &amp;lt;target name='run-selected-files-in-test'&amp;gt;&lt;br /&gt;        &amp;lt;fail unless='classname'&amp;gt;Must set property 'files'&amp;lt;/fail&amp;gt;&lt;br /&gt;        &amp;lt;mkdir dir='${test.classes.dir}'&amp;gt;&amp;lt;/mkdir&amp;gt;&lt;br /&gt;        &amp;lt;junit dir='${test.classes.dir}' printsummary='true' showoutput='true' fork='true'&amp;gt;&lt;br /&gt;            &lt;br /&gt;            &amp;lt;classpath refid='run.test.class.path'&amp;gt;&amp;lt;/classpath&amp;gt;&lt;br /&gt;            &amp;lt;formatter type='brief' usefile='false'&amp;gt;&amp;lt;/formatter&amp;gt;&lt;br /&gt;            &amp;lt;formatter type='xml'&amp;gt;&amp;lt;/formatter&amp;gt;&lt;br /&gt;            &amp;lt;test name='${classname}'&amp;gt;&amp;lt;/test&amp;gt;&lt;br /&gt;        &amp;lt;/junit&amp;gt;&lt;br /&gt;    &amp;lt;/target&amp;gt;&lt;br /&gt;   &amp;lt;target name='debug-nb' depends='compile, compile-test'&amp;gt;&lt;br /&gt;        &amp;lt;path id='sourcepath'&amp;gt;&lt;br /&gt;            &amp;lt;pathelement path='src/'&amp;gt;&amp;lt;/pathelement&amp;gt;&lt;br /&gt;            &amp;lt;pathelement path='test/'&amp;gt;&amp;lt;/pathelement&amp;gt;&lt;br /&gt;            &amp;lt;pathelement path='..\\DeclTypeSys\\src'&amp;gt;&amp;lt;/pathelement&amp;gt;&lt;br /&gt;            &amp;lt;pathelement path='..\\DeclTypeSys\\test'&amp;gt;&amp;lt;/pathelement&amp;gt;&lt;br /&gt;        &amp;lt;/path&amp;gt;&lt;br /&gt;        &amp;lt;nbjpdastart transport='dt_socket' name='perspective' addressproperty='jpda.address'&amp;gt;&lt;br /&gt;            &amp;lt;classpath refid='run.test.class.path'&amp;gt;&amp;lt;/classpath&amp;gt;&lt;br /&gt;            &amp;lt;sourcepath refid='sourcepath'&amp;gt;&amp;lt;/sourcepath&amp;gt;&lt;br /&gt;        &amp;lt;/nbjpdastart&amp;gt;&lt;br /&gt;        &amp;lt;junit dir='${test.classes.dir}' showoutput='true' printsummary='yes' fork='true'&amp;gt;&lt;br /&gt;            &amp;lt;jvmarg value='-Xdebug'&amp;gt;&amp;lt;/jvmarg&amp;gt;&lt;br /&gt;            &amp;lt;jvmarg value='-Xnoagent'&amp;gt;&amp;lt;/jvmarg&amp;gt;&lt;br /&gt;            &amp;lt;jvmarg value='-Djava.compiler=none'&amp;gt;&amp;lt;/jvmarg&amp;gt;&lt;br /&gt;            &amp;lt;jvmarg value='-Xrunjdwp:transport=dt_socket,address=${jpda.address},suspend=y'&amp;gt;&amp;lt;/jvmarg&amp;gt;&lt;br /&gt;            &lt;br /&gt;            &amp;lt;formatter type='xml'&amp;gt;&amp;lt;/formatter&amp;gt;&lt;br /&gt;            &amp;lt;formatter usefile='false' type='brief'&amp;gt;&amp;lt;/formatter&amp;gt;&lt;br /&gt;            &amp;lt;classpath refid='run.test.class.path'&amp;gt;&amp;lt;/classpath&amp;gt;&lt;br /&gt;            &amp;lt;batchtest&amp;gt;&lt;br /&gt;                &amp;lt;fileset dir='${basedir}/test'&amp;gt;&lt;br /&gt;                    &lt;br /&gt;                    &amp;lt;include name='**/**/*Test.java'&amp;gt;&amp;lt;/include&amp;gt;&lt;br /&gt;                &amp;lt;/fileset&amp;gt;&lt;br /&gt;            &amp;lt;/batchtest&amp;gt;&lt;br /&gt;        &amp;lt;/junit&amp;gt;&lt;br /&gt;    &amp;lt;/target&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After I did that, my JUnit results look like this: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href='http://1.bp.blogspot.com/_GbeUi4pR7kA/Rl-8AuS1a0I/AAAAAAAAABU/wVpsJ7eZlB8/s1600-h/netbeans_plain_junit.png' onblur='try {parent.deselectBloggerImageGracefully();} catch(e) {}'&gt;&lt;img border='0' id='BLOGGER_PHOTO_ID_5070978426055519042' alt='' src='http://1.bp.blogspot.com/_GbeUi4pR7kA/Rl-8AuS1a0I/AAAAAAAAABU/wVpsJ7eZlB8/s320/netbeans_plain_junit.png' style='margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;'&gt;&lt;/img&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So, that was OK, but far from great. I thought that there should be a way to invoke the NetBeans JUnit test runner; however, googling around for it didn't help much. Then, just when I was about to lose hope, I ran upon these couple of posts:&lt;br /&gt;&lt;br /&gt;&lt;a href='http://junit.netbeans.org/doc/binding-freeform-to-output.html'&gt;Binding Freeform to Output&lt;/a&gt; and &lt;br /&gt;&lt;a href='http://weblogs.java.net/blog/gsporar/archive/2006/02/uportal_develop_4.html'&gt; UPortal Develop by Greg Sporar &lt;/a&gt; . &lt;br /&gt;&lt;br /&gt;3.A slight complication on my end : I really didn't want to mess around with the target name of the original build.xml since the other team members were using that already. Thus, I added the following task to my ide-file-targets.xml: &lt;br /&gt;&lt;pre language="xml"&gt;&lt;br /&gt;    &amp;lt;target name='test-project'&amp;gt;&lt;br /&gt;       &lt;br /&gt;        &amp;lt;antcall target='junit'&amp;gt;&amp;lt;/antcall&amp;gt;&lt;br /&gt;    &amp;lt;/target&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and changed the test single target name to "test-run-selected-files-in-test", so that the target name starts with "test" and changed the corresponding entry in my project.xml to run the right target. &lt;br /&gt;&lt;br /&gt;And now, my test results look like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href='http://1.bp.blogspot.com/_GbeUi4pR7kA/Rl-7auS1azI/AAAAAAAAABM/Vz_mDvMb6rI/s1600-h/netbeans_junit_beauty.png' onblur='try {parent.deselectBloggerImageGracefully();} catch(e) {}'&gt;&lt;img border='0' id='BLOGGER_PHOTO_ID_5070977773220490034' alt='' src='http://1.bp.blogspot.com/_GbeUi4pR7kA/Rl-7auS1azI/AAAAAAAAABM/Vz_mDvMb6rI/s320/netbeans_junit_beauty.png' style='margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;'&gt;&lt;/img&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BEAUTY !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-2553877953158979063?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/Wrzkzudqw2E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/2553877953158979063/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/05/junit-results-in-free-form-projects.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2553877953158979063?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2553877953158979063?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/Wrzkzudqw2E/junit-results-in-free-form-projects.html" title="JUnit results in free form projects" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_GbeUi4pR7kA/Rl-8AuS1a0I/AAAAAAAAABU/wVpsJ7eZlB8/s72-c/netbeans_plain_junit.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/05/junit-results-in-free-form-projects.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cBQX4yfCp7ImA9WxRbGEQ.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-8722112580883138263</id><published>2007-05-23T00:24:00.000-05:00</published><updated>2008-12-10T03:50:50.094-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-10T03:50:50.094-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><category scheme="http://www.blogger.com/atom/ns#" term="junit" /><category scheme="http://www.blogger.com/atom/ns#" term="groovy" /><title>NetBeans testing with Groovy</title><content type="html">I'm making some progress on my thesis, and as one can expect, when I'm writing code, I need to be writing some unit tests for it. Now, I know that Groovy is an excellent candidate for writing unit tests (better than the traditional JUnit stuff that NetBeans supports out of the box). However, it isn't quite obvious exactly how is one supposed to use and run these Groovy unit tests inside of NetBeans (apart form hacking together a crude solution where you have to add a line to a file, every time you need something to the suite() method). I just want to be able to hit the Alt-F6 button and have all of my tests run like magic : no manual additions to the suite, no tweaking. &lt;br /&gt;&lt;br /&gt;So, in the end it worked, with a couple of gotchas:&lt;br /&gt;1. NetBeans only seems to like running JUnit Test cases (when you hit Alt-F6) if and only if the test case name ends with "Test". That's kinda clunky, and as far as I know is not a requirement of JUnit itself. THere is nothing preventing you from executing the unit test individually (e.g. right-click -&gt; run) - it runs like magic, but unless the class name ends with "Test", NetBeans doesn't add it to the bucket of tests to run. &lt;br /&gt;&lt;br /&gt;2. The &lt;a href="http://coyote.dev.java.net"&gt; coyote module &lt;/a&gt; provides some support for testing in Groovy; however, it is not entirely intuitive exactly how that is done. In effect, if you want things to work nicely, you have to do 2 things:&lt;br /&gt; - first, select a class that you want to test, go to Tools - Groovy Tests - Create Tests. That will basically greate a suite and a test in the $PROJECT/groovy-tests directory, as well as a groovy class in there. &lt;br /&gt;&lt;br /&gt;A note a couple of months later, after the completion of the thesis project: Groovy worked great for the unit and integration testing of my project. It was fairly easy to script any of the scenarios that I had in mind, and after I had the general template for working with the groovy tests, it became quite easy to have pretty decent test coverage. Actually, the Groovy tests ended up being one of the important reasons for managing to complete the project after losing all of the work that I had done for the last 1.5 years ( yeah, I know i'm dumb not to have a backup, so, if YOU are working on something that important, DO A BACKUP NOW!!!). &lt;br /&gt;&lt;br /&gt;Here is what my setup looks like:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_GbeUi4pR7kA/RlJ3QeS1awI/AAAAAAAAAA0/eEUERQ0pm1E/s1600-h/groovy_testing1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_GbeUi4pR7kA/RlJ3QeS1awI/AAAAAAAAAA0/eEUERQ0pm1E/s320/groovy_testing1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5067243655638903554" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1. I have one Java class for each type of tests that I wrote in Groovy. That is useful to be able to say "Test Project" from the project menu, and have all Groovy Tests executed in a meaningful manner. &lt;br /&gt;&lt;br /&gt;2. Each Java JUnit subclass, has something like this in it. In effect, that takes the all Groovy files starting with "Service" and makes test suite out of them. One thing to note is that (slightly inconventiently), when the unit tests are run, all test methods from all groovy files show up under the name of the Java test class e.g. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_GbeUi4pR7kA/RlJ3Y-S1axI/AAAAAAAAAA8/nMAl5DrysjI/s1600-h/groovy_test_results.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_GbeUi4pR7kA/RlJ3Y-S1axI/AAAAAAAAAA8/nMAl5DrysjI/s320/groovy_test_results.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5067243801667791634" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public  static Test suite() throws Exception {&lt;br /&gt;        TestSuite suite = new TestSuite("HandlerTests");&lt;br /&gt;        &lt;br /&gt;suite.addTest(AllTestSuite.suite("/home/polrtex/Docs/UofS_SE/Thesis/Implementation/MvpService/test/groovytest","Service*.groovy"));&lt;br /&gt;        &lt;br /&gt;        return suite;&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;3. Finally, the Groovy test has some test methods in it, which get executed when you run the "Test" command on the project.&lt;br /&gt;&lt;br /&gt;One final note on the tests themselves. I was using Spring 2.0 for my project, so I wanted to use the same datasource and service classes that the Spring Framework provides. Now, I knew that there were a couple of supporting Spring test classes (e.g. org.springframework.test.AbstractTransactionalDataSourceSpringContextTests), but I wasn't quite sure how to use them when the test are implemented in Groovy. What I ended up doing was to have a base Java class that extended the Spring test class mentioned above, and then have all of my Groovy tests extend that class. One thing that was interesting to note here was that I had to use the Spring autowire by name option, and the population of protected variables e.g. &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;class DaoTest  extends com.troymaxventurs.mvp.test.MvpBaseTest {&lt;br /&gt;    //protected ds;);&lt;br /&gt;    protected mvpDAO;&lt;br /&gt;    protected mvpDataSource;&lt;br /&gt;    DaoTest() {&lt;br /&gt;        super("DaoTest")&lt;br /&gt;        setPopulateProtectedVariables(true)        &lt;br /&gt;        setAutowireMode(AUTOWIRE_BY_NAME)                     &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The reason I needed it to populate the protected variables (and not the bean fields) is that when these Groovy tests were instantiated, Spring tried to populate some Groovy specific public properties (e.g. the metaClass property), and thus, it failed along the way. With the population of protected variables, I could specify exactly what I wanted to have populated, without having to worry about any magic that Spring does to discover what dependencies to inject.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-8722112580883138263?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/6lmD5qYoK3g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/8722112580883138263/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/03/netbeans-testing-with-groovy.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/8722112580883138263?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/8722112580883138263?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/6lmD5qYoK3g/netbeans-testing-with-groovy.html" title="NetBeans testing with Groovy" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_GbeUi4pR7kA/RlJ3QeS1awI/AAAAAAAAAA0/eEUERQ0pm1E/s72-c/groovy_testing1.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/03/netbeans-testing-with-groovy.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MAR3w_fCp7ImA9WB5VEk0.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-5739621145759552931</id><published>2007-03-30T09:26:00.000-05:00</published><updated>2007-08-04T01:37:26.244-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-08-04T01:37:26.244-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="netbeans" /><title>Customizing the executable</title><content type="html">I'm currently working on an NetBeans RCP based app, spending a huge&lt;br /&gt;amount of my time on the platform. I got around to customizing the&lt;br /&gt;application that I'm working on, and I did recall Geertjan's post about cleaning up&lt;br /&gt;the app from the NetBeans specific stuff. &lt;a href="http://blogs.sun.com/geertjan/entry/changing_a_windows_executable_s"&gt;Geertjan did mention&lt;/a&gt; that&lt;br /&gt;you could fix the executable icon (on Windows) by using the resource&lt;br /&gt;editor on the built zip file. Well, the altenative is to make a copy&lt;br /&gt;of the executable from your ${harness.dir}/launchers/app.exe to your&lt;br /&gt;local project dir, edit the executable resources by using the Resource&lt;br /&gt;Hacker that Geertjan recommended, and modify the build script to use&lt;br /&gt;the modified executable to use your updated executable for building&lt;br /&gt;your app. So, the changes to my harness build file are as described&lt;br /&gt;below. It is indeed a bit of a hack, as one I'd imagine that it&lt;br /&gt;wouldn't be advisable to edit the global build scripts (that build for&lt;br /&gt;all projects); however, it seems that this is a more universal need&lt;br /&gt;for platform developers - one should be able to totally customize the&lt;br /&gt;branding of the application. While the majority of the work is&lt;br /&gt;possible to be done within NetBeans (with the excellent support of the&lt;br /&gt;platform modules), the ability to customize the icon on the executable&lt;br /&gt;is a very important one as well.&lt;br /&gt;&lt;br /&gt;in the body of the build-launchers target ($platform_dir/harness/suite.xml):&lt;br /&gt;&lt;br /&gt;right after :&lt;br /&gt;&lt;pre language="xml"&gt;&lt;br /&gt;&amp;lt;mkdir dir="${build.launcher.dir}/etc"/&amp;gt;&lt;br /&gt;&amp;lt;mkdir dir="${build.launcher.dir}/bin"/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Add the following :&lt;br /&gt;&lt;pre language="xml"&gt;&lt;br /&gt;&amp;lt;available file="branding/launcher/${app.name}.exe" property="local.launcher.found" /&amp;gt;&lt;br /&gt;&amp;lt;antcall target="make-local-launcher" inheritall="true"/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;then, add a new target in the same file&lt;br /&gt;&lt;pre language="xml"&gt;&lt;br /&gt;&amp;lt;target name="make-local-launcher" unless="local.launcher.found"&amp;gt;&lt;br /&gt;&amp;lt;mkdir dir="branding/launcher" /&amp;gt;&lt;br /&gt;&amp;lt;copy file="${harness.dir}/launchers/app.exe"&lt;br /&gt;tofile="branding/launcher/${app.name}.exe" overwrite="false"/&amp;gt;&lt;br /&gt;&amp;lt;/target&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-5739621145759552931?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/j-7u5ezpJTc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/5739621145759552931/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/03/customizing-executable.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/5739621145759552931?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/5739621145759552931?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/j-7u5ezpJTc/customizing-executable.html" title="Customizing the executable" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/03/customizing-executable.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYFR3c_eip7ImA9WBFXGEU.&quot;"><id>tag:blogger.com,1999:blog-19648744.post-2891802717585423378</id><published>2007-03-26T00:31:00.001-05:00</published><updated>2007-03-26T00:31:56.942-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-03-26T00:31:56.942-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mobile video" /><category scheme="http://www.blogger.com/atom/ns#" term="j2me" /><category scheme="http://www.blogger.com/atom/ns#" term="my thesis" /><title>Vanished "Sun Smart Ticket" demo app</title><content type="html">I'm in the process of scrambling some resources together for my thesis project which has to do with J2ME and video delivery. Now, I've been working on this project (on and off) for the last 1.5 years, so it's been a while since I went back to look at all the resources that I had used at the very beginning. &lt;br /&gt;&lt;br /&gt;So, one of the excellent resource that I used from the beginning was the Sun Smart Ticket J2ME &amp; J2EE demo application. I used it to learn the "best practices" when I was getting started, and to a large degree I used it as a template for the first prototype that I built. So, I was quite surprised to find out that the application in question has just vanished from the internet : it was not on the Sun site, it was NOWHERE !!! It was mentioned on a couple of Sun publications, it was in Michael Yuan's excellent Enterprise J2ME book.. but the actual source to the server and j2me client has just vanished.. Evidently, it used to be a part of what the "Wireless Blueprints", which is no more, with nothing to replace it... &lt;br /&gt;&lt;br /&gt;Well, to sum it up, I found a copy on &lt;a href='http://www.borland.com/devsupport/bes/downloads/deployathon/smarticket/smartticket-2_0-ea.zip'&gt;a borland site&lt;/a&gt;, so I thought I'd give it a mention, just in case somebody else is scrambling to dig up this prescious resource. This just makes me wonder though, why is Sun trying to bury this demo... It was an excellent demo, with some pretty outstanding design ideas (which are a little complex, but after getting over the initial learning curve, they're sheer brilliance).. Well, that's a question that I should probably ask some of the J2ME people... it's open source now, right...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19648744-2891802717585423378?l=www.troymaxventures.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/akochnev/~4/_4h0Do6ekPc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.troymaxventures.com/feeds/2891802717585423378/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.troymaxventures.com/2007/03/vanished-sun-smart-ticket-demo-app.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2891802717585423378?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/19648744/posts/default/2891802717585423378?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/akochnev/~3/_4h0Do6ekPc/vanished-sun-smart-ticket-demo-app.html" title="Vanished &quot;Sun Smart Ticket&quot; demo app" /><author><name>akochnev</name><uri>http://www.blogger.com/profile/05519996133043093264</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="04528222012618666301" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.troymaxventures.com/2007/03/vanished-sun-smart-ticket-demo-app.html</feedburner:origLink></entry></feed>
