<?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>Sven Lange</title>
	<atom:link href="http://www.svenlange.co.za/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.svenlange.co.za</link>
	<description>A web geek&#039;s blog</description>
	<lastBuildDate>Tue, 17 Aug 2010 08:43:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>HTML5 offline capabilities for web applications</title>
		<link>http://www.svenlange.co.za/?p=165</link>
		<comments>http://www.svenlange.co.za/?p=165#comments</comments>
		<pubDate>Sun, 15 Aug 2010 12:17:43 +0000</pubDate>
		<dc:creator>Sven Lange</dc:creator>
				<category><![CDATA[Lessons Learned]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[localStorage]]></category>

		<guid isPermaLink="false">http://www.svenlange.co.za/?p=165</guid>
		<description><![CDATA[Inspired by a HTML5 GTUG-Campout Meeting I decided to play around a little with HTML5. In this post I will show an example how to create book instances in a book management web application while being offline and push all &#8230; <a href="http://www.svenlange.co.za/?p=165">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Inspired by a <a href="http://www.meetup.com/GTUG-Campout">HTML5 GTUG-Campout Meeting</a> I decided to play around a little with HTML5. In this post I will show an example how to create book instances in a book management web application while being offline and push all the books into the database by the time the user is online again.</p>
<p>The use case for my little example is the following: A user is offline and wants to enter some new books into a book management web application.</p>
<p>OK the first question that arises is: How can a client detect whether it is on- or offline? The answer is it shouldn&#8217;t be automatically and you can find a good answer to that <a href="http://code.google.com/intl/de-DE/apis/gears/gears_faq.html#isOnlineFunction">here</a>. So the user needs to be aware whether he is online or not and triggers a syncronisation with the web server by himself.</p>
<p>In HTML5 you have a client side storage where you can place stuff. It is a key/value pair storage with a maximum size of 5MB. To persist an object (in my example a book) you best better use <a href="http://www.json.org/js.html">JSON</a>. The following code snipplet shows a JavaScript function called <em>preserve</em> that collects all entered details for a book from an input page and places the result in the local storage. The local storage can be accessed with <em>localStorage </em>as you can see in line 15.</p>
<pre class="brush: jscript;">
function preserve() {

	function getValueById(id) {
		return document.getElementById(id).value;
	}

	var JSONbook = {
		&quot;title&quot; : getValueById(&quot;title&quot;),
		&quot;isbn&quot; : getValueById(&quot;isbn&quot;),
		&quot;author&quot; : getValueById(&quot;author1&quot;)
	};

	var bookString = JSON.stringify(JSONbook);

	localStorage.setItem(localStorage.length + 1, bookString);
}
</pre>
<p>Due to the fact that you can only place strings into the key/value store one has to convert the JSON object into a string. This can be achivied with the help of the following free <a href="http://www.json.org/json2.js">javascript stringifier/parser</a> which I use here in line 13.</p>
<p>Of course <em>localStorage.length + 1</em> is not a good way to generate a key, but for this experimental example it suits the needs.</p>
<p>So now when a user is back online and decides he wants to push all the newly created books into the database server a little Javascript like the following could do the job for him. For example by clicking on a button the <em>persistAllBooks</em> gets invoked. This function sequentially reads all book objects from the localStorage and calls the <a href="http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit">post_to_url</a> function for each book. <em>post_to_url</em> builds up a form, fills it with the books attributes and pushes them to the server.</p>
<pre class="brush: jscript;">
function persistAllBooks() {
	for (var i = 1; i &lt;= localStorage.length; i++) {
		var item = localStorage.getItem(i);
		var parse = JSON.parse(item);
		post_to_url(parse);
	}

}

function post_to_url(params) {
	var form = document.createElement(&quot;form&quot;);
	form.setAttribute(&quot;method&quot;, &quot;post&quot;);
	form.setAttribute(&quot;action&quot;, &quot;/bookmngt/book/save&quot;);

	for (var key in params) {
		var hiddenField = document.createElement(&quot;input&quot;);
		hiddenField.setAttribute(&quot;type&quot;, &quot;hidden&quot;);
		hiddenField.setAttribute(&quot;name&quot;, key);
		hiddenField.setAttribute(&quot;value&quot;, params[key]);

		form.appendChild(hiddenField);
	}

	document.body.appendChild(form);
	form.submit();
}
</pre>
<p>Thats it. Of cource the book creation page needs to be <a href="http://diveintohtml5.org/offline.html">offline</a> available to the client and HTML5 is helping here too.</p>
<p>Thanks to <a href="http://www.thomas-asel.de">Thomas Asel</a> for brainstorming and talking about HTML5 which led to this post.</p>
<h2>HTML5 Resources</h2>
<p>The following list contains some good HTML5 resources I found on the net while experimenting a little.</p>
<p>Dive Into HTML 5 &#8211; <a href="http://diveintohtml5.org/">diveintohtml5.org</a><br />
Browsers with Wings &#8211; <a href="http://www.slideshare.net/remy.sharp/browsers-with-wings">slideshare.net/remy.sharp/browsers-with-wings</a><br />
HTML5 on Wikipedia &#8211; <a href="http://en.wikipedia.org/wiki/HTML5">en.wikipedia.org/wiki/HTML5</a><br />
&#8220;Offline&#8221;: What does it mean and why should I care? &#8211; <a href="http://www.html5rocks.com/tutorials/offline/whats-offline/">www.html5rocks.com/tutorials/offline/whats-offline</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.svenlange.co.za/?feed=rss2&amp;p=165</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable Ehcaches UpdateChecker in Grails application</title>
		<link>http://www.svenlange.co.za/?p=122</link>
		<comments>http://www.svenlange.co.za/?p=122#comments</comments>
		<pubDate>Sat, 27 Feb 2010 10:12:53 +0000</pubDate>
		<dc:creator>Sven Lange</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Ehcache]]></category>
		<category><![CDATA[UpdateChecker]]></category>

		<guid isPermaLink="false">http://www.svenlange.co.za/?p=122</guid>
		<description><![CDATA[This post describes how to disable Ehcaches annoying and suspiciously talkative UpdateChecker in a Grails 1.2.0 application using Ehcache 1.7.1 as its 2nd level cache provider. <a href="http://www.svenlange.co.za/?p=122">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I found it pretty annoying that Ehcache always reminded me that there is an update to a newer version of its framework available. After searching the web I found an <a href="http://forums.terracotta.org/forums/posts/list/2793.page">interesting thread in the Terracotta forum</a> saying that the <a href="http://ehcache.org/apidocs/net/sf/ehcache/util/UpdateChecker.html">UpdateChecker</a> is not only looking for updates. In addition it also submits information about the applications environment to Terracotta by default. And that is not a good thing in my opinion.</p>
<p>Here you can see youself: <a href="http://svn.terracotta.org/svn/ehcache/trunk/core/src/main/java/net/sf/ehcache/util/UpdateChecker.java">http://svn.terracotta.org/svn/ehcache/trunk/core/src/main/java/net/sf/ehcache/util/UpdateChecker.java</a></p>
<p>Fortunately you can disable this behavior by adding an Ehcache configuration to your Grails application. I have tested this with a Grails 1.2.0 application which includes Ehcache 1.7.1.</p>
<p>Simply place an ehcache.xml file in your <em>&lt;app-root&gt;/grails-app/conf</em> folder containing your Ehcache configuration. For this post I am using the configuration that ships with Ehcache as default (ehcache-failsafe.xml) and modify it.</p>
<pre class="brush: xml;">
&lt;ehcache xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;ehcache.xsd&quot; updateCheck=&quot;false&quot;&gt;

    &lt;diskStore path=&quot;java.io.tmpdir&quot;/&gt;

    &lt;defaultCache
            maxElementsInMemory=&quot;10000&quot;
            eternal=&quot;false&quot;
            timeToIdleSeconds=&quot;120&quot;
            timeToLiveSeconds=&quot;120&quot;
            overflowToDisk=&quot;true&quot;
            maxElementsOnDisk=&quot;10000000&quot;
            diskPersistent=&quot;false&quot;
            diskExpiryThreadIntervalSeconds=&quot;120&quot;
            memoryStoreEvictionPolicy=&quot;LRU&quot;
            /&gt;

&lt;/ehcache&gt;
</pre>
<p>With the attribute <em>updateCheck=&#8221;false&#8221;</em> in the root tag the haunting is gone.</p>
<p>XML Schema for Ehcache config can be found here: <a href="http://ehcache.org/ehcache.xsd">http://ehcache.org/ehcache.xsd</a></p>
<p>More Information about Ehcache configuration: <a href="http://ehcache.org/documentation/configuration.html">http://ehcache.org/documentation/configuration.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.svenlange.co.za/?feed=rss2&amp;p=122</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Recursively remove Subversions .svn folders</title>
		<link>http://www.svenlange.co.za/?p=105</link>
		<comments>http://www.svenlange.co.za/?p=105#comments</comments>
		<pubDate>Thu, 04 Feb 2010 20:07:41 +0000</pubDate>
		<dc:creator>Sven Lange</dc:creator>
				<category><![CDATA[Lessons Learned]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://www.svenlange.co.za/?p=105</guid>
		<description><![CDATA[Howto recursively remove Subversions .svn folders. <a href="http://www.svenlange.co.za/?p=105">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To remove all the sometimes pretty annoying <em>.svn</em> folders here are some very helpful lines of code.</p>
<pre class="brush: plain;">
for /f &quot;tokens=* delims=&quot; %%i in ('dir /s /b /a:d *svn') do (
rd /s /q &quot;%%i&quot;
)
</pre>
<p>Just place the above lines into a file called removeSvn.cmd, place it into the polluted folder and then run it. Done.</p>
<p>Another resources on this topic:</p>
<ul>
<li><a href="http://codesnippets.joyent.com/posts/show/104">Recursively remove all .svn directories</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.svenlange.co.za/?feed=rss2&amp;p=105</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating UML class diagrams from Grails domain model</title>
		<link>http://www.svenlange.co.za/?p=80</link>
		<comments>http://www.svenlange.co.za/?p=80#comments</comments>
		<pubDate>Sat, 23 Jan 2010 14:06:04 +0000</pubDate>
		<dc:creator>Sven Lange</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[UML]]></category>

		<guid isPermaLink="false">http://www.svenlange.co.za/?p=80</guid>
		<description><![CDATA[In this post I compare the existing Grails plugins to generate UML class diagrams. <a href="http://www.svenlange.co.za/?p=80">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I tried some Grails plugins that generate UML class diagrams from the existing domain model in an Grails application. I found the following two plugins in the offical Grails plugin repository to play with.</p>
<ul>
<li><a href="http://www.grails.org/plugin/create-domain-uml">Create Domain UML 0.5</a> created by Al Phillips (<a href="http://code.google.com/p/grails-domain-uml/">Source code</a>)</li>
<li><a href="http://www.grails.org/plugin/class-diagram">Class diagram plugin 0.4.1</a> created by <a href="http://trygveamundsen.blogspot.com">Trygve Amundsen</a></li>
</ul>
<p>The application I used is a small book management app that manages a couple hundred books at my workplace.</p>
<p><span id="more-80"></span></p>
<h3>Create Domain UML plugin</h3>
<p>First I tried the <em>Create Domain UML</em> plugin. This plugin is very easy to install and actually consists only of one custom Grails  script called CreateDomainUml.groovy.</p>
<p>To generate the diagram the<a href="http://yuml.me/"> yuml.me</a> service is used. The service is totally free according to the faq section. But still his  might be a problem for some people as they cant send any source codes of there program across the internet. Well, you could run your own yuml service by <a href="http://yuml.me/getit">buying the software</a> and run it on an internal server.</p>
<p>To install the plugin into your Grails application simply enter the following command line command.</p>
<pre class="brush: plain;">
grails install-plugin create-domain-uml
</pre>
<p>To generate a class diagram just enter:</p>
<pre class="brush: plain;">
grails create-domain-uml
</pre>
<p>Ok enough texting. Let&#8217;s see what the plugin can do for us.</p>
<div id="attachment_82" class="wp-caption alignnone" style="width: 302px"><a href="http://www.svenlange.co.za/wp-content/uploads/2010/01/scroffyCreateDomainUMLPlugin.png"><img class="size-medium wp-image-82" title="scroffyCreateDomainUMLPlugin" src="http://www.svenlange.co.za/wp-content/uploads/2010/01/scroffyCreateDomainUMLPlugin-292x300.png" alt="UML Class Diagram" width="292" height="300" /></a><p class="wp-caption-text">Scroffy Top Down class diagram</p></div>
<div id="attachment_84" class="wp-caption alignnone" style="width: 302px"><a href="http://www.svenlange.co.za/wp-content/uploads/2010/01/createDomainUMLPlugin.png"><img class="size-medium wp-image-84" title="createDomainUMLPlugin" src="http://www.svenlange.co.za/wp-content/uploads/2010/01/createDomainUMLPlugin-292x300.png" alt="UML class diagram" width="292" height="300" /></a><p class="wp-caption-text">Orderly Top Down class diagram</p></div>
<p>The plugin creates a HTML-File and puts it into the applications root folder. On the page you see four links directing to www.yuml.me. Two of them will generate a Top Down class diagram (scroffy/orderly) as you can see above and the the other two a Right Left version of the class diagram (scroffy/orderly).</p>
<h3 id="pluginBoxTitle">Class diagram plugin</h3>
<p>Second up to try the <em>Class diagram plugin.</em> This plugin is not that easy to install. First you need to download and install <a href="http://www.graphviz.org/">Graphviz</a>. Graphviz is an open source graph visualization software licensed under the Common Public License Version 1.0.</p>
<p>The installation can be triggered by executing the following command line command.</p>
<pre class="brush: plain;">
grails install-plugin class-diagram
</pre>
<p>After some configuring and starting up your Grails application class diagrams can be generated by invoking <em>http://localhost:8080/classDiagram</em>. The result could look like the following.</p>
<div id="attachment_89" class="wp-caption alignnone" style="width: 199px"><a href="http://www.svenlange.co.za/wp-content/uploads/2010/01/classDiagramPlugin.png"><img class="size-medium wp-image-89" title="classDiagramPlugin" src="http://www.svenlange.co.za/wp-content/uploads/2010/01/classDiagramPlugin-189x300.png" alt="UML Class Diagram" width="189" height="300" /></a><p class="wp-caption-text">Class diagram generated by Class Diagram Plugin</p></div>
<p>The plugin comes with a mass of config possibilities I had not a deep look into. There you can change the diagrams direction (TopDown/RightLeft), appearance and level of detail.</p>
<p>Little downsite of the plugins is that its views depend on JQuery so might look ugly without. But it is still possible to generate the desired diagram.</p>
<h3>Conclusion</h3>
<p><a href="http://www.grails.org/plugin/create-domain-uml">Create Domain UML</a> is way easier to install and has fancy but not so detailed diagrams.</p>
<p><a href="http://www.grails.org/plugin/class-diagram">Class diagram plugin</a> is not so easy to install and has a lot configs. The diagram itself does not look so nice but is more detailed.</p>
<p>For my docs I used <em>Class diagram plugin</em> although it doesn&#8217;t look so neat. For me it was more important that the diagram shows all details of the model.</p>
<p>Hopefully we will see some improvements to the <em>Create Domain UML</em> plugin, because it is easy to use and looks nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.svenlange.co.za/?feed=rss2&amp;p=80</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Give the tomcat a bit more memory</title>
		<link>http://www.svenlange.co.za/?p=69</link>
		<comments>http://www.svenlange.co.za/?p=69#comments</comments>
		<pubDate>Fri, 15 Jan 2010 16:24:55 +0000</pubDate>
		<dc:creator>Sven Lange</dc:creator>
				<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Memory]]></category>

		<guid isPermaLink="false">http://www.svenlange.co.za/?p=69</guid>
		<description><![CDATA[If Tomcat needs more memory then you have to add the following line to the catalina config file. Windows (catalina.bat) set JAVA_OPTS=%JAVA_OPTS% -server -Xms512M -Xmx768M -XX:MaxPermSize=128m Grails 1.2 default PermGen memory is set to 96MB. The Sun JVMs default is &#8230; <a href="http://www.svenlange.co.za/?p=69">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If Tomcat needs more memory then you have to add the following line to the catalina config file.</p>
<p><strong>Windows (catalina.bat)</strong></p>
<pre class="brush: xml;">
set JAVA_OPTS=%JAVA_OPTS% -server -Xms512M -Xmx768M -XX:MaxPermSize=128m
</pre>
<p>Grails 1.2 default PermGen memory is set to 96MB. The Sun JVMs default is 64MB. (<a href="http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp">Java HotSpot VM Options</a>)</p>
<p style="text-align: center;"><img class="size-medium wp-image-78 aligncenter" title="Memory" src="http://www.svenlange.co.za/wp-content/uploads/2010/01/memory-300x135.jpg" alt="Memory" width="300" height="135" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.svenlange.co.za/?feed=rss2&amp;p=69</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manually install JDK 6 on Suse Linux Enterpise Edition 10 SP2</title>
		<link>http://www.svenlange.co.za/?p=53</link>
		<comments>http://www.svenlange.co.za/?p=53#comments</comments>
		<pubDate>Mon, 08 Jun 2009 12:53:26 +0000</pubDate>
		<dc:creator>Sven Lange</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Suse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JDK]]></category>
		<category><![CDATA[SLES]]></category>

		<guid isPermaLink="false">http://www.svenlange.co.za/?p=53</guid>
		<description><![CDATA[First remove older and maybe protected JDKs with yast. yast -&#62; Software -&#62; Software management Then invoke following command on console. ./jdk-6u14-linux-i586-rpm.bin Afterwards create file /etc/profile.local and add following line. export JAVA_HOME=/usr/java/jdk1.6.0_14 That&#8217;s it.]]></description>
			<content:encoded><![CDATA[<p>First remove older and maybe protected JDKs with yast.</p>
<p>yast -&gt; Software -&gt; Software management</p>
<p>Then invoke following command on console.</p>
<pre class="brush: plain;">
./jdk-6u14-linux-i586-rpm.bin
</pre>
<p>Afterwards create file <em>/etc/profile.local</em> and add following line.</p>
<pre class="brush: plain;">
export JAVA_HOME=/usr/java/jdk1.6.0_14
</pre>
<p>That&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.svenlange.co.za/?feed=rss2&amp;p=53</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using storeXPath() in your Grails Webtest</title>
		<link>http://www.svenlange.co.za/?p=3</link>
		<comments>http://www.svenlange.co.za/?p=3#comments</comments>
		<pubDate>Fri, 11 Jul 2008 09:47:27 +0000</pubDate>
		<dc:creator>Sven Lange</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Webtest]]></category>
		<category><![CDATA[storeXPath]]></category>

		<guid isPermaLink="false">http://svenlange.co.za/?p=3</guid>
		<description><![CDATA[Today I had to figure out how to save some content from a site during a running Webtest so that I am able to restore all changed data afterwards. Luckily Webtest provides the step storeXPath() which does the job. But &#8230; <a href="http://www.svenlange.co.za/?p=3">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I had to figure out how to save some content from a site during a running Webtest so that I am able to restore all changed data afterwards. Luckily Webtest provides the step storeXPath() which does the job.</p>
<p>But it was not that easy to realize my task due to the lack of good documentation and finding the correct xpath expression.</p>
<p>The following code snippet grabs the text value from a text input field with the id surname and saves it in the ant property xyz.</p>
<pre class="brush: java;">
def testSomething() {
   webtest('Some description') {

      // saving initial value
      storeXPath(xpath: &quot;id('surname')/@value&quot;, property: &quot;xyz&quot;)

      // restore initial value
      setInputField(name: &quot;surname&quot;, value: &quot;#{xyz}&quot;)

   }
}
</pre>
<p>Pretty simple in the end, but it took a while till I got it. Maybe it helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.svenlange.co.za/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
