<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>On The Rhoads/Brad</title>
	<atom:link href="http://ontherhoads.org/brad/feed/" rel="self" type="application/rss+xml" />
	<link>http://ontherhoads.org/brad</link>
	<description></description>
	<lastBuildDate>Mon, 02 Apr 2012 17:55:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To Do  A Global Grep</title>
		<link>http://ontherhoads.org/brad/2012/04/how-to-do-a-global-grep/</link>
		<comments>http://ontherhoads.org/brad/2012/04/how-to-do-a-global-grep/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 17:48:24 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[grep]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=114</guid>
		<description><![CDATA[Here&#8217;s an example of how to do a recursive grep through your file system. In this case I&#8217;m looking for the text &#8216;otalo.AO.models&#8217; in all Python scripts (*.py).
It turns out that the find command is way to do this. It lets you execute another command on its results. So here we pass the results to [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an example of how to do a recursive grep through your file system. In this case I&#8217;m looking for the text &#8216;otalo.AO.models&#8217; in all Python scripts (*.py).</p>
<p>It turns out that the find command is way to do this. It lets you execute another command on its results. So here we pass the results to grep. The -H grep param is needed to get the file names to print in front the actual content. </p>
<p>So the general form is:</p>
<p><code>sudo find / -name [search string] -exec [any command] {} \;</code></p>
<p>And my example search is:<br />
<code><br />
sudo find / -name *.py -exec grep -H 'otalo.AO.models' {} \;<br />
</code></p>
<p>which happily gives this result:</p>
<p><code><br />
/home/otalo/otalo/AO/fixtures/seed_data.py:from otalo.AO.models import User, Forum, Tag, Admin, Line<br />
/opt/freeswitch/scripts/AO/experiment-digest.py:from otalo.AO.models import Line, Message_forum<br />
. . .<br />
</code></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F04%2Fhow-to-do-a-global-grep%2F&amp;title=How+To+Do++A+Global+Grep" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F04%2Fhow-to-do-a-global-grep%2F&amp;title=How+To+Do++A+Global+Grep" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F04%2Fhow-to-do-a-global-grep%2F&amp;title=How+To+Do++A+Global+Grep" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F04%2Fhow-to-do-a-global-grep%2F&amp;title=How+To+Do++A+Global+Grep', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F04%2Fhow-to-do-a-global-grep%2F&amp;t=How+To+Do++A+Global+Grep" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F04%2Fhow-to-do-a-global-grep%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F04%2Fhow-to-do-a-global-grep%2F&amp;title=How+To+Do++A+Global+Grep" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2012/04/how-to-do-a-global-grep/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VM Search Engine</title>
		<link>http://ontherhoads.org/brad/2012/02/vm-search-engine/</link>
		<comments>http://ontherhoads.org/brad/2012/02/vm-search-engine/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 08:34:17 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=111</guid>
		<description><![CDATA[Loading

 
  google.load('search', '1', {language : 'en'});
  google.setOnLoadCallback(function() {
    var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
      '011315861205209999399:udojr8mkp2s', customSearchOptions);
    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    customSearchControl.draw('cse');
  }, true);






















]]></description>
			<content:encoded><![CDATA[<div id="cse" style="width: 100%;">Loading</div>
<p><script src="http://www.google.com/jsapi" type="text/javascript"></script><br />
<script type="text/javascript"> 
  google.load('search', '1', {language : 'en'});
  google.setOnLoadCallback(function() {
    var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
      '011315861205209999399:udojr8mkp2s', customSearchOptions);
    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    customSearchControl.draw('cse');
  }, true);
</script></p>
<link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Fvm-search-engine%2F&amp;title=VM+Search+Engine" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Fvm-search-engine%2F&amp;title=VM+Search+Engine" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Fvm-search-engine%2F&amp;title=VM+Search+Engine" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Fvm-search-engine%2F&amp;title=VM+Search+Engine', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Fvm-search-engine%2F&amp;t=VM+Search+Engine" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Fvm-search-engine%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Fvm-search-engine%2F&amp;title=VM+Search+Engine" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2012/02/vm-search-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Failed to connect to FreeSWITCH</title>
		<link>http://ontherhoads.org/brad/2012/02/failed-to-connect-to-freeswitch/</link>
		<comments>http://ontherhoads.org/brad/2012/02/failed-to-connect-to-freeswitch/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 23:51:31 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[voip]]></category>
		<category><![CDATA[freeswitch]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=105</guid>
		<description><![CDATA[I&#8217;ve just started working with FreeSWITCH. I&#8217;m using the FreeSWITHCHBOX appliance.
When you start the appliance, FreeSWITCH is normally started automatically. And if you see the following message anywhere, it means that FreeSWITCH did not start. And that probably means that there&#8217;s a mistake in one the config files.
Failed to connect to FreeSWITCH event socket subsystem. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just started working with <a href="http://www.freeswitch.org/">FreeSWITCH</a>. I&#8217;m using the <a href="http://susestudio.com/a/Kr7Ayv/freeswitchbox">FreeSWITHCHBOX</a> appliance.</p>
<p>When you start the appliance, FreeSWITCH is normally started automatically. And if you see the following message anywhere, it means that FreeSWITCH did not start. And that probably means that there&#8217;s a mistake in one the config files.</p>
<p><code>Failed to connect to FreeSWITCH event socket subsystem. Make sure FreeSWITCH is running...</code></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Ffailed-to-connect-to-freeswitch%2F&amp;title=Failed+to+connect+to+FreeSWITCH" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Ffailed-to-connect-to-freeswitch%2F&amp;title=Failed+to+connect+to+FreeSWITCH" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Ffailed-to-connect-to-freeswitch%2F&amp;title=Failed+to+connect+to+FreeSWITCH" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Ffailed-to-connect-to-freeswitch%2F&amp;title=Failed+to+connect+to+FreeSWITCH', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Ffailed-to-connect-to-freeswitch%2F&amp;t=Failed+to+connect+to+FreeSWITCH" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Ffailed-to-connect-to-freeswitch%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2012%2F02%2Ffailed-to-connect-to-freeswitch%2F&amp;title=Failed+to+connect+to+FreeSWITCH" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2012/02/failed-to-connect-to-freeswitch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create A Unique File Name Using A MAC Address</title>
		<link>http://ontherhoads.org/brad/2011/11/create-a-unique-file-name-using-a-mac-address/</link>
		<comments>http://ontherhoads.org/brad/2011/11/create-a-unique-file-name-using-a-mac-address/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 18:04:49 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=102</guid>
		<description><![CDATA[I needed a scheme to generate file names coming from different locations to a central server. The file names are generated in a script and I didn&#8217;t want to have to change the script for different locations. So I decided to include the MAC Address of the machine in the file name.
This little script grabs [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a scheme to generate file names coming from different locations to a central server. The file names are generated in a script and I didn&#8217;t want to have to change the script for different locations. So I decided to include the MAC Address of the machine in the file name.</p>
<p>This little script grabs the address and converts the : characters to a &#8211; and stores there result in a var called MAC.</p>
<p><code><br />
set - `ifconfig | grep -B 1 inet | head -1  | sed -e "s/\:/-/g"`<br />
MAC=$5<br />
</code></p>
<p>So if you run that command then do</p>
<p><code>echo $MAC</code></p>
<p>you&#8217;ll get something like this:</p>
<p><code>00-16-3E-11-09-20</code></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2011%2F11%2Fcreate-a-unique-file-name-using-a-mac-address%2F&amp;title=Create+A+Unique+File+Name+Using+A+MAC+Address" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2011%2F11%2Fcreate-a-unique-file-name-using-a-mac-address%2F&amp;title=Create+A+Unique+File+Name+Using+A+MAC+Address" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2011%2F11%2Fcreate-a-unique-file-name-using-a-mac-address%2F&amp;title=Create+A+Unique+File+Name+Using+A+MAC+Address" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2011%2F11%2Fcreate-a-unique-file-name-using-a-mac-address%2F&amp;title=Create+A+Unique+File+Name+Using+A+MAC+Address', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2011%2F11%2Fcreate-a-unique-file-name-using-a-mac-address%2F&amp;t=Create+A+Unique+File+Name+Using+A+MAC+Address" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2011%2F11%2Fcreate-a-unique-file-name-using-a-mac-address%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2011%2F11%2Fcreate-a-unique-file-name-using-a-mac-address%2F&amp;title=Create+A+Unique+File+Name+Using+A+MAC+Address" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2011/11/create-a-unique-file-name-using-a-mac-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email From My Dad</title>
		<link>http://ontherhoads.org/brad/2010/04/email-from-my-dad/</link>
		<comments>http://ontherhoads.org/brad/2010/04/email-from-my-dad/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 03:55:27 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=100</guid>
		<description><![CDATA[42  years ago tonight a woman was worried that her child might be born before midnight and be stuck with being called an April fool          Can you imagine a woman in labor worrying about such a profound issue?        [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>42  years ago tonight a woman was worried that her child might be born before midnight and be stuck with being called an April fool          Can you imagine a woman in labor worrying about such a profound issue?               She is still missed and loved               Dad</p></blockquote>
<p>I was born at 12:27 AM April 2, 1968</p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2010%2F04%2Femail-from-my-dad%2F&amp;title=Email+From+My+Dad" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2010%2F04%2Femail-from-my-dad%2F&amp;title=Email+From+My+Dad" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2010%2F04%2Femail-from-my-dad%2F&amp;title=Email+From+My+Dad" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2010%2F04%2Femail-from-my-dad%2F&amp;title=Email+From+My+Dad', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2010%2F04%2Femail-from-my-dad%2F&amp;t=Email+From+My+Dad" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2010%2F04%2Femail-from-my-dad%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2010%2F04%2Femail-from-my-dad%2F&amp;title=Email+From+My+Dad" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2010/04/email-from-my-dad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating One-To-Many Records In A Grails Service</title>
		<link>http://ontherhoads.org/brad/2009/11/creating-one-to-many-records-in-a-grails-service/</link>
		<comments>http://ontherhoads.org/brad/2009/11/creating-one-to-many-records-in-a-grails-service/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 06:33:33 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[grails]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=63</guid>
		<description><![CDATA[A parent can have many children. This article explains how to  write a service such that, if after adding a parent there is an error when adding a child, the entire transaction is rolled back. For example, add parent p1, successfully add child c1, then when adding child c2 an error occurs, both p1 [...]]]></description>
			<content:encoded><![CDATA[<p>A parent can have many children. This article explains how to  write a service such that, if after adding a parent there is an error when adding a child, the entire transaction is rolled back. For example, add parent p1, successfully add child c1, then when adding child c2 an error occurs, both p1 and c1 should be rolled back.</p>
<p>Note that this requires Grails 1.2-M4.</p>
<p>Here are the domain objects:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Parent <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">static</span> hasMany <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span> children : Child <span style="color: #66cc66;">&#93;</span>
&nbsp;
<span style="color: #aaaadd; font-weight: bold;">String</span>  name
&nbsp;
<span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
name<span style="color: #66cc66;">&#40;</span>blank:<span style="color: #000000; font-weight: bold;">false</span>,unique:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Child <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">static</span> belongsTo <span style="color: #66cc66;">=</span> Parent
&nbsp;
<span style="color: #aaaadd; font-weight: bold;">String</span> name
&nbsp;
<span style="color: #aaaadd; font-weight: bold;">String</span> pet
&nbsp;
Parent parent
&nbsp;
<span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
name<span style="color: #66cc66;">&#40;</span>blank:<span style="color: #000000; font-weight: bold;">false</span>,unique:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
pet<span style="color: #66cc66;">&#40;</span>blank:<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Now if you do:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">grails generate<span style="color: #66cc66;">-</span>all <span style="color: #66cc66;">*</span></pre></td></tr></table></div>

<p>You&#8217;ll get separate forms that do work. But if we were talking about an invoice application, for example, you&#8217;d really want to have 1 data entry form. That&#8217;s what we do here:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">&nbsp;
<span style="color: #66cc66;">&lt;%</span>@ page contentType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html;charset=UTF-8&quot;</span> <span style="color: #66cc66;">%&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;</span>html<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>head<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>meta http<span style="color: #66cc66;">-</span>equiv<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> content<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>meta name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;layout&quot;</span> content<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main&quot;</span> /<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>title<span style="color: #66cc66;">&gt;</span>Sample title<span style="color: #66cc66;">&lt;</span>/title<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>/head<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>body<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>h1<span style="color: #66cc66;">&gt;</span>Add A Record<span style="color: #66cc66;">&lt;</span>/h1<span style="color: #66cc66;">&gt;</span>
&nbsp;
  <span style="color: #66cc66;">&lt;</span>g:<span style="color: #b1b100;">if</span> test<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${flash.message}&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;message&quot;</span><span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>flash.<span style="color: #006600;">message</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/div<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>/g:if<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>g:<span style="color: #b1b100;">if</span> test<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${flash.errors}&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;errors&quot;</span><span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>ul<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>g:render template<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;renderflasherrors&quot;</span> collection<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${flash.errors}&quot;</span>  <span style="color: #000000; font-weight: bold;">as</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;list&quot;</span>/<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>/ul<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>/div<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>/g:if<span style="color: #66cc66;">&gt;</span>
&nbsp;
&nbsp;
  <span style="color: #66cc66;">&lt;</span>g:form action<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;add&quot;</span> name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;doAdd&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>table<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>tr<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>
          Parent <span style="color: #aaaadd; font-weight: bold;">Name</span>
        <span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>
          Child <span style="color: #aaaadd; font-weight: bold;">Name</span>
        <span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>
          Pet <span style="color: #aaaadd; font-weight: bold;">Name</span>
        <span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>/tr<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>tr<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>
      <span style="color: #808080; font-style: italic;">//&lt;g:textField name=&quot;parentName&quot; value=&quot;${flash.params?.parentName}&quot; /&gt;</span>
       <span style="color: #66cc66;">&lt;</span>g:textField name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;parentName&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${params?.parentName}&quot;</span> /<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>
      <span style="color: #808080; font-style: italic;">//&lt;g:textField name=&quot;childName&quot; value=&quot;${flash.params?.childName}&quot; /&gt;</span>
       <span style="color: #66cc66;">&lt;</span>g:textField name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;childName&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${params?.childName}&quot;</span> /<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>
      <span style="color: #808080; font-style: italic;">//&lt;g:textField name=&quot;petName&quot; value=&quot;${flash.params?.petName}&quot; /&gt;</span>
      <span style="color: #66cc66;">&lt;</span>g:textField name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;petName&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${params?.petName}&quot;</span> /<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>/tr<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>tr<span style="color: #66cc66;">&gt;&lt;</span>td<span style="color: #66cc66;">&gt;&lt;</span>g:submitButton name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;update&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Update&quot;</span> /<span style="color: #66cc66;">&gt;&lt;</span>/td<span style="color: #66cc66;">&gt;&lt;</span>/tr<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>/table<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>/g:form<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>/body<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>/html<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>The tricky part in this was figuring out how to create both records in the controller and return any errors and the entered data back to client. More on that later, but for now just notice lines 13-16 where we render the errors. This is a little different than in the generated forms. There you can check if the object has errors and display them.</p>
<p>But in this example, all of the objects are created in a service, so the .gsp (and the controller) don&#8217;t know anything about the objects. So we end up passing the errors back in a collection flash.errors.</p>
<p>Now look at lines 37, 40 and 43 and compare those to similar lines in the generated forms. There you use a bean to get the value from. But here, we just redisplay the params which contains everything the user originally entered. <del datetime="2009-11-18T06:33:20+00:00">Actually, the params are being stored in flash. For some reason, the form fields end up getting dropped from the params by the time we get back to action:show.</del> </p>
<p>Here&#8217;s the controller:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> AddrecordController <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> addRecordsService
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> index <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        redirect action:<span style="color: #ff0000;">&quot;show&quot;</span>, params:params
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> add <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;do add&quot;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
            addRecordsService.<span style="color: #006600;">addAll</span><span style="color: #66cc66;">&#40;</span>params<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>java.<span style="color: #006600;">lang</span>.<span style="color: #aaaadd; font-weight: bold;">RuntimeException</span> re<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
          <span style="color: #000000; font-weight: bold;">def</span> errorMessages <span style="color: #66cc66;">=</span> re.<span style="color: #006600;">errors</span>.<span style="color: #006600;">allErrors</span>.<span style="color: #663399;">collect</span> <span style="color: #66cc66;">&#123;</span> g.<span style="color: #006600;">message</span><span style="color: #66cc66;">&#40;</span>error:it<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span>
            <span style="color: #993399;">println</span>  errorMessages
            flash.<span style="color: #006600;">message</span> <span style="color: #66cc66;">=</span> g.<span style="color: #006600;">message</span><span style="color: #66cc66;">&#40;</span>code:<span style="color: #ff0000;">&quot;addRecord.save.failed&quot;</span><span style="color: #66cc66;">&#41;</span>
            flash.<span style="color: #006600;">errors</span> <span style="color: #66cc66;">=</span> errorMessages
           <span style="color: #808080; font-style: italic;">//flash.params = params</span>
            <span style="color: #808080; font-style: italic;">//render action:&quot;show&quot;,  params:params</span>
            render view: <span style="color: #ff0000;">&quot;show&quot;</span>, params:params
            <span style="color: #000000; font-weight: bold;">return</span>
        <span style="color: #66cc66;">&#125;</span>
        redirect action:<span style="color: #ff0000;">&quot;show&quot;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> show <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Make sure you render the view not the action and follow it with a return.</p>
<p>If there&#8217;s an error in the service a RunTimeError get&#8217;s thrown. As of Grails 1.2-M4, the exception thrown is a grails.validation.ValidationException, which has the list of errors, so at line 18 we pass each error to a message tag to get the readable messages [1].</p>
<p>Finally, here&#8217;s the service:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> AddRecordsService <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> transactional <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> addAll<span style="color: #66cc66;">&#40;</span>params<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;add all&quot;</span>
        <span style="color: #993399;">println</span> params
        <span style="color: #000000; font-weight: bold;">def</span> Parent theParent <span style="color: #66cc66;">=</span>  addParent<span style="color: #66cc66;">&#40;</span>params.<span style="color: #006600;">parentName</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">def</span> Child theChild   <span style="color: #66cc66;">=</span> addChild<span style="color: #66cc66;">&#40;</span>params.<span style="color: #006600;">childName</span>,params.<span style="color: #006600;">petName</span>,theParent<span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #993399;">println</span> theParent
        <span style="color: #993399;">println</span> theChild
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> addParent<span style="color: #66cc66;">&#40;</span>pName<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;add parent: ${pName}&quot;</span>
        <span style="color: #000000; font-weight: bold;">def</span> theParent <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Parent<span style="color: #66cc66;">&#40;</span>name:pName<span style="color: #66cc66;">&#41;</span>
        theParent.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>failOnError:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> theParent
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> addChild<span style="color: #66cc66;">&#40;</span>cName,pName,Parent theParent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;add child: ${cName}&quot;</span>
        <span style="color: #000000; font-weight: bold;">def</span> theChild <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Child<span style="color: #66cc66;">&#40;</span>name:cName,pet:pName,parent:theParent<span style="color: #66cc66;">&#41;</span>
&nbsp;
       theChild.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>failOnError:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> theChild
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Grails 1.2-M4 added failOnError:true as an option to save(). So now the cause of an error is returned.</p>
<p>Thanks to everyone who answered my questions on this ([1],[2],[3],[4]).</p>
<p><a href="http://old.nabble.com/How-To-Parse-Runttime-Exception-Error-%28GRAILS-5146%29-td26272781.html#a26272781">[1]</a>Re: How To Parse Runttime Exception Error (GRAILS-5146)</p>
<p><a href="http://stackoverflow.com/questions/1628982/how-to-make-transactions-work-in-grails">[2]</a>How To Make Transactions Work In Grails</p>
<p><a href="http://stackoverflow.com/questions/1640666/how-to-know-the-cause-of-a-validation-error">[3]</a>How To Know The Cause Of A Validation Error</p>
<p><a href="http://stackoverflow.com/questions/1646855/render-errors-from-a-service">[4]</a>Render Errors From A Service</p>
<p><a href="http://ontherhoads.org/brad/wp-content/uploads/2009/11/transtest1.zip">Download transtest</a></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F11%2Fcreating-one-to-many-records-in-a-grails-service%2F&amp;title=Creating+One-To-Many+Records+In+A+Grails+Service" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F11%2Fcreating-one-to-many-records-in-a-grails-service%2F&amp;title=Creating+One-To-Many+Records+In+A+Grails+Service" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F11%2Fcreating-one-to-many-records-in-a-grails-service%2F&amp;title=Creating+One-To-Many+Records+In+A+Grails+Service" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F11%2Fcreating-one-to-many-records-in-a-grails-service%2F&amp;title=Creating+One-To-Many+Records+In+A+Grails+Service', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F11%2Fcreating-one-to-many-records-in-a-grails-service%2F&amp;t=Creating+One-To-Many+Records+In+A+Grails+Service" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F11%2Fcreating-one-to-many-records-in-a-grails-service%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F11%2Fcreating-one-to-many-records-in-a-grails-service%2F&amp;title=Creating+One-To-Many+Records+In+A+Grails+Service" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2009/11/creating-one-to-many-records-in-a-grails-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Google Docs For Software Localization</title>
		<link>http://ontherhoads.org/brad/2009/09/using-google-docs-for-software-localization/</link>
		<comments>http://ontherhoads.org/brad/2009/09/using-google-docs-for-software-localization/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 20:59:52 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[I18N]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=58</guid>
		<description><![CDATA[Google provides some truly amazing automatic translation tools.  And now translation is included in Google Docs. This turns out to be a powerful tool for software localization.
My current and probably long-term favorite development environment is Grails. Grails has great localization support build into it. An important piece of that is the messages.properties file, where [...]]]></description>
			<content:encoded><![CDATA[<p>Google provides some truly amazing <a href="http://translate.google.com/translate_tools?hl=en">automatic translation tools</a>.  And now translation is included in Google Docs. This turns out to be a powerful tool for software localization.</p>
<p>My current and probably long-term favorite development environment is Grails. Grails has great localization support build into it. An important piece of that is the <code>messages.properties</code> file, where you store all of your values that you want to be localized. </p>
<p>Actually, there can be lots of properties files. Grails actually ships with:</p>
<ul>
<li><code>messages_de.properties</code></li>
<li><code>messages_es.properties</code></li>
<li><code>messages_fr.properties</code></li>
<li><code>messages_it.properties</code></li>
<li><code>messages_ja.properties</code></li>
<li><code>messages_nl.properties</code></li>
<li><code>messages_pt_BR.properties</code></li>
<li><code>messages_ru.properties</code></li>
<li><code>messages_th.properties</code></li>
<li><code>messages_zh_CN.properties</code></li>
</ul>
<p>For example, <code>messages_fr.properties</code> is for French. </p>
<p>All the base files have translations of commonly used words. As you add more functionality to your application, you of course need more labels and buttons, etc. So you add them to your messages.properties file. Then all you have to do is translate your file into all these and other languages. The good news is that you can use Google Docs to get the job done. Or at least give you a head start on the translation process.</p>
<p>Just load your properties file into Google Docs and select Tools|Translate. <div id="attachment_59" class="wp-caption alignleft" style="width: 310px"><a href="http://ontherhoads.org/brad/wp-content/uploads/2009/09/translate.png"><img src="http://ontherhoads.org/brad/wp-content/uploads/2009/09/translate-300x123.png" alt="translate" title="translate" width="300" height="123" class="size-medium wp-image-59" /></a><p class="wp-caption-text">translate</p></div></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F09%2Fusing-google-docs-for-software-localization%2F&amp;title=Using+Google+Docs+For+Software+Localization" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F09%2Fusing-google-docs-for-software-localization%2F&amp;title=Using+Google+Docs+For+Software+Localization" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F09%2Fusing-google-docs-for-software-localization%2F&amp;title=Using+Google+Docs+For+Software+Localization" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F09%2Fusing-google-docs-for-software-localization%2F&amp;title=Using+Google+Docs+For+Software+Localization', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F09%2Fusing-google-docs-for-software-localization%2F&amp;t=Using+Google+Docs+For+Software+Localization" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F09%2Fusing-google-docs-for-software-localization%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F09%2Fusing-google-docs-for-software-localization%2F&amp;title=Using+Google+Docs+For+Software+Localization" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2009/09/using-google-docs-for-software-localization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling A Service From The Grails Console</title>
		<link>http://ontherhoads.org/brad/2009/08/calling-a-service-from-the-grails-console/</link>
		<comments>http://ontherhoads.org/brad/2009/08/calling-a-service-from-the-grails-console/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 07:47:05 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=54</guid>
		<description><![CDATA[I&#8217;m doing my first project in Grails and intend to blog some of thing things I&#8217;m learning.
During development, the grails console is very useful for testing specific pieces of code without having to go through your whole system to get to that particular bit of code.
For the most part, you can just enter grails commands [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m doing my first project in Grails and intend to blog some of thing things I&#8217;m learning.</p>
<p>During development, the grails console is very useful for testing specific pieces of code without having to go through your whole system to get to that particular bit of code.</p>
<p>For the most part, you can just enter grails commands and hit execute. But apparently dependency inject doesn&#8217;t happen in the console. So there&#8217;s a bit of a trick to execute a service from the console.</p>
<p>If you had a service named MySecretService with a function named secretSquirell, you could access it via dependency injection in a domain class, a controller or another service by first adding</p>
<p><code>def mySecretService</code></p>
<p>then later you can say<br />
<code>def result = mySecretService.secretSquirell()</code></p>
<p>But to test in the console you need to do this:</p>
<p><code>def service = ctx.getBean("mySecretService")</code><br />
<code>def result = service.secretSquirell()</code></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;t=Calling+A+Service+From+The+Grails+Console" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F08%2Fcalling-a-service-from-the-grails-console%2F&amp;title=Calling+A+Service+From+The+Grails+Console" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2009/08/calling-a-service-from-the-grails-console/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easter PowerPoint</title>
		<link>http://ontherhoads.org/brad/2009/04/easter-powerpoint/</link>
		<comments>http://ontherhoads.org/brad/2009/04/easter-powerpoint/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 21:35:51 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=44</guid>
		<description><![CDATA[how-the-risen-christ-can-make-a-difference
Easter Presentation &#8211; Power Point 97-2003 format




















]]></description>
			<content:encoded><![CDATA[<p><a href="http://ontherhoads.org/brad/wp-content/uploads/2009/04/how-the-risen-christ-can-make-a-difference.pptx">how-the-risen-christ-can-make-a-difference</a></p>
<p><a href="http://ontherhoads.org/brad/wp-content/uploads/2009/04/how-the-risen-christ-can-make-a-difference.ppt">Easter Presentation &#8211; Power Point 97-2003 format</a></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F04%2Feaster-powerpoint%2F&amp;title=Easter+PowerPoint" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F04%2Feaster-powerpoint%2F&amp;title=Easter+PowerPoint" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F04%2Feaster-powerpoint%2F&amp;title=Easter+PowerPoint" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F04%2Feaster-powerpoint%2F&amp;title=Easter+PowerPoint', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F04%2Feaster-powerpoint%2F&amp;t=Easter+PowerPoint" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F04%2Feaster-powerpoint%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F04%2Feaster-powerpoint%2F&amp;title=Easter+PowerPoint" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2009/04/easter-powerpoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problem Files</title>
		<link>http://ontherhoads.org/brad/2009/03/problem-files/</link>
		<comments>http://ontherhoads.org/brad/2009/03/problem-files/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 21:53:29 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ministry partnership]]></category>

		<guid isPermaLink="false">http://ontherhoads.org/brad/?p=36</guid>
		<description><![CDATA[Just a couple of files I needed to make available.
stewardship
think




















]]></description>
			<content:encoded><![CDATA[<p>Just a couple of files I needed to make available.</p>
<p><a rel="attachment wp-att-34" href="http://ontherhoads.org/brad/?attachment_id=34"></a><a href="http://ontherhoads.org/brad/wp-content/uploads/2009/03/stewardship.swf">stewardship</a></p>
<p><a rel="attachment wp-att-35" href="http://ontherhoads.org/brad/?attachment_id=35"><a href="http://ontherhoads.org/brad/wp-content/uploads/2009/03/think.swf">think</a></a></p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->


<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F03%2Fproblem-files%2F&amp;title=Problem+Files" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F03%2Fproblem-files%2F&amp;title=Problem+Files" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F03%2Fproblem-files%2F&amp;title=Problem+Files" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F03%2Fproblem-files%2F&amp;title=Problem+Files', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F03%2Fproblem-files%2F&amp;t=Problem+Files" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F03%2Fproblem-files%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fontherhoads.org%2Fbrad%2F2009%2F03%2Fproblem-files%2F&amp;title=Problem+Files" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://ontherhoads.org/brad/2009/03/problem-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

