<?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>let x=x &#187; opensource</title>
	<atom:link href="http://www.crazymcphee.net/x/tag/opensource/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crazymcphee.net/x</link>
	<description>programming idiom and methodology</description>
	<lastBuildDate>Tue, 13 Jul 2010 21:56:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Money-is-Money 0.17</title>
		<link>http://www.crazymcphee.net/x/2009/12/04/money-is-money-0-17/</link>
		<comments>http://www.crazymcphee.net/x/2009/12/04/money-is-money-0-17/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 08:52:12 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[money-is-money]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=498</guid>
		<description><![CDATA[I just released a new version of Money-Is-Money, v0.17. If you&#8217;re interested, see the features here and here. My aim with it is to make the most accurate currency-aware Java money handling library available. This time I&#8217;ve added just a couple of new methods to get the whole and fractional amounts as Integers (I use [...]]]></description>
			<content:encoded><![CDATA[<p>I just released a new version of Money-Is-Money, v0.17. If you&#8217;re interested, see the features <a href="http://www.crazymcphee.net/x/2009/04/17/money-is-money-v016/">here</a> and <a href="http://www.crazymcphee.net/x/2009/04/17/money-is-money-v015-with-added-maven-repository/">here</a>. My aim with it is to make the most accurate currency-aware Java money handling library available. This time I&#8217;ve added just a couple of new methods to get the whole and fractional amounts as Integers (I use throughout BigDecimal and BigInteger to represent amounts, to avoid the fatal floating point errors).</p>
<p>To include it into your Maven POM you&#8217;ll have to add my repository to a profile in your settings.xml:</p>
<pre class="code" lang="xml">&lt;repositories&gt;
  &lt;repository&gt;
    &lt;id&gt;crazy-mcphee&lt;/id&gt;
    &lt;url&gt;http://modular.autonomous.org:80/artifactory-2.0.5/libs-releases-local&lt;/url&gt;
    &lt;snapshots&gt;
      &lt;enabled&gt;false&lt;/enabled&gt;
    &lt;/snapshots&gt;
    &lt;releases&gt;
      &lt;enabled&gt;true&lt;/enabled&gt;
    &lt;/releases&gt;
  &lt;/repository&gt;
&lt;/repositories&gt;</pre>
<p>At which point you can include the dependency in your pom.xml for your project:</p>
<pre class="code" lang="xml">&lt;dependency&gt;
  &lt;groupId&gt;org.autonomous&lt;/groupId&gt;
  &lt;artifactId&gt;money-is-money&lt;/artifactId&gt;
  &lt;version&gt;0.17&lt;/version&gt;
&lt;/dependency&gt;</pre>
<p>If you want to check the source code out with SVN the release is at <em>http://crazymcphee.net/svn/money/tags/money-is-money-0.17</em> and the latest trunk at <em>http://crazymcphee.net/svn/money/trunk</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/12/04/money-is-money-0-17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Out of the box experience</title>
		<link>http://www.crazymcphee.net/x/2009/10/06/out-of-the-box-experience/</link>
		<comments>http://www.crazymcphee.net/x/2009/10/06/out-of-the-box-experience/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 03:44:47 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[profession]]></category>
		<category><![CDATA[wizards considered harmful]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=483</guid>
		<description><![CDATA[Every now and again we get some customers who expect that they can get a custom website, portal, or services integration done by looking at a vendor&#8217;s &#8220;out of the box&#8221; experience. This can be very frustrating for us, as we need to get into their heads that no platform will delivery any website, portal, [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and again we get some customers who expect that they can get a custom website, portal, or services integration done by looking at a vendor&#8217;s &#8220;out of the box&#8221; experience. This can be very frustrating for us, as we need to get into their heads that no platform will delivery any website, portal, or integration &#8220;out of the box&#8221;. I classify this as a species of magical thinking.  This sort of thinking is so persuasive among many IT systems users that they will spend $500,000 on the infrastructure and $50,000 on the development effort. They are often shocked to discover that to get all the features they demand &#8211; even when those features can be delivered trivially from the chosen platform, costs time (and therefore money) often to the equivalent value of the software licensing. The &#8220;out of the box&#8221; approach can deliver excellent results in terms of a single-point-system, let&#8217;s say a CRM (e.g. sign up for a Salesforce account) but they don&#8217;t see to integrate that CRM into their custom warehousing system (for example) and linking all of that into a comprehensive product website involves completely customised software development. Every website, portal or integration scenario is custom &#8211; always. Unless it is somehow the case that you don&#8217;t mind that your website is the default &#8220;Welcome to Apache Tomcat&#8221; page.</p>
<p>In recent times I&#8217;ve seen this often enough that I think it&#8217;s really a failing of the IT industry in general, and we need to educate business IT users about the various scenarios and categories of software.</p>
<p>The simplest analogy I can think of is to say the website or portal is the letter, and the platform is the word processor.  Regardless if you use Word, Wordperfect, Pages 09, your email program or just plain old &#8216;notepad.exe&#8217;, at the end of the day the time to write the letter is pretty much the same effort and therefore the task is basically identical. If you said &#8220;I want you to help me to write a letter to my member of parliament&#8221;, should  I ask you whether you&#8217;re using the new letter wizard in Word? Have you seen this great &#8220;clippy&#8221; feature? Have you considered the new upgrade to Office 2007? Tell you to buy a Mac? Or would I be better off asking who is your member of parliament and what&#8217;s the matter about? When we get these sorts of naive clients we need to concentrate their minds on what their actual problem is and the best way we can solve it, when they&#8217;ve got their head in the sand thinking about that great drag-and-drop wizard feature the vendor showed them they totally thinking about the completely wrong thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/10/06/out-of-the-box-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tapestry 5 web framework</title>
		<link>http://www.crazymcphee.net/x/2009/08/26/tapestry-5-web-framework/</link>
		<comments>http://www.crazymcphee.net/x/2009/08/26/tapestry-5-web-framework/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 12:09:18 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[tapestry]]></category>
		<category><![CDATA[tapestry5]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web framework]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=443</guid>
		<description><![CDATA[Lately I&#8217;ve been writing a Tapestry 5 based web application. I&#8217;ve used it before for a smaller application but this is the first time I&#8217;ve used it on a larger project. In a number of ways it is a very powerful framework to write web applications. The basics of Tapestry is that it is a [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been writing a <a href="http://tapestry.apache.org/tapestry5/" target="_blank">Tapestry 5</a> based web application. I&#8217;ve used it before for a smaller application but this is the first time I&#8217;ve used it on a larger project. In a number of ways it is a very powerful framework to write web applications.</p>
<p>The basics of Tapestry is that it is a component-based web framework. Just about everything, including web pages, are components. Components may contain other components. The way it works is very simple and quite elegant, once you get used to it and weaned off the big-XML-file style of configuring a web application.</p>
<p>When you start, you have two main Java packages that are created for you (if you use the maven archetype, otherwise you will create these packages yourself). If your package root is say &#8220;net.crazymcphee.webapp&#8221;, then your two packages are &#8220;net.crazymcphee.webapp.pages&#8221; and &#8220;net.crazymcphee.webapp.components&#8221;. To configure a Tapestry 5 project with maven <a href="http://tapestry.apache.org/tapestry5/quickstart/">use this command</a> and answer the prompts:</p>
<pre>mvn archetype:generate \</pre>
<pre>    -DarchetypeCatalog=http://tapestry.formos.com/maven-snapshot-repository</pre>
<p>Don&#8217;t use the one in the <a href="http://tapestry.apache.org/tapestry5/tutorial1/first.html">tutorial</a> as it will not work! This is an excellent illustration of the first and most serious problem that Tapestry 5 has: the documentation not only has massive lacunas, it is also sometimes wrong and not updated.</p>
<p>Now, any class that you create in the &#8220;pages&#8221; package will automatically become a page in your application. But these classes need not be very complex at all. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">net.crazymcphee.webapp.pages</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.tapestry5.annotations.Persist</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.tapestry5.annotations.Property</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.tapestry5.ioc.annotations.Inject</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.crazymcphee.webapp.model.Person</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.crazymcphee.webapp.services.PersonService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Persons <span style="color: #009900;">&#123;</span>
&nbsp;
    @Inject
    <span style="color: #000000; font-weight: bold;">private</span> PersonService personService<span style="color: #339933;">;</span>
    @Property
    @Persist
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">List</span> persons<span style="color: #339933;">;</span>
    @Property
    @Persist
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> searchTerm<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">Object</span> onSubmitFromSearch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        persons <span style="color: #339933;">=</span> personService.<span style="color: #006633;">findPersons</span><span style="color: #009900;">&#40;</span>searchTerm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #003399;">Object</span> onSubmitFromClear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        persons <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">EMPTY_LIST</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can see that this class doesn&#8217;t extend any infrastructure classes and has quite a simple structure. This is a fully functional page with two actions &#8211; one populates a list, the other clears it.</p>
<p>Now, to explain just a little here; PersonService is injected by Tapestry, but you need to configure in your AppModule which implementation you want to use. You can also use it with Spring as your IOC container but the one that comes with Tapestry is perfectly good enough for most applications.</p>
<p>The List, persons, and the searchTerm parameters are marked as @Property (so we don&#8217;t need to add getters and setters) and also @Persist so that the variables are preserved from request to request.</p>
<p>The methods &#8220;onSubmitFromSearch&#8221; and &#8220;onSubmitFromClear&#8221; are using a convention &#8211; &#8220;onSubmit&#8221; will also work, but assuming (as is true in this case) that we may have multiple forms on the one page, each method will only be fired from the &#8220;search&#8221; form in one instance, and the &#8220;clear&#8221; form in the other. These names are not special, it&#8217;s just (as you&#8217;ll see below) the forms will have these two names. They could be &#8220;Bill&#8221; and &#8220;Ben&#8221; in which case the methods would be &#8220;onSubmitFromBill&#8221; and &#8220;onSubmitFromBen&#8221;.</p>
<p>You will also note that these methods return the same page instance, which tells Tapestry to re-render the same page, but if you wanted to forward onto another page, you would add a instance variable, mark it with an @InjectPage annotation, and return that instance variable (after initialising it in your &#8220;onSubmit&#8221; method) instead of just returning &#8220;this&#8221;.</p>
<p>This page Persons, is available at {application-context-path}/persons. But there is one other part of the puzzle &#8211; the actual view. As mentioned, Tapestry uses convention over configuration and in this case, the convention is that the Page markup must be named the same: Persons.tml. Here is the matching tml file for the class above;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">html</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:type</span><span style="color: #000000;">=</span>&#8220;layout&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">title</span><span style="color: #000000;">=</span>&#8220;Peoples I Might Know&#8221;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #7f007f;"><span style="color: #000000;"> </span>t:sidebarTitle<span style="color: #000000;">=</span><span style="color: #2a00ff;">&#8220;Current Time&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #7f007f;">xmlns:t</span><span style="color: #000000;">=</span>&#8220;http://tapestry.apache.org/schema/tapestry_5_1_0.xsd&#8221;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #7f007f;">xmlns:p</span><span style="color: #000000;">=</span>&#8220;tapestry:parameter&#8221;<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f5fbf;">&lt;!&#8211; Most of the page content, including &lt;head&gt;, &lt;body&gt;, etc. tags, comes from Layout.tml &#8211;&gt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:form</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;search&#8221;<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:textfield</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;searchTerm&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">validate</span><span style="color: #000000;">=</span>&#8220;required&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">size</span><span style="color: #000000;">=</span>&#8220;20&#8243;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:submit</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;searchPeople&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">value</span><span style="color: #000000;">=</span>&#8220;search&#8221;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f7f7f;"><span style="color: #008080;">&lt;/</span>t:form<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:grid</span><span style="color: #000000;"> </span><span style="color: #7f007f;">source</span><span style="color: #000000;">=</span>&#8220;persons&#8221;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:form</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;clear&#8221;<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #2a00ff;"><span style="color: #000000;"> </span><span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:submit</span><span style="color: #000000;"> </span><span style="color: #7f007f;">t:id</span><span style="color: #000000;">=</span>&#8220;clearPeople&#8221;<span style="color: #000000;"> </span><span style="color: #7f007f;">value</span><span style="color: #000000;">=</span>&#8220;clear&#8221;<span style="color: #008080;">/&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f7f7f;"><span style="color: #008080;">&lt;/</span>t:form<span style="color: #008080;">&gt;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; min-height: 14.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Andale Mono; color: #3f7f7f;"><span style="color: #008080;">&lt;/</span>html<span style="color: #008080;">&gt;</span></p>
<p>Yes, it&#8217;s that bloody simple. The first form fires the &#8220;onSubmitFromSearch&#8221; method (with a little bit of validation, done in javascript) and the second method clears the list. In-between, there is this <span style="color: #008080;">&lt;</span><span style="color: #3f7f7f;">t:grid</span><span style="color: #000000;"> </span><span style="color: #7f007f;">source</span><span style="color: #000000;">=</span>&#8220;persons&#8221;<span style="color: #008080;">/&gt; <span style="color: #000000;">business, which, if the &#8216;persons&#8217; variable in the page class is populated, will show a list of its contents! </span></span></p>
<p>To test our app, we can use the command-line &#8216;mvn clean jetty:run&#8217;. When Jetty has run up, then we can point our browser at the web app: http://localhost:8080/sample-webapp/Persons, and with any luck we will see the following:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-1.png"><img style="border: 0px initial initial;" title="Initial View" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-1-300x171.png" alt="Initial View" width="300" height="171" /></a></p>
<p>Now, by default, Tapestry creates the web app to use the template design as shown above. Of course, you can make it look completely some other way &#8211; or even use a totally different template if you want. The page template is just a component that&#8217;s included.</p>
<p>So if you enter in a search term and click the search button, you&#8217;d expect to see a result like this:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-2.png"><img class="alignnone size-medium wp-image-452" title="Search Result" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-2-300x174.png" alt="Search Result" width="300" height="174" /></a></p>
<p>As you can see, the list is automatically populated with the details returned from the service method (in this particular instance, this are just a canned response, but normally of course they&#8217;d be the result of a database or a web service call of some type).</p>
<p>When you click the clear button, the list is cleared as you&#8217;d expect:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-3.png"><img class="alignnone size-medium wp-image-453" title="Clear button result" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-3-300x175.png" alt="Clear button result" width="300" height="175" /></a></p>
<p>Now, here&#8217;s a really powerful feature I find in Tapestry. Let&#8217;s say our automated acceptance tests assert that when the &#8216;Clear&#8217; button is pressed, the Search box as well as the persons list is cleared. What Tapestry allows us to to do, is keep Jetty running, edit the files in the IDE, and re-run the tests against the running app without restarting! We edit our method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #003399;">Object</span> onSubmitFromClear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        persons <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">EMPTY_LIST</span><span style="color: #339933;">;</span>
        searchTerm<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this case I&#8217;ve also added a bit of space around the clear button in the template as well:</p>
<p><a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-4.png"><img class="alignnone size-medium wp-image-454" title="Picture 4" src="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/Picture-4-300x175.png" alt="Picture 4" width="300" height="175" /></a></p>
<p>And now our failing test will pass.</p>
<p>Editing files like this in the running web app only works for Pages and I think Components. If I had to change the service or model classes I&#8217;d have to restart, but &#8220;mvn jetty:run&#8221; isn&#8217;t very a heavyweight process.</p>
<p>As I said above, Tapestry&#8217;s not perfect: it&#8217;s major flaw is the poor documentation. Convention-over-configuration is easy to grok &#8211; if you know the convention. If you don&#8217;t and the documentation doesn&#8217;t tell you, and you can&#8217;t find a sample of what you need, it can be very frustrating. There is an excellent user list though.</p>
<p>Its other major flaw may be the stability of the API. Tapestry 5 is different (and incompatible) from Tapestry 4 is different from Tapestry 3. But so far I&#8217;ve used it on a couple of projects and I&#8217;m really enjoying it. I really hate the oodles of XML boilerplate and massive amounts of configuration found in Spring and I find myself somewhat reluctant to use it unless I really have to. Tapestry solves for me a range of different problems and mostly it presents a very elegant way to create a componentised web application. You might like to give it a try.</p>
<p>Attached is the sample code used above. It took me about 10 minutes to write (far shorter than it took me to write this blog entry!) - <a href="http://www.crazymcphee.net/x/wp-content/uploads/2009/08/sample-webapp.tar.gz">sample-webapp.tar bundle</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/08/26/tapestry-5-web-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Money-is-Money v0.16</title>
		<link>http://www.crazymcphee.net/x/2009/04/17/money-is-money-v016/</link>
		<comments>http://www.crazymcphee.net/x/2009/04/17/money-is-money-v016/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 13:56:59 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=327</guid>
		<description><![CDATA[Putting money-is-money into my own Maven repository gave the impetus to me to clean up the actual code base of the library. There are now a grand total of three classes, including an interface, which is much reduced. As anyone who knows me, will know that I think this is a great improvement. See this [...]]]></description>
			<content:encoded><![CDATA[<p>Putting money-is-money into my own <a title="v0.15 with maven repository" href="http://www.crazymcphee.net/x/2009/04/17/money-is-money-v015-with-added-maven-repository/" target="_self">Maven repository</a> gave the impetus to me to clean up the actual code base of the library. There are now a grand total of <em>three</em> classes, including an interface, which is <em>much</em> reduced. As anyone who knows me, will know that I think this is a great improvement. See <a href="http://www.crazymcphee.net/x/2009/04/17/money-is-money-v015-with-added-maven-repository/" target="_self">this post </a>- also linked in the first sentence above &#8211; to learn the details of the Maven repository and how and where to get the source code check out.</p>
<p>You can manually browse the artefacts in the repository <a href="http://modular.autonomous.org/artifactory-2.0.5/libs-releases-local/org/autonomous/money-is-money/0.16/">here</a>.</p>
<p>Here&#8217;s the updated README:</p>
<blockquote><p>This package is copyright 2008-2009 Scot Mcphee.</p>
<p>Email: scot.mcphee at gmail.com</p>
<p>Licence is the M.I.T. Licence. Please see the file &#8220;LICENCE&#8221;.</p>
<p>WHAT IS Money-Is-Money?</p>
<p>Money-Is-Money is a library for the correct manipulation of monetary data. I wrote this small library because I found that there were not any available public source Money implementations, despite some Time-based libraries promising such (I guess Time is more interesting to programmers than filthy lucre).</p>
<p>It consists primarily of an interface, called &#8216;Money&#8217;, and a Factory for making money, called &#8216;MoneyMaker&#8217;. There is a single implementation classes, MoneyAmount.</p>
<p>Money uses BigDecimal throughout to represent values. Yes, that&#8217;s a java.math.BigDecimal. If you whine about wanting to use doubles and floats congratulations! You are the target audience and therefore you should *really* be using this library and I won&#8217;t go into debate here why it&#8217;s wrong to use floating point logic in  Money implementations.</p>
<p>Money is designed to be an immutable object. All operations on Money, such as Money.add(Money) returns a new instance of Money representing the added amounts. There are operations for add, subtract, divide, and multiply. The default rounding mode is HALF_EVEN or &#8216;bankers rounding&#8217;. If a value comes out to 0.5, it is rounded to the EVEN value, so $3.555 at  a precision of 2 decimal places becomes 3.56, and so does $3.565. Divide and multiply also include methods to perform those operations with a user-specified rounding mode. There are also methods to do high-precision &#8220;no rounding&#8221; division and multiplication (dividePrecise and multiplyPrecise), which will throw an ArithmeticException if the decimals cannot be terminated and therefore have no decimal representation, e.g. 10/3, so be careful in using it.</p>
<p>There is also two methods to &#8216;proRate&#8217; money. The first takes the existing money and divides it up as equally as possible into the number of buckets you specify, with the modulo distributed in as small as increments as possible across as many of the buckets as possible.</p>
<p>This is NOT THE SAME as dividing by the number you specify. So $10.00 divided into 3 buckets results in buckets containing $3.34, $3.33, $3.33. The specification is that adding the buckets back up should always result in the original amount without any rounding errors. You should be able to pro rate an amount, then pro rate those amounts, recursively many many times and adding up all the &#8216;leaf&#8217; values will result in EXACTLY the original amount.</p>
<p>There is an additional method of &#8216;proRate&#8217;. That is the weighted pro-rate, proRateWeighted. It allows you divide a money amount into a number of buckets with each amount weighted according to a value in an array. E.g. an array of {1, 2} divides the amount into 2 buckets, the first one having 1/3 of the amount, the second 2/3. This can get much more complex than that simple example, e.g. consider $54 divided by the weights {1, 1, 2, 3, 5, 8, 13, 21}. Well in that case I am cheating because the amounts returned would be {1, 1, 2, 3, 5, 8, 13, 21}, but consider some random amount, let&#8217;s say  $9824516.53 divided by that same array of weightings. The weightings have to be obeyed and the numbers  must all add up at the end. This implementation was supplied by my friend and former colleague Tim Eagles and refined a little by myself.</p>
<p>The current implementations of both the &#8216;proRate&#8217; methods take the remainder <em>R</em> and distribute it amongst the *first* <em>R</em> elements of the (weighted or un-weighted) buckets. Thus, the earliest elements may be out by 1 cent (or 1 whole Yen) compared to a straight floating point division of value divided by number of buckets.</p>
<p>If you find this library at all useful, or have improvements and suggestions, drop me a line at scot.mcphee@gmail.com</p>
<p>Please remember to shake your MoneyMaker.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/04/17/money-is-money-v016/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Money-Is-Money v0.15 with added maven repository</title>
		<link>http://www.crazymcphee.net/x/2009/04/17/money-is-money-v015-with-added-maven-repository/</link>
		<comments>http://www.crazymcphee.net/x/2009/04/17/money-is-money-v015-with-added-maven-repository/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 06:54:17 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=322</guid>
		<description><![CDATA[In the course of an assignment for a client I&#8217;ve been giving Artifactory a good going-over. Artifactory is a Maven repository and mirror and is pretty cool and easy to set up &#8211; just drop the WAR file into a running Tomcat instance. On my Mac I ran it under Tomcat 6.0.18 with Java 5, [...]]]></description>
			<content:encoded><![CDATA[<p>In the course of an assignment for a client I&#8217;ve been giving <a title="Artifactory website" href="http://www.jfrog.org/products.php" target="_blank">Artifactory</a> a good going-over. Artifactory is a Maven repository and mirror and is pretty cool and easy to set up &#8211; just drop the WAR file into a running Tomcat instance. On my Mac I ran it under Tomcat 6.0.18 with Java 5, and on my personal Linux box (Ubuntu) I ran it with Tomcat 5.5 and Java 6. All is pretty sweet and it is fairly trivial to get Maven set up to use it. It&#8217;s just a matter of overriding the &#8216;central&#8217; repository in your <em>~/.m2/settings.xml</em> to point to you new local copy &#8211; by default it mirrors several useful repositories as well as the default one. Adding security (such as public read-only access and username/password for deployment of artefacts) takes only a few minutes on top of that.</p>
<p>In the course of all this testing though I thought it best to use it in something like real anger with the Maven release plugin rather than my rather artificial usage scenario I was building up between my two development machines.</p>
<p>As a result of all that I&#8217;ve released a version of my Monetary library, money-is-money. The version is 0.15 and the Maven repository for it can be found at <a title="Maven respoitory" href="http://modular.autonomous.org:80/artifactory-2.0.5/libs-releases-local/">http://modular.autonomous.org:80/artifactory-2.0.5/libs-releases-local</a></p>
<p>If you want to check the source code out with SVN out the release is at <em>http://crazymcphee.net/svn/money/tags/money-is-money-0.15</em> and the latest trunk at <em>http://crazymcphee.net/svn/money/trunk</em> (which at the time of writing is the same as the release of course, except it generates 0.16-SNAPSHOT).</p>
<p>To include it into your Maven POM you&#8217;ll have to add my respository to a profile in your settings.xml:</p>
<pre class="code" lang="xml">&lt;repositories&gt;
  &lt;repository&gt;
    &lt;id&gt;crazy-mcphee&lt;/id&gt;
    &lt;url&gt;http://modular.autonomous.org:80/artifactory-2.0.5/libs-releases-local&lt;/url&gt;
    &lt;snapshots&gt;
      &lt;enabled&gt;false&lt;/enabled&gt;
    &lt;/snapshots&gt;
    &lt;releases&gt;
      &lt;enabled&gt;true&lt;/enabled&gt;
    &lt;/releases&gt;
  &lt;/repository&gt;
&lt;/repositories&gt;</pre>
<p>At which point you can include the dependency in your pom.xml for your project:</p>
<pre class="code" lang="xml">&lt;dependency&gt;
  &lt;groupId&gt;org.autonomous&lt;/groupId&gt;
  &lt;artifactId&gt;money-is-money&lt;/artifactId&gt;
  &lt;version&gt;0.15&lt;/version&gt;
&lt;/dependency&gt;</pre>
<p>After that Maven should fetch the artifact from my repository automatically for you. Money-Is-Money is deliberately designed to void any external dependencies on anything other than Java libs, except for JUnit which only matters if you want to build from source. For more information please see <a href="http://www.crazymcphee.net/x/2009/02/11/money-is-money/" target="_self">this post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/04/17/money-is-money-v015-with-added-maven-repository/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Money Is Money v 0.14</title>
		<link>http://www.crazymcphee.net/x/2009/02/11/money-is-money/</link>
		<comments>http://www.crazymcphee.net/x/2009/02/11/money-is-money/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 06:01:58 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[tools and techniques]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=152</guid>
		<description><![CDATA[I&#8217;ve made a modest &#8211; very modest &#8211; library for dealing with Monetary amounts. IMHO something like this should be inside Java, to stop all those idiots using floating point logic to calculate money amounts. My library uses exactly NO EXTERNAL DEPENDENCIES apart from what&#8217;s already in Java 5 and Junit 3.8.1 for tests, which [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made a modest &#8211; <em>very</em> modest &#8211; library for dealing with Monetary amounts. IMHO something like this should be inside Java, to stop all those idiots using floating point logic to calculate money amounts. My library uses exactly <em>NO EXTERNAL DEPENDENCIES</em> apart from what&#8217;s already in Java 5 and Junit 3.8.1 for tests, which were by and large, all written first. It&#8217;s release with the MIT Licence, so you can use it freely as long as you include the copyright notices.</p>
<p>It&#8217;s still a work in progress. You can check it out with SVN from <a title="Money Is Money" href="http://crazymcphee.net/svn/money/trunk/" target="_self">http://crazymcphee.net/svn/money/trunk/</a></p>
<p>From the README:</p>
<blockquote><p>This package is copyright 2008-2009 Scot Mcphee.</p>
<p>Licence is the M.I.T. Licence. Please see the file &#8220;LICENCE&#8221;.</p>
<p>WHAT IS Money-Is-Money?</p>
<p>Money-Is-Money is a library for the correct manipulation of monetary data. I wrote this small library because I found that there were not any available public source Money implementations, despite some Time-based libraries promising such (I guess Time is more interesting to programmers than filthy lucre).</p>
<p>It consists primarily of an interface, called &#8216;Money&#8217;, and a Factory for making money, called &#8216;MoneyMaker&#8217;.  There are a number of implementation classes, primarily CashMoney and  PrecisionMoney. They both share a abstract implementation, AbstractMoney. For the time being. I can see ways to eliminating both and just having a single implementation of the Money interface, but I haven&#8217;t done it yet.</p>
<p>However, for the time being, CashMoney is used whenever MoneyMaker is given a Currency (that&#8217;s java.util.Currency)  which has a default scale less than the given BigDecimal&#8217;s scale. Yes, that&#8217;s a java.math.BigDecimal. If you whine  about wanting to use doubles and floats congratulations! you are the target audience and therefore you should *really* be using this library and I won&#8217;t go into debate here why it&#8217;s wrong to use floating point logic in  Money<br />
implementations.</p>
<p>Money is designed to be an immutable object. All operations on Money, such as Money.add(Money) returns a new instance  of Money representing the added amounts. There are operations for add, subtract, divide, and multiply. The default rounding mode is HALF_EVEN or &#8216;bankers rounding&#8217;. If a value comes out to 0.5, it is rounded to the EVEN value,  so $3.555 at  a precision of 2 decimal places becomes 3.56, and so does $3.565. Divide and multiply also include methods to perform those operations with a specified rounding mode.</p>
<p>There is also a method &#8216;proRate&#8217;. This takes the existing money and divides it up into the number of buckets you  specify, with the modulo distributed in as small as increments as possible across as money of the buckets as possible. This is NOT THE SAME as dividing by the number you specify. So $10.00 divided into 3 buckets results in buckets containing $3.34, $3.33, $3.33. The specification is, adding the buckets back up should always result in the original amount without any rounding errors. You should be able to pro rate an amount, then pro rate those amounts, recursively many many times and adding up all the values will result in EXACTLY the original amount.</p>
<p>If you find this library at all useful, or have improvements and suggestions, drop me a line at scot dot mcphee at gmail dot com</p>
<p>Please remember to shake your MoneyMaker.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/02/11/money-is-money/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open source and profits</title>
		<link>http://www.crazymcphee.net/x/2009/01/29/open-source-and-profits/</link>
		<comments>http://www.crazymcphee.net/x/2009/01/29/open-source-and-profits/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 05:30:28 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[infrastructure and frameworks]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=108</guid>
		<description><![CDATA[Sun&#8217;s sales topped estimates, according to Bloomberg, and this was all thanks to its open source software strategy, according to Matt Asay at CNET: Sun Microsystems is getting some love from Wall Street after its sales and earnings topped estimates, as detailed by Bloomberg. Software sales jumped 21 percent year-over-year. What is fueling the growth? [...]]]></description>
			<content:encoded><![CDATA[<p>Sun&#8217;s sales topped estimates, according to <a title="Bloomberg's report on Sun's result" href="http://www.bloomberg.com/apps/news?pid=20601087&amp;sid=aTpPkrKPME1g&amp;refer=home" target="_blank">Bloomberg</a>, and this was all thanks to its <em>open source software strategy</em>, according to Matt Asay at CNET:</p>
<blockquote><p>Sun Microsystems is getting some love from Wall Street after its sales and earnings topped estimates, as detailed by Bloomberg. Software sales jumped 21 percent year-over-year.</p>
<p>What is fueling the growth? The same thing that Sun CEO Jonathan Schwartz has doggedly said would lift Sun&#8217;s fortunes again: open source.</p>
<p>via <a href="http://news.cnet.com/8301-13505_3-10152077-16.html#">Open source makes Sun&#8217;s quarter shine | The Open Road &#8211; CNET News</a>.</p></blockquote>
<p>If this approach is validated going forward the next year or two, will it change the software industry radically? Quite possibly. Remember this is not a five-man company selling training and consultancy services leveraged off it&#8217;s founders&#8217; successful open source software effort, nor even a much larger company set up solely to market and sell services and support contracts based around packaged open source distributions. Sun is a <em>big vendor</em>, which has had to turn its ship of business around almost 180 degrees to get where it&#8217;s going now. And maybe, just <em>maybe</em>, it&#8217;s on a winning course now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/01/29/open-source-and-profits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
