<?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>Jeroen's Blog</title>
	<atom:link href="http://www.jwse.nl/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.jwse.nl/blog</link>
	<description>De wereld volgens Jeroen Wolsink</description>
	<lastBuildDate>Wed, 04 Aug 2010 20:12: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>4Daagse 2010 zit er weer op</title>
		<link>http://www.jwse.nl/blog/?p=266</link>
		<comments>http://www.jwse.nl/blog/?p=266#comments</comments>
		<pubDate>Mon, 26 Jul 2010 08:39:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[4daagse]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=266</guid>
		<description><![CDATA[De vierdaagse zit er weer op. Dit jaar is het ons allemaal weer gelukt om de Via Gladiola te halen. Voor Annemiek was het haar eerste keer. En dan ook nog meteen de 50km!! Het was niet makkelijk, maar het is haar toch gelukt. Ik ben trots op jou schat! Nu maar weer aftellen tot [...]]]></description>
			<content:encoded><![CDATA[<p>De vierdaagse zit er weer op. Dit jaar is het ons allemaal weer gelukt om de Via Gladiola te halen. Voor Annemiek was het haar eerste keer. En dan ook nog meteen de 50km!! Het was niet makkelijk, maar het is haar toch gelukt. Ik ben trots op jou schat!
</p>
<div id="attachment_271" class="wp-caption alignnone" style="width: 1034px"><a href="http://www.jwse.nl/blog/wp-content/uploads/2010/07/DSCN0347.JPG"><img src="http://www.jwse.nl/blog/wp-content/uploads/2010/07/DSCN0347-1024x768.jpg" alt="pre honeymoon" title="4Daagse 2010" width="768" height="576" class="size-large wp-image-271" /></a><p class="wp-caption-text">pre honeymoon</p></div>
<p>Nu maar weer aftellen tot volgend jaar:</p>
<p>
<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" height="77" width="202"><param name="src" value="http://www.jwse.nl/blog/wp-content/uploads/2010/07/countdown_0400.swf" /><param name="wmode" value="transparent" /><embed wmode="transparent" src="http://www.jwse.nl/blog/wp-content/uploads/2010/07/countdown_0400.swf" type="application/x-shockwave-flash" height="77" width="202"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=266</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Vierdaagse begint een uur eerder</title>
		<link>http://www.jwse.nl/blog/?p=262</link>
		<comments>http://www.jwse.nl/blog/?p=262#comments</comments>
		<pubDate>Mon, 19 Jul 2010 14:53:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[4daagse]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=262</guid>
		<description><![CDATA[Advies aan wandelaars: drink voldoende In verband met de later op de dag te verwachten hitte (33°C) worden de starttijden voor deelnemers (50 en 40 km) aan de 94ste Vierdaagse morgen een uur vervroegd. De deelnemers aan de 30 kilometerafstand gaan zelfs anderhalf uur eerder van start. Alle deelnemers moeten morgen ook een uur eerder [...]]]></description>
			<content:encoded><![CDATA[<h1>Advies aan wandelaars: drink voldoende</h1>
<p>In verband met de later op de dag te verwachten hitte (33°C) worden  de starttijden voor deelnemers (50 en 40 km) aan de 94ste Vierdaagse  morgen een uur vervroegd. De deelnemers aan de 30 kilometerafstand gaan  zelfs anderhalf uur eerder van start. Alle deelnemers moeten morgen ook  een uur eerder (om 16.00 uur) binnen zijn.</p>
<p>Met nadruk adviseert de marsleiding de wandelaars ook goed gebruik te  maken van de koelere ochtenduren. Voor de laatste twaalf kilometer  worden drie extra waterpunten ingericht, zodat er op het laatste deel  van de eerste wandeldag vier waterverversingspunten beschikbaar zijn  voor de wandelaars. Daarnaast wordt ook nog een beroep gedaan op de  aanwonenden van de parcoursen om de wandelaars van (drink)water te  voorzien.</p>
<h2>Graadje warmer</h2>
<p>Het besluit de start te vervroegen, extra waterpunten in te richten  en de wandelaars nog nadrukkelijker voor te lichten over maatregelen die  zij zelf kunnen nemen om hun vocht- en temperatuurhuishouding van hun  lichaam op peil te houden, werd door het bestuur genomen nadat het Weer  Advies Team van de Vierdaagse zijn advies van zondag had bijgesteld.  &#8220;Veiligheid van wandelaars staat voorop. Toen duidelijk werd dat het  morgen nog een graadje warmer wordt dan gedacht, is besloten het starten  nog meer te vervroegen. Het gaat er vooral om dat de wandelaars het  warmste moment van de dag, zo tussen twee en vier uur morgen voor  blijven. Zo tussen twee en vier uur morgen &#8220;, aldus marsleider Johan  Willemstein.</p>
<h2>Vers water</h2>
<p>Ter hoogte van Strandpark Slijk-Ewijk zullen in samenwerking met  sponsor Albron flesjes water uitgedeeld worden. Enkele kilometers verder  op de Oosterhoutsestraat ter hoogte van nummer 95 treffen de wandelaars  watertapinstallaties aan. Kort voor het begin van de Oosterhoutsedijk  is het reguliere waterpunt van Vitens te vinden. Tenslotte wordt in  Lent, pal na de spoorbrug over de Waal, en dus voor het begin van de  Waalbrug nog een waterpunt ingericht door middel van het uitdelen van  flesjes.</p>
<h2>Starttijden</h2>
<p>Deelnemers aan de 50 kilometer afstand starten morgen tussen 03.00 en  en 03.45 uur, de 40 km groep 1 start tussen 04.15 en 05.00 uur, de 40  km groep 2 start tussen 05.15 en 06.00 uur. De 30 kilometer wandelaars  starten tussen 06.00 en 06.30 uur.<br />
Omdat de wandelaars op de kortste afstand tot zowel de jongste als de  oudste leeftijdscategorieën behoren, is hun starttijd met anderhalf uur  vervroegd.</p>
<h2>Adviezen wandelaars</h2>
<p>Adviezen rechtstreeks aan de wandelaars luiden:<br />
Drink voldoende;<br />
Zorg dat u altijd iets te drinken bij u heeft;<br />
Bescherm hoofd en nek;<br />
Benut de vroege uren voor het wandelen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=262</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wij zijn er klaar voor</title>
		<link>http://www.jwse.nl/blog/?p=259</link>
		<comments>http://www.jwse.nl/blog/?p=259#comments</comments>
		<pubDate>Mon, 19 Jul 2010 14:35:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[4daagse]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=259</guid>
		<description><![CDATA[Zo, de laatste voorbereidingen zijn getroffen. Wij zijn er klaar voor. In verband met de verwachte hitte, starten we morgen een uur eerder dan normaal (03:00 ipv 0:400).]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jwse.nl/blog/wp-content/uploads/2010/07/Dag-0-040.JPG"><img class="alignnone size-medium wp-image-260" title="Dag 0 040" src="http://www.jwse.nl/blog/wp-content/uploads/2010/07/Dag-0-040-300x277.jpg" alt="Dag 0 040" width="300" height="277" /></a></p>
<p>Zo, de laatste voorbereidingen zijn getroffen. Wij zijn er klaar voor. In verband met de verwachte hitte, starten we morgen een uur eerder dan normaal (03:00 ipv 0:400).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=259</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>4Daagse 2010</title>
		<link>http://www.jwse.nl/blog/?p=255</link>
		<comments>http://www.jwse.nl/blog/?p=255#comments</comments>
		<pubDate>Thu, 15 Jul 2010 15:48:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wandelen]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=255</guid>
		<description><![CDATA[Nog even en dan is het zover!! Bekijk hieronder alvast de route. Het werkt erg rustgevend.]]></description>
			<content:encoded><![CDATA[<p>Nog even en dan is het zover!! Bekijk hieronder alvast de route. Het werkt erg rustgevend.</p>
<p><embed src="http://www.omroepgelderland.nl/player.swf" width="500" height="280" allowscriptaccess="always" allowfullscreen="true" flashvars="controlbar=over&#038;stretching=uniform&#038;file=/uitzendingen/video/2010/06/100622 000 4daagsedag1.flv&#038;title=Dag 1: De dag van Elst&#038;image=http://www.omroepgelderland.nl/upload_mm/0/0/5/cid621401_image2_500x280.jpg&#038;streamer=rtmp://media2.omroepgelderland.nl/stream&#038;skin=http://www.omroepgelderland.nl/og_new.swf&#038;plugins=http://www.omroepgelderland.nl/embedPlugin&#038;embed.playerlocation=http://www.omroepgelderland.nl/player.swf"/></p>
<p><embed src="http://www.omroepgelderland.nl/player.swf" width="500" height="280" allowscriptaccess="always" allowfullscreen="true" flashvars="controlbar=over&#038;stretching=uniform&#038;file=http://media.omroepgelderland.nl/items/video/2010/07/DAG2.flv&#038;title=Dag 2: De dag van Wijchen&#038;image=http://www.omroepgelderland.nl/upload_mm/2/d/6/cid630451_image3_500x280.jpg&#038;skin=http://www.omroepgelderland.nl/og_new.swf&#038;plugins=http://www.omroepgelderland.nl/embedPlugin&#038;embed.playerlocation=http://www.omroepgelderland.nl/player.swf"/></p>
<p><embed src="http://www.omroepgelderland.nl/player.swf" width="500" height="280" allowscriptaccess="always" allowfullscreen="true" flashvars="controlbar=over&#038;stretching=uniform&#038;file=http://media.omroepgelderland.nl/items/video/2010/06/DAG3.flv&#038;title=Dag 3: De dag van Groesbeek&#038;image=http://www.omroepgelderland.nl/upload_mm/8/8/1/cid629421_image3_500x280.jpg&#038;skin=http://www.omroepgelderland.nl/og_new.swf&#038;plugins=http://www.omroepgelderland.nl/embedPlugin&#038;embed.playerlocation=http://www.omroepgelderland.nl/player.swf"/></p>
<p><embed src="http://www.omroepgelderland.nl/player.swf" width="500" height="280" allowscriptaccess="always" allowfullscreen="true" flashvars="controlbar=over&#038;stretching=uniform&#038;file=http://media.omroepgelderland.nl/items/video/2010/06/DAG4.flv&#038;title=Dag 4: De dag van Cuijk&#038;image=http://www.omroepgelderland.nl/upload_mm/f/0/4/cid628431_image1_500x280.jpg&#038;skin=http://www.omroepgelderland.nl/og_new.swf&#038;plugins=http://www.omroepgelderland.nl/embedPlugin&#038;embed.playerlocation=http://www.omroepgelderland.nl/player.swf"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=255</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code Kata: RoboStack</title>
		<link>http://www.jwse.nl/blog/?p=244</link>
		<comments>http://www.jwse.nl/blog/?p=244#comments</comments>
		<pubDate>Mon, 17 May 2010 15:06:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ActiveMQ]]></category>
		<category><![CDATA[Code Kata]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[Swing Application Framework]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=244</guid>
		<description><![CDATA[Last week I stumbled upon this article on JavaLobby. Below a quote from the article. Code Katas are small, relatively simple exercises designed to give you a problem to try and solve. I like to use them as a way to get my feet wet and help write something more interesting than &#8220;Hello World&#8221; but [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I stumbled upon <a href="http://java.dzone.com/articles/code-kata-robostack">this</a> article on JavaLobby. Below a quote from the article.</p>
<blockquote><p><a href="http://blogs.tedneward.com/ct.ashx?id=0e5b971c-8dd4-48ef-b47c-b9b0611607dd&amp;url=http%3a%2f%2fcodekata.pragprog.com%2f2007%2f01%2fcode_katahow_it.html" target="_blank">Code Katas</a> are small, relatively simple exercises designed to give you a problem to try and solve. I like to use them as a way to get my feet wet and help write something more interesting than &#8220;Hello World&#8221; but less complicated than &#8220;The Internet&#8217;s Next Killer App&#8221;.</p></blockquote>
<p>The Code Kata  is about a robotic arm that can manipulate an assembly-line. The robotic arm should be able to process commands like: move x over y, move x onto y and pile x over y. Please read the article if you want to know more about the problem domain. This weekend I gave it a try. What started out as a small coding exercise, emerged to the exploration of several frameworks like: Swing Application Framework  (JSR 296), Spring JMS and ActiveMQ.</p>
<p>Below you can see a screenshot of the server and client application.</p>
<p>Feel free to download the Maven2 project: <a href="http://www.jwse.nl/blog/wp-content/uploads/2010/05/robostack.zip">robostack.zip</a></p>
<p><em>* Note: to let the client and server communicate with eachother, you should have ActiveMQ up and running on port 61616. </em></p>
<p><a href="http://www.jwse.nl/blog/wp-content/uploads/2010/05/screen.png"><img class="alignnone size-full wp-image-245" title="RoboStack" src="http://www.jwse.nl/blog/wp-content/uploads/2010/05/screen.png" alt="RoboStack" width="530" height="289" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=244</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java EE 6 vs Spring 3.0</title>
		<link>http://www.jwse.nl/blog/?p=240</link>
		<comments>http://www.jwse.nl/blog/?p=240#comments</comments>
		<pubDate>Thu, 24 Dec 2009 13:17:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=240</guid>
		<description><![CDATA[Having both Java EE 6 and Spring 3.0 recently released, there is a fierce discussion going on between both camps. Have look at the server side postings below. SpringSource takes Spring 3.0 to GA GlassFish v3 and Java EE 6 Released SpringSource takes Spring 3.0 to GA]]></description>
			<content:encoded><![CDATA[<p>Having both Java EE 6 and Spring 3.0 recently released, there is a fierce discussion going on between both camps. Have look at the server side postings below.</p>
<p><a href="http://www.theserverside.com/news/thread.tss?thread_id=58985">SpringSource takes Spring 3.0 to GA</a></p>
<p><a href="http://www.theserverside.com/news/thread.tss?thread_id=58858">GlassFish v3 and Java EE 6 Released</a></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<h1>SpringSource takes Spring 3.0 to GA</h1>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=240</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCBCD</title>
		<link>http://www.jwse.nl/blog/?p=233</link>
		<comments>http://www.jwse.nl/blog/?p=233#comments</comments>
		<pubDate>Thu, 24 Dec 2009 10:44:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=233</guid>
		<description><![CDATA[Yesterday I passed the Sun Certified Business Component Developer exam.  I had no hand-on experience with EJB 3.0.  My experience with the Spring Framework helped me a lot to understand the principles of EJB. To prepare myself for the exam, I&#8217;ve read EJB 3.0 in Action. Although it is a good book, it contains a [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I passed the Sun Certified Business Component Developer exam.  <img class="alignright" title="Java Evil Edition" src="http://img.worsethanfailure.com/images/200705/Java-Evil-Edition-orfjackal_net-lores.png" alt="" width="138" height="222" /></p>
<p>I had no hand-on experience with EJB 3.0.  My experience with the Spring Framework helped me a lot to understand the principles of EJB. To prepare myself for the exam, I&#8217;ve read EJB 3.0 in Action. Although it is a good book, it contains a lot of information that isn&#8217;t required to know for the exam. </p>
<p>I also used the mock exams from Ethuware.  The questions in the question bank are faithfully to the exam. The question viewer from Ethuware is a Java application, so I had no problems using it under Xubuntu.  Below are some links to other resources that you can use for preparation:</p>
<p><a href="http://ordina.nl/Downloadcentrum/~/media/Files/Onze%20dienstverlening/technologie/3%202%204%20%20Cookbook%20EJB.ashx?forcedownload=1">SCBCD 5.0 study guide</a></p>
<p><a href="http://ordina.nl/Downloadcentrum/~/media/Files/Onze%20dienstverlening/technologie/3%202%204%20%20Cookbook%20EJB.ashx?forcedownload=1">EJB 3.0 Cookbook<br />
</a></p>
<p><a href="http://java.boot.by/scbcd5-guide/"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=233</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSF 2.0 Maven archetype</title>
		<link>http://www.jwse.nl/blog/?p=228</link>
		<comments>http://www.jwse.nl/blog/?p=228#comments</comments>
		<pubDate>Wed, 21 Oct 2009 10:52:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=228</guid>
		<description><![CDATA[To quickly get started with JSF 2.0 I’ve created a maven archetype. To use this archetype, you must have Maven 2, Tomcat 6 and Eclipse installed on your machine. Follow the steps below to get a new project up and running: Step 1: Go to your workspace folder cd c:\workspaces\DevWorkspace Step 2: Generate a new [...]]]></description>
			<content:encoded><![CDATA[<p>To quickly get started with JSF 2.0 I’ve created a maven archetype. To use this archetype, you must have Maven 2, Tomcat 6 and Eclipse installed on your machine. Follow the steps below to get a new project up and running:</p>
<p><strong>Step 1: Go to your workspace folder</strong></p>
<p>cd c:\workspaces\DevWorkspace</p>
<p><strong>Step 2: Generate a new project</strong></p>
<p>To generate a new project using the archetype, you must use the following command:</p>
<p>mvn archetype:generate -DarchetypeGroupId=nl.jwse.archtypes -DarchetypeArtifactId=martino -DarchetypeVersion=1.0 -DgroupId=[YOUR GROUP ID] -DartifactId=[YOUR ARTIFACT] DpackageName=[YOUR PACKAGE_NAME] -DremoteRepositories=http://www.jwse.nl/maven2</p>
<p>for example</p>
<p>mvn archetype:generate -DarchetypeGroupId=nl.jwse.archtypes -DarchetypeArtifactId=martino -DarchetypeVersion=1.0 -DgroupId=com.acme.sample -DartifactId=jsf2demo -DpackageName=nl.jwse.sample.jsf2demo -DremoteRepositories=http://www.jwse.nl/maven2</p>
<p><strong>Step 3: Go inside the new project folder</strong></p>
<p>cd c:\workspaces\DevWorkspace\jsf2demo</p>
<p><strong>Step 4: Generate an Eclipse project</strong></p>
<p>mvn eclipse:eclipse</p>
<p>This command will generate a WTP eclipse project for you.</p>
<p><strong>Step 5: Import the project into Eclipse</strong></p>
<p>As you can see below the archetype creates a complete project to get you started.</p>
<p><strong><a href="http://www.jwse.nl/blog/wp-content/uploads/2009/10/martino.png"><img class="alignnone size-full wp-image-230" title="martino" src="http://www.jwse.nl/blog/wp-content/uploads/2009/10/martino.png" alt="martino" width="913" height="528" /></a><br />
</strong></p>
<p><strong>Step 6: Add the project to the Tomcat server and start the server</strong></p>
<p><strong>Step 7: Point your browser to http://localhost:8080/jsf2demo<br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=228</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Faces Taglib explained</title>
		<link>http://www.jwse.nl/blog/?p=215</link>
		<comments>http://www.jwse.nl/blog/?p=215#comments</comments>
		<pubDate>Thu, 24 Sep 2009 12:36:07 +0000</pubDate>
		<dc:creator>jwolsink</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=215</guid>
		<description><![CDATA[In this article i will explain the features of the Spring Faces Tag library. Although this library has some nice functions, the amount of documentation on the net is very scarce. To get started i have opened the spring-faces.tld inside the spring-faces.jar. The table below shows the available tags in the library. I have created [...]]]></description>
			<content:encoded><![CDATA[<p>In this article i will explain the features of the Spring Faces Tag library. Although this library has some nice functions, the amount of documentation on the net is very scarce. To get started i have opened the spring-faces.tld inside the spring-faces.jar. The table below shows the available tags in the library. I have created this table with a little xlst magic.</p>
<p><a href='http://www.jwse.nl/blog/wp-content/uploads/2009/09/tablib-table.html'>Spring Faces taglib</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=215</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create custum labels for enumerated types in JSF</title>
		<link>http://www.jwse.nl/blog/?p=201</link>
		<comments>http://www.jwse.nl/blog/?p=201#comments</comments>
		<pubDate>Thu, 24 Sep 2009 09:01:50 +0000</pubDate>
		<dc:creator>jwolsink</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JSF]]></category>

		<guid isPermaLink="false">http://www.jwse.nl/blog/?p=201</guid>
		<description><![CDATA[In this article i will show you how to create custom labels for Java Enum types with a custom JSF converter. Click here to download the  example application. To run the example application you need Maven2. Simple type mvn jetty:run to start the embedded Jetty container. After a few seconds you can point your browser [...]]]></description>
			<content:encoded><![CDATA[<p>
In this article i will show you how to create custom labels for Java Enum types with a custom JSF converter. Click <a href="http://www.jwse.nl/blog/wp-content/uploads/2009/09/enumsample.zip">here </a>to download the  example application. To run the example application you need Maven2. Simple type <code>mvn jetty:run</code> to start the embedded Jetty container. After a few seconds you can point your browser to http://localhost:8080/enumsample to see the application up and running.
</p>
<p>
To convert an enum type to a more friendly label, i&#8217;ve created a custom enum type converter. As you can see in the code below, that converter translate an enum value to a label in the message bundle. Based on the locale of your browser a localized messege will be returned.
</p>
<pre name="code" class="java">
package nl.jwse.sample.enumsample.converter;

import java.util.Locale;
import java.util.ResourceBundle;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

/**
 * Generic Enum Type converter. Converts an enum value to a language specific and display-friendly
 * label. The label should be defined in a messagebundle with the following convention.
 *
 * [Full enum classname].[Enum field]=Enter displaylabel here.
 *
 * i.e.
 *
 * nl.jwse.sample.enumsample.type.Card.HEARTS=Harten
 *
 * @author Jeroen Wolsink
 *
 */
public class EnumTypeConverter implements Converter {

	@SuppressWarnings("unchecked")
	public Object getAsObject(FacesContext fc, UIComponent comp,
			String value) {
		Class enumType = comp.getValueExpression("value").getType(fc.getELContext());
		return Enum.valueOf(enumType, value);
	}

	public String getAsString(FacesContext fc, UIComponent component,
			Object object) {
		if (object == null) {
			return null;
		}
		Enum<?> type = (Enum<?>) object;

		return getEnumLabel(type, fc);
	}

	/**
	 * Creates a localized label for the enum type. The label must be
	 * defined in the resource bundle, or else the toString() value will
	 * bee returned.
	 * @param type EnumType
	 * @param fc FacesContext
	 * @return The label for the enumerated type
	 */
	private String getEnumLabel(Enum<?> type, FacesContext fc) {

		String label = null;

		String messageBundle = fc.getApplication().getMessageBundle();
		Locale locale = fc.getApplication().getDefaultLocale();
		ResourceBundle rb = ResourceBundle.getBundle(messageBundle, locale);
		try {
			String key = generateKey(type);
			label = rb.getString(key);
		} catch (Exception e) {
			label = type.toString();
		}

		return label;
	}

	/**
	 * Generates a message bundle key based on an Enum Type.
	 * @param type EnumType
	 * @return Message bundle key
	 */
	private String generateKey(Enum<?> type) {

		String className = type.getClass().getName();
		String key = className + '.' + type.toString();

		return key;
	}
}
</pre>
<p>
Before you can use the converter in your JSF page, the converter must be registered in the FacesContext.xml.
</p>
<pre name="code" class="xml">
<converter>
	<converter-id>enumTypeConverter</converter-id>
	<converter-class>nl.jwse.sample.enumsample.converter.EnumTypeConverter</converter-class>
</converter>
</pre>
<p>In the page you can add the converter to an outputText usering the converter=&#8221;enumTypeConverter&#8221; attribute. In the backingbean there is also a conversion for the Card enum type to a selectItem list. You can view the implementation in the sourcefiles of the example application</p>
<pre name="code" class="xml">
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:sf="http://www.springframework.org/tags/faces"
	xmlns:ctm="http://enumsample/jsf"
	template="layout/template.xhtml">

	<ui:define name="body">

		<h:panelGrid columns="2">
			<h:outputLabel for="cardType" value="#{msg.cardtype}" />
			<h:outputText id="cardType" value="#{enumSampleBB.card}" converter="enumTypeConverter" />

			<h:outputLabel for="cardSelect" value="#{msg.cardselect}" />
			<h:selectOneMenu id="cardSelect">
				<f:selectItems value="#{enumSampleBB.cardSelectItems}" />
			</h:selectOneMenu>

		</h:panelGrid>

	</ui:define>
</ui:composition>
</pre>
<p>
I hope this article was helpfull to you. Any comments are most welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jwse.nl/blog/?feed=rss2&amp;p=201</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
