<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Depressed Programmer</title>
	
	<link>http://depressedprogrammer.wordpress.com</link>
	<description>Because programming is depressing</description>
	<lastBuildDate>Thu, 13 Aug 2009 05:24:36 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain="depressedprogrammer.wordpress.com" port="80" path="/?rsscloud=notify" registerProcedure="" protocol="http-post" />
<image>
		<url>http://www.gravatar.com/blavatar/82a04ca881a41d7ee94d49a6224d8db3?s=96&amp;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Depressed Programmer</title>
		<link>http://depressedprogrammer.wordpress.com</link>
	</image>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Geeky" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>What files changed in WordPress 2.8.4? The proper way to upgrade patches</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/vDQcQU3_bFM/</link>
		<comments>http://depressedprogrammer.wordpress.com/2009/08/13/what-files-changed-in-wordpress-2-8-4-the-proper-way-to-upgrade-patches/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 05:24:36 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Files Changed]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[Upgrading]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=107</guid>
		<description><![CDATA[I run raptorsrepublic.com which uses WordPress with some pretty heavy customizations here and there so every time WordPress releases an upgrade I&#8217;m very wary of doing it because I just don&#8217;t know how it&#8217;ll effect the platform.  Partial file copying with FTP can really throw you a curveball and if one file gets corrupted [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=107&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I run <a href="http://raptorsrepublic.com">raptorsrepublic.com</a> which uses WordPress with some pretty heavy customizations here and there so every time WordPress releases an upgrade I&#8217;m very wary of doing it because I just don&#8217;t know how it&#8217;ll effect the platform.  Partial file copying with FTP can really throw you a curveball and if one file gets corrupted it&#8217;ll take you hours to find out which one.  </p>
<p>I think the best way of upgrading WordPress installations is by only copying files that changed over patch releases (e.g.: 2.8.2, 2.8.3 and 2.8.4).  If there&#8217;s a database change things get a little more complicated but in most patch releases that&#8217;s not the case.  </p>
<p>The way you find out what files were changed is by accessing the WordPress SVN repository and running the svn diff command.  Here is the commands one need to run and the output that follows it.  I&#8217;m running this on a Linux box with SVN installed.  You could also do it in windows if you <a href="http://subversion.tigris.org/getting.html#windows">download the binaries</a>.</p>
<pre>
svn diff --summarize http://core.svn.wordpress.org/tags/2.8.3/ http://core.svn.wordpress.org/tags/2.8.4/
M      http://core.svn.wordpress.org/tags/2.8.4/wp-login.php
M      http://core.svn.wordpress.org/tags/2.8.4/wp-includes/version.php
M      http://core.svn.wordpress.org/tags/2.8.4/readme.html
</pre>
<p>This means three files changed between the two versions as M stands for modified.  That value could also be A for added and D for deleted.  If you&#8217;d like to see what the actual changes were just get rid of the <code>--summarize</code> part.  I copied these three files over to my WordPress installation and I&#8217;m done!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=107&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/QwDIgPzcvZ2HS-jbLriqAqLBmeQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/QwDIgPzcvZ2HS-jbLriqAqLBmeQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/QwDIgPzcvZ2HS-jbLriqAqLBmeQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/QwDIgPzcvZ2HS-jbLriqAqLBmeQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/vDQcQU3_bFM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2009/08/13/what-files-changed-in-wordpress-2-8-4-the-proper-way-to-upgrade-patches/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2009/08/13/what-files-changed-in-wordpress-2-8-4-the-proper-way-to-upgrade-patches/</feedburner:origLink></item>
		<item>
		<title>Integrating vBulletin with a WordPress theme</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/BFW7xpKL6Cc/</link>
		<comments>http://depressedprogrammer.wordpress.com/2009/07/06/integrating-vbulletin-with-a-wordpress-theme/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 22:56:53 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Footer]]></category>
		<category><![CDATA[Header]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Templates]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[vBulletin]]></category>
		<category><![CDATA[vBullettin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=99</guid>
		<description><![CDATA[OK, so you have a WordPress blog and are thinking about adding a vBulletin message board to it and want it to appear seamlessly within your WP theme.   This post will show you how to do it.
The way you go about accomplishing this is by creating two Plugins under vBulletin.  Before we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=99&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>OK, so you have a WordPress blog and are thinking about adding a vBulletin message board to it and want it to appear seamlessly within your WP theme.   This post will show you how to do it.</p>
<p>The way you go about accomplishing this is by creating two Plugins under vBulletin.  Before we do anything we have to make sure that the Plugin/Hook system is enabled.  For this select <em>vBulletin Options</em> under the <em>vBulletin Options</em> from the control panel.  Select the <em>Plugin/Hook System</em> option in the select list and make sure its enabled.  Once you&#8217;ve done that, you&#8217;ll need to create a couple plugins.  Click on the <em>Add New Plugin</em> option under the <em>Plugins &amp; Products</em> on the left hand side of the control panel.  Create a plugin with the <em>Hook Location</em> specified as <em>global_start</em> and the default execution order.  Give it the title of <em>WP Header</em> and in the <em>Plugin PHP Code</em> field, write the following:</p>
<pre class="brush: php;">
ob_start();
   include('../path/to/wp-load.php');
   include('../blog/wp-content/themes/sandbox/header.php');
   $wp_header = ob_get_contents();
ob_end_clean();
</pre>
<p>Now let&#8217;s examine what I did here.  Bascially, I&#8217;m invoking two WordPress PHP files, <em>wp-load.php</em> from the main installation and <em>header.php</em> from my theme&#8217;s directory.  I capture the content of it in the <code>$wp_header</code> variable which we&#8217;ll use later.</p>
<p>Make sure you change the plugin to be active by clicking on the <em>Yes</em> radio button and save the plugin.</p>
<p>Now we&#8217;ll create another plugin for the footer.  Once again, specify the <i>Hook Location</i> as <i>global_start</i>, give it the title of <i>WP Footer</i> and select the default execution order.  In the <i>Plugin PHP Code</i> field write the following:</p>
<pre class="brush: php;">
ob_start();
   include('../blog/wp-content/themes/sandbox/footer.php');
   $wp_footer = ob_get_contents();
ob_end_clean();
</pre>
<p>In this plugin we&#8217;re capturing the theme&#8217;s <i>footer.php</i> in the <code>$wp_footer</code> variable.  </p>
<p>Now we need to insert the two pieces of data we captured into the vBulletin theme.  For that let&#8217;s go to <i>Style Manager</i> under the <i>Styles &amp; Templates</i> group in the left control panel.  Once there, select <i>Edit Templates</i> from the drop down list which should give you a listing of all the editable files in your theme.  Double-click on <i>header</i> from the list and simply add the following line of code as the first line in the file:</p>
<pre class="brush: php;">
$wp_header
</pre>
<p>Save it and go back to the list of editable files and edit <i>footer</i>.  Make sure the following line of code is the last line in the file:</p>
<pre class="brush: php;">
$wp_footer
</pre>
<p>Save it and you&#8217;re done.</p>
<p>Well, almost.  Depending on the version of vBulletin you have you might get a PHP error which says something like &#8220;sanitize_url function has already been defined&#8221;.  Check the vBulletin file its happening in, download it and rename both occurrences of the function to something like <code>vb_sanitize_url</code> and now you&#8217;re done.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=99&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/V3K1QfHyQFv6jg_eUKuGhuinUX0/0/da"><img src="http://feedads.g.doubleclick.net/~a/V3K1QfHyQFv6jg_eUKuGhuinUX0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/V3K1QfHyQFv6jg_eUKuGhuinUX0/1/da"><img src="http://feedads.g.doubleclick.net/~a/V3K1QfHyQFv6jg_eUKuGhuinUX0/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/BFW7xpKL6Cc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2009/07/06/integrating-vbulletin-with-a-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2009/07/06/integrating-vbulletin-with-a-wordpress-theme/</feedburner:origLink></item>
		<item>
		<title>Conditionally printing HTML tags in JSF Facelets</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/SwBOzXoNBMY/</link>
		<comments>http://depressedprogrammer.wordpress.com/2009/06/08/conditionally-printing-html-tags-in-jsf-facelets/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 17:20:00 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Facelets]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=89</guid>
		<description><![CDATA[This took me a bit to figure out so I thought I&#8217;d post it.
Say you&#8217;re using JSF and want to conditionally print some HTML tags in your Facelet that could, technically speaking, result in non well-formed markup.  You can&#8217;t really do it.  Printing something like  is illegal as it&#8217;ll complain about the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=89&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This took me a bit to figure out so I thought I&#8217;d post it.</p>
<p>Say you&#8217;re using JSF and want to conditionally print some HTML tags in your Facelet that could, technically speaking, result in non well-formed markup.  You can&#8217;t really do it.  Printing something like <code></code> is illegal as it&#8217;ll complain about the &lt; and &gt; characters being in there.  Using the  tag doesn&#8217;t work either, even if you wrap the content in a CDATA element.  Problem is that it&#8217;s preventing you from writing non well-formed markup in any which way.</p>
<p>One of the solutions is to force the rendering kit to not analyze the output for &#8220;well-formedness&#8221; by passing the HTML markup in a variable.  </p>
<p>In your <em>facelet.xhtml</em></p>
<pre class="brush: xml;">
&lt;h:outputText escape=&quot;false&quot;
              rendered=&quot;#{someCondition}&quot;
              value=&quot;#{messages['lessThan'].concat('ul').concat(messages['greaterThan'])}&quot;/&gt;
</pre>
<p>In <em>messages.properties</em></p>
<pre>
lessThan=&lt;
greaterThan=&gt;
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=89&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/onpvO0NCBUErHbJeJcrjRNxrs9k/0/da"><img src="http://feedads.g.doubleclick.net/~a/onpvO0NCBUErHbJeJcrjRNxrs9k/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/onpvO0NCBUErHbJeJcrjRNxrs9k/1/da"><img src="http://feedads.g.doubleclick.net/~a/onpvO0NCBUErHbJeJcrjRNxrs9k/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/SwBOzXoNBMY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2009/06/08/conditionally-printing-html-tags-in-jsf-facelets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2009/06/08/conditionally-printing-html-tags-in-jsf-facelets/</feedburner:origLink></item>
		<item>
		<title>What the hell is the cause of this NullPointerException?</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/Sj9YITDRrIM/</link>
		<comments>http://depressedprogrammer.wordpress.com/2009/03/26/what-the-hell-is-the-cause-of-this-nullpointerexception/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 20:50:09 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cause]]></category>
		<category><![CDATA[IDEA]]></category>
		<category><![CDATA[IntelliJ]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[NullPointerException]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=86</guid>
		<description><![CDATA[It&#8217;s infinite deep!

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=86&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It&#8217;s infinite deep!</p>
<p><img src="http://depressedprogrammer.files.wordpress.com/2009/03/nullpointerexception-cause.jpg?w=936&#038;h=922" alt="nullpointerexception-cause" title="nullpointerexception-cause" width="936" height="922" class="alignnone size-full wp-image-85" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=86&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/sVA7WIKvkoOP_9Ri-LUhjpRIK_4/0/da"><img src="http://feedads.g.doubleclick.net/~a/sVA7WIKvkoOP_9Ri-LUhjpRIK_4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/sVA7WIKvkoOP_9Ri-LUhjpRIK_4/1/da"><img src="http://feedads.g.doubleclick.net/~a/sVA7WIKvkoOP_9Ri-LUhjpRIK_4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/Sj9YITDRrIM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2009/03/26/what-the-hell-is-the-cause-of-this-nullpointerexception/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2009/03/nullpointerexception-cause.jpg" medium="image">
			<media:title type="html">nullpointerexception-cause</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2009/03/26/what-the-hell-is-the-cause-of-this-nullpointerexception/</feedburner:origLink></item>
		<item>
		<title>IntelliJ Hilarity</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/i7_prGpbjLk/</link>
		<comments>http://depressedprogrammer.wordpress.com/2009/02/20/intellij-hilarity/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 19:40:01 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=73</guid>
		<description><![CDATA[Note that this is a very lame post.   IntelliJ IDEA is the greatest Java IDE in the world, his post does not &#8220;diss&#8221; it in any way, just pointing out something that was funny to me and only so because I&#8217;ve been at it for quite some time now.
I often have IntelliJ generate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=73&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Note that this is a very lame post.   IntelliJ IDEA is the greatest Java IDE in the world, his post does not &#8220;diss&#8221; it in any way, just pointing out something that was funny to me and only so because I&#8217;ve been at it for quite some time now.</p>
<p>I often have IntelliJ generate the equals() and hashCode() methods for me when programming @Entity beans.  Here&#8217;s what it did for me:</p>
<p><img src="http://depressedprogrammer.files.wordpress.com/2009/02/equals.jpg?w=685&#038;h=252" alt="equals" title="equals" width="685" height="252" class="alignnone size-full wp-image-74" /></p>
<p>Makes sense, but notice how the last if statement is highlighted? That&#8217;s IntelliJ&#8217;s way of telling me that it can make things better which is a little weird because IntelliJ&#8217;s the guy that generated the code for me.  Anyway, I see what the hint has to say:</p>
<p><img src="http://depressedprogrammer.files.wordpress.com/2009/02/hint.jpg?w=425&#038;h=234" alt="hint" title="hint" width="425" height="234" class="alignnone size-full wp-image-75" /></p>
<p>It&#8217;s saying that it can make some of these ifs redundant and sure enough once I take the hint the return clause is joined with last if like so:</p>
<p><img src="http://depressedprogrammer.files.wordpress.com/2009/02/first-hint.jpg?w=610&#038;h=35" alt="first-hint" title="first-hint" width="610" height="35" class="alignnone size-full wp-image-76" /></p>
<p>It&#8217;s all good but notice now that it now highlighted the previous if statement and if I accept it, it&#8217;ll continue doing the same thing over and over again.  I&#8217;ll accept all the improvements it wants to make and I&#8217;ll finally end up with this method which is logically equivalent to what I showed you in the first picture:</p>
<p><img src="http://depressedprogrammer.files.wordpress.com/2009/02/final.jpg?w=557&#038;h=150" alt="final" title="final" width="557" height="150" class="alignnone size-full wp-image-77" /></p>
<p>The difference isn&#8217;t that great in an entity with three properties but you get the point about tertiary statements and IntelliJ&#8221;s love for them.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=73&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/EmBFAf3JWFAokEiDFythc9PKa-s/0/da"><img src="http://feedads.g.doubleclick.net/~a/EmBFAf3JWFAokEiDFythc9PKa-s/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EmBFAf3JWFAokEiDFythc9PKa-s/1/da"><img src="http://feedads.g.doubleclick.net/~a/EmBFAf3JWFAokEiDFythc9PKa-s/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/i7_prGpbjLk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2009/02/20/intellij-hilarity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2009/02/equals.jpg" medium="image">
			<media:title type="html">equals</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2009/02/hint.jpg" medium="image">
			<media:title type="html">hint</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2009/02/first-hint.jpg" medium="image">
			<media:title type="html">first-hint</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2009/02/final.jpg" medium="image">
			<media:title type="html">final</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2009/02/20/intellij-hilarity/</feedburner:origLink></item>
		<item>
		<title>Writing Custom Facelet JSF Components</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/WsZCocW6Xjc/</link>
		<comments>http://depressedprogrammer.wordpress.com/2008/12/21/writing-custom-facelet-jsf-components/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 06:59:42 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Facelets]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jee]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=63</guid>
		<description><![CDATA[Writing Facelet JSF Components is NOT the same thing as writing custom JSP-based JSF Components.  Once you get past that it turns out they&#8217;re not hard to write at all.  There&#8217;s no mucking around with JSP tag libraries, TLD files and other such archaic nonsense.
You need to edit create/edit three files in total. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=63&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Writing Facelet JSF Components is NOT the same thing as writing custom JSP-based JSF Components.  Once you get past that it turns out they&#8217;re not hard to write at all.  There&#8217;s no mucking around with JSP tag libraries, TLD files and other such archaic nonsense.</p>
<p>You need to edit create/edit three files in total.  Here&#8217;s an example of a Facelet JSF component that prints out a table row when it is nested around another UI component.  For example, the component if used the following way:</p>
<pre class="brush: java;">
&lt;arse:tableRow&gt;
    &lt;h:inputText id=&quot;myId&quot; label=&quot;My Label&quot;/&gt;
&lt;/arse:tableRow&gt;
</pre>
<p>would print</p>
<pre class="brush: xml;">
&lt;tr&gt;
  &lt;td&gt;My Label&lt;/td&gt;
  &lt;td&gt;&lt;input type=&quot;text&quot; ..../&gt;&lt;/td&gt;
&lt;/tr&gt;
</pre>
<p>Simple, right?  Here&#8217;s the three files you have to create/edit:</p>
<h2><code>faces-config.xml</code></h2>
<p>Make sure the following is present in your faces-config.xml:</p>
<pre class="brush: xml;">
    &lt;component&gt;
        &lt;component-type&gt;tableRow&lt;/component-type&gt;
        &lt;component-class&gt;com.arsenalist.UITableRow&lt;/component-class&gt;
    &lt;/component&gt;
</pre>
<h2><code>META-INF/mytag-taglib.xml</code></h2>
<p>Create a file withe following contents under your META-INF folder:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE facelet-taglib PUBLIC
  &quot;-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN&quot;
  &quot;http://java.sun.com/dtd/facelet-taglib_1_0.dtd&quot;&gt;

&lt;facelet-taglib&gt;
    &lt;namespace&gt;http://www.arsenalist.com/jsf/util&lt;/namespace&gt;
    &lt;tag&gt;
        &lt;tag-name&gt;tableRow&lt;/tag-name&gt;
        &lt;component&gt;
            &lt;component-type&gt;tableRow&lt;/component-type&gt;
            &lt;renderer-type&gt;tableRow.renderer&lt;/renderer-type&gt;
        &lt;/component&gt;
    &lt;/tag&gt;
&lt;/facelet-taglib&gt;
</pre>
<p>Note the namespace, that&#8217;s what you&#8217;ll need to refer in the Facelet before using the tag, e.g:</p>
<pre class="brush: xml;">
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:arse=&quot;http://www.arsenalist.com/jsf/util&quot;
      . . .
</pre>
<h2><code>UITableRow.java</code></h2>
<p>Finally, create the actual component.  Here&#8217;s an example of a component that wraps the child elements around a tr and a couple tds.  We must override <code>getRendersChildren()</code> to return true because it is the component&#8217;s duty to render its children (since we&#8217;re wrapping it around stuff).</p>
<pre class="brush: java;">
package com.arsenalist;

import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import java.io.IOException;

/**
 * This class renders a table row.  It must contain two controls, the label and control to render.
 * @author Zarar Siddiqi
 */
public class UITableRow extends UIOutput {

    public UITableRow() {
        setRendererType(null);
    }

    public boolean getRendersChildren() {
        return true;
    }

    public void encodeBegin(FacesContext facesContext) throws IOException {
        // We're rendering a table row
        facesContext.getResponseWriter().startElement(&quot;tr&quot;, null);
    }

    @Override
    public void encodeChildren(FacesContext facesContext) throws IOException {
        ResponseWriter writer = facesContext.getResponseWriter();

        UIComponent control = getChildren().get(0);

        writer.startElement(&quot;td&quot;, label);
        // Label goes inside td
        writer.startElement(&quot;label&quot;, label);
        writer.writeAttribute(&quot;for&quot;, control.getClientId(facesContext), null);

        writer.write((String) control.getAttributes().get(&quot;label&quot;));
        writer.endElement(&quot;label&quot;);
        writer.endElement(&quot;td&quot;);

        // Div element goes in the second along with the control
        writer.startElement(&quot;td&quot;, control);
        control.encodeEnd(facesContext);
        writer.endElement(&quot;td&quot;);
    }

    @Override
    public void encodeEnd(FacesContext facesContext) throws IOException {
        ResponseWriter writer = facesContext.getResponseWriter();
        writer.endElement(&quot;tr&quot;);
    }

    @Override
    public String getFamily() {
        return COMPONENT_TYPE;
    }
}
</pre>
<p>And that&#8217;s that.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=63&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/B1jzilQw6bT9Jwa1Wu4zf7LvSls/0/da"><img src="http://feedads.g.doubleclick.net/~a/B1jzilQw6bT9Jwa1Wu4zf7LvSls/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/B1jzilQw6bT9Jwa1Wu4zf7LvSls/1/da"><img src="http://feedads.g.doubleclick.net/~a/B1jzilQw6bT9Jwa1Wu4zf7LvSls/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/WsZCocW6Xjc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2008/12/21/writing-custom-facelet-jsf-components/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2008/12/21/writing-custom-facelet-jsf-components/</feedburner:origLink></item>
		<item>
		<title>GMail Bug – Where are my two messages?</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/n4hVbmnYP3M/</link>
		<comments>http://depressedprogrammer.wordpress.com/2008/11/14/gmail-bug-where-are-my-two-messages/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 00:05:44 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[GMail]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=56</guid>
		<description><![CDATA[It says I have two messages, but where the hell are they?

Even the Firefox Google Notifier agrees with me:
If you&#8217;ve seen these messages, let me know:

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=56&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It says I have two messages, but where the hell are they?</p>
<p><a href="http://depressedprogrammer.files.wordpress.com/2008/11/gmail-bug-where-are-my-messages.jpg"><img style="border:1px solid black;" src="http://depressedprogrammer.files.wordpress.com/2008/11/gmail-bug-where-are-my-messages.jpg" alt="gmail-bug-where-are-my-messages" title="gmail-bug-where-are-my-messages" class="aligncenter size-full wp-image-57" /></a></p>
<p>Even the Firefox Google Notifier agrees with me:</p>
<p>If you&#8217;ve seen these messages, let me know:</p>
<p><a href="http://depressedprogrammer.files.wordpress.com/2008/11/firefox-agrees.jpg"><img src="http://depressedprogrammer.files.wordpress.com/2008/11/firefox-agrees.jpg" alt="firefox-agrees" title="firefox-agrees" class="aligncenter size-full wp-image-61" style="border:1px solid black;" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=56&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/33ZcU8hrRxogZ2ibySvQe52rqg8/0/da"><img src="http://feedads.g.doubleclick.net/~a/33ZcU8hrRxogZ2ibySvQe52rqg8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/33ZcU8hrRxogZ2ibySvQe52rqg8/1/da"><img src="http://feedads.g.doubleclick.net/~a/33ZcU8hrRxogZ2ibySvQe52rqg8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/n4hVbmnYP3M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2008/11/14/gmail-bug-where-are-my-two-messages/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2008/11/gmail-bug-where-are-my-messages.jpg" medium="image">
			<media:title type="html">gmail-bug-where-are-my-messages</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2008/11/firefox-agrees.jpg" medium="image">
			<media:title type="html">firefox-agrees</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2008/11/14/gmail-bug-where-are-my-two-messages/</feedburner:origLink></item>
		<item>
		<title>JSF Seam Validation + Custom Messages + Annotations + Internationalization</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/XtNiST9rehA/</link>
		<comments>http://depressedprogrammer.wordpress.com/2008/06/24/jsf-seam-validation-custom-messages-annotations-internationalization/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 20:02:07 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[Internationalization]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Seam]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=54</guid>
		<description><![CDATA[Validation is one of the first things you test out when evaluating a web framework and its often one of the most time consuming to wrap your head around.   In this post I&#8217;ll talk about three types of validation mechanisms present in JBoss&#8217; Seam which will get you on your way towards validating [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=54&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Validation is one of the first things you test out when evaluating a web framework and its often one of the most time consuming to wrap your head around.   In this post I&#8217;ll talk about three types of validation mechanisms present in JBoss&#8217; Seam which will get you on your way towards validating web forms without too much pain:</p>
<p>I&#8217;m going to cover three cases:</p>
<ol>
<li>Validating required fields without using annotations</li>
<li>Validating manually and displaying custom messages</li>
<li>Validating fields using Hibernate annotations in Seam beans</li>
</ol>
<p>We&#8217;ll also display messages using a simple resource bundle (<code>java.util.ResourceBundle</code>) which will allow us to internationalize our forms and messages.  Let&#8217;s dive into the examples:</p>
<h2>Validating required fields without using annotations</h2>
<p>This is the most general case, you want to force the user to input something in your text fields and if they don&#8217;t, you want to display a message telling them just that.  </p>
<p>Here&#8217;s a JSF form which asks for a username and password:</p>
<pre class="brush: java;">
&lt;h:messages/&gt;
&lt;h:form id=&quot;LoginForm&quot;&gt;
    &lt;table&gt;
	&lt;tr&gt;
	    &lt;td&gt;&lt;h:outputText value=&quot;#{messages['login.username']}&quot;/&gt;&lt;/td&gt;
	    &lt;td&gt;
		&lt;h:inputText required=&quot;true&quot; value=&quot;#{user.username}&quot; label=&quot;#{messages['login.username']}&quot;/&gt;
	    &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
	    &lt;td&gt;&lt;h:outputText value=&quot;#{messages['login.password']}&quot;/&gt;&lt;/td&gt;
	    &lt;td&gt;
		&lt;h:inputSecret required=&quot;true&quot; value=&quot;#{user.password}&quot; label=&quot;#{messages['login.password']}&quot;/&gt;
	    &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
	    &lt;td&gt;&lt;/td&gt;
	    &lt;td&gt;
		&lt;h:commandButton action=&quot;#{loginAction.login}&quot;
				 value=&quot;#{messages['button.login']}&quot;/&gt;
	    &lt;/td&gt;
	&lt;/tr&gt;
    &lt;/table&gt;
&lt;/h:form&gt;
</pre>
<p>Specifying <b>required=&#8221;true&#8221;</b> is all you need to validate required fields.  The matter of displaying messages is left to the <code>&lt;h:messages/&gt;</code> tag which iterates through the list of messages generated by the validation phase and displays them sequentially.</p>
<p>By default validation messages are displayed in a format that is not very intuitive, in order to change the format you must override a property in your <code>messages.properties</code> file located at the root of your classpath:</p>
<p><code>javax.faces.component.UIInput.REQUIRED={0} is a required field.</code></p>
<p>The placeholder is {0} is automatically filled by the <i>label</i> attribute of the <code>&lt;h:inputText&gt;</code> tag.  So in the above case if login.username is defined to be &#8220;Username&#8221; in the resource bundle, the messages that will be printed will be: Username is a required field.</p>
<p>If validation passes, then the <code>login()</code> method on the bean referenced by loginAction will be called (as specified by the <code>&lt;h:commandButton&gt;</code> tag.</p>
<h2>Validating manually and displaying custom messages</h2>
<p>This is probably the most powerful way of validating user input &#8211; programmatically.  Let&#8217;s face it, the built-in validators can only do so much, at some point you end up writing java code to validate input by checking it against a database or queue etc.  Going back to the login example, say we need to check the values supplied by the user against a database and if they match, let them into the system and if they don&#8217;t, kick them back to the login page with a message.  The login page does not change, let&#8217;s get to the LoginAction class:</p>
<pre class="brush: java;">
@Name( &quot;loginAction&quot; )
public class LoginAction {

    @In
    private User user;

    @In(create=true)
    private FacesMessages facesMessages;

    public String login() {
        if (user.getUsername().equals( &quot;Arsenalist&quot; ) &amp;&amp; user.getPassword().equals( &quot;Raptors&quot; )) {
            return &quot;success&quot;;
        } else {
            facesMessages.addFromResourceBundle(&quot;login.failed&quot;);
            return &quot;failure&quot;;
        }
    }
}
</pre>
<p>It&#8217;s very obvious what&#8217;s happening here.  The injected instance of <code>FacesMessages</code> allows you to use its <code>addFromResourceBundle()</code> method to specify a message that will be displayed in the view resulting from returning &#8220;failure&#8221;.  Just for completeness sakes, here&#8217;s the <i>faces-config.xml</i> navigation rule:</p>
<pre class="brush: xml;">

    &lt;navigation-rule&gt;
        &lt;from-view-id&gt;/pages/login.xhtml&lt;/from-view-id&gt;
        &lt;navigation-case&gt;
            &lt;from-action&gt;#{loginAction.login}&lt;/from-action&gt;
            &lt;from-outcome&gt;success&lt;/from-outcome&gt;
            &lt;to-view-id&gt;/pages/home.xhtml&lt;/to-view-id&gt;
        &lt;/navigation-case&gt;
        &lt;navigation-case&gt;
            &lt;from-action&gt;#{loginAction.login}&lt;/from-action&gt;
            &lt;from-outcome&gt;failure&lt;/from-outcome&gt;
            &lt;to-view-id&gt;/pages/login.xhtml&lt;/to-view-id&gt;
        &lt;/navigation-case&gt;
    &lt;/navigation-rule&gt;
</pre>
<h2>Validating fields using Hibernate annotations in Seam beans</h2>
<p>The next step is to apply more complex validation without resorting to writing Java code and for that Seam relies on Hibernate&#8217;s validation framework.  As an aside, this dependency is probably the most annoying thing about Seam at this point but it works well enough to look past.</p>
<p>Let&#8217;s say we need to force the value of username to be atleast 5 characters.  In order to do this we need to annotate two things:</p>
<ol>
<li>The injected user variable in <code>LoginAction</code> so Seam knows to validate it</li>
<li>The <code>User</code> objects properties to specify what to validate.</li>
<ol>
<p>Here&#8217;s the relevant piece in <code>LoginAction.java</code>:</p>
<pre class="brush: java;">
@Name( &quot;loginAction&quot; )
public class LoginAction {
    @In @Valid
    private User user;
    public String login() {
        . . . .
    }
</pre>
<p>Here&#8217;s the relevant piece in <code>User.java</code>:</p>
<pre class="brush: java;">
@Name( &quot;user&quot; )
public class User {

    private String username;
    private String password;

    @Length(min=5, message= &quot;#{messages['login.username.length']}&quot; )
    public String getUsername() {
        return username;
    }
    . . . .
</pre>
<p>Notice how we&#8217;re using a resource key inside an annotation to print the message.  This will look for a resource bundle called <i>messages</i> and inside it for the <i>login.username.length</i> property to retrieve the message.  You could alternately just write the message in plain old English inside the annotation but why would you want to when you can internationalize.  </p>
<p>The last thing we need to do is tell the JSF page that it will need validation (I think this is a somewhat redundant step since the bean is already annotated but nonetheless it is required).  You must wrap the fields of the login form around the &lt;s:validateAll&gt; tag like so:</p>
<pre class="brush: java;">
&lt;h:messages/&gt;
&lt;h:form id=&quot;LoginForm&quot;&gt;
    &lt;s:validateAll&gt;
            . . . .
	    &lt;h:outputText value=&quot;#{messages['login.username']}&quot;/&gt;&lt;/td&gt;
            . . . .
    &lt;/s:validateAll&gt;
&lt;/h:form&gt;
</pre>
<p><b>Note:</b> Be sure to specify required=&#8221;true&#8221; for the fields you want to apply annotation validations to.  Otherwise, you&#8217;ll see some very weird results such as only non-blank fields getting the annotation validations applied to while the blank fields get considered valid.</p>
<p>Here&#8217;s a list of annotations that you can use to validate java beans:</p>
<ul>
<li>@Length(min=, max=) Checks whether the string length matches the range</li>
<li>@Max(value=) Checks that the value is less than or equal to the max</li>
<li>@Min(value=) Checks that the value is greater than or equal to the min</li>
<li>@NotNull Checks that the value is not null</li>
<li>@Past For a date object, checks that the date is in the past</li>
<li>@Future For a date object, checks that the date is in the future</li>
<li>@Pattern(regex=&#8221;regexp&#8221;, flag=) For a string, checks that the string matches this pattern</li>
<li>@Range(min=, max=) Checks whether the value is between the min and the max</li>
<li>@Size(min=, max=) For collections, checks that the size is between the two</li>
<li>@AssertFalse Asserts that the evaluation of the method is false</li>
<li>@AssertTrue Asserts that the evaluation of the method is true</li>
<li>@Valid For a collection or a map, checks that all the objects they contain are valid</li>
<li>@Email Checks whether the string conforms to the email address specification</li>
</ul>
<p>That&#8217;s all there is to it.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/depressedprogrammer.wordpress.com/54/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/depressedprogrammer.wordpress.com/54/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=54&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/1OT5bIgoXrxcBVJOT9NvIdf90x0/0/da"><img src="http://feedads.g.doubleclick.net/~a/1OT5bIgoXrxcBVJOT9NvIdf90x0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1OT5bIgoXrxcBVJOT9NvIdf90x0/1/da"><img src="http://feedads.g.doubleclick.net/~a/1OT5bIgoXrxcBVJOT9NvIdf90x0/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/XtNiST9rehA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2008/06/24/jsf-seam-validation-custom-messages-annotations-internationalization/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2008/06/24/jsf-seam-validation-custom-messages-annotations-internationalization/</feedburner:origLink></item>
		<item>
		<title>Free Euro 2008 Pool Script</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/CIvkjn6fV3Y/</link>
		<comments>http://depressedprogrammer.wordpress.com/2008/05/26/free-euro-2008-pool-script/#comments</comments>
		<pubDate>Mon, 26 May 2008 21:34:10 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[Euro 2008]]></category>
		<category><![CDATA[FIFA]]></category>
		<category><![CDATA[Office Pool]]></category>
		<category><![CDATA[Pool]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=51</guid>
		<description><![CDATA[OK, I don&#8217;t contribute much to the software community but I&#8217;m feeling generous today.
Since I run this pool at my office and for some unknown and weird reasons the link is #1 on Google for Euro 2008 Office Pool, I figured I&#8217;d share the piece of code that runs that &#8220;system&#8221; with the public.  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=51&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Fsoccer%2FFree_Euro_2008_Pool_Script' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe>OK, I don&#8217;t contribute much to the software community but I&#8217;m feeling generous today.</p>
<p>Since I run <a href="http://haroon.sis.utoronto.ca/football/">this pool</a> at my office and for some unknown and weird reasons the link is <a href="http://www.google.ca/search?hl=en&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;hs=HcP&amp;q=euro+2008+office+pool&amp;btnG=Search&amp;meta=">#1 on Google for Euro 2008 Office Pool</a>, I figured I&#8217;d share the piece of code that runs that &#8220;system&#8221; with the public.  </p>
<p>Its basically a PHP/MySQL app with a few tables that are self-explanatory (I hope).  You just enter who picked what teams and players and then just update the results as they happen &#8211; watch the entrants rise and fall as each team wins, loses or ties.  Its quite fun really, much better than doing cocaine.  The PDF form that entrants fill out is part of the zip along with everything else you need, but <a href="http://haroon.sis.utoronto.ca/football/EntryForm.pdf">here it is anyway</a> if you want to take a look.</p>
<p><a href="http://haroon.sis.utoronto.ca/football/football-v2.zip">Download the ZIP file here.</a>  All you really need to do is dump the schema in a MySQL 5 database (maybe even 4 might work), change the database info in ez_sql.php file (just replace INSERT_HOST tags etc.) and you&#8217;re good to go.</p>
<p>If you do feel like joining the pool, send me your entry form and $16 through PayPal to zarars at gmail</p>
<p><strong>Update:</strong> I&#8217;ve updated this post with an <a href="http://haroon.sis.utoronto.ca/football/football-v2.zip">improved version of this software</a> which includes sample data.  Here&#8217;s the <a href="http://haroon.sis.utoronto.ca/football/footballpool.zip">older version</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/depressedprogrammer.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/depressedprogrammer.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=51&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/87c8jhPwuY24cehmVgYPGSorMNU/0/da"><img src="http://feedads.g.doubleclick.net/~a/87c8jhPwuY24cehmVgYPGSorMNU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/87c8jhPwuY24cehmVgYPGSorMNU/1/da"><img src="http://feedads.g.doubleclick.net/~a/87c8jhPwuY24cehmVgYPGSorMNU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/CIvkjn6fV3Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2008/05/26/free-euro-2008-pool-script/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2008/05/26/free-euro-2008-pool-script/</feedburner:origLink></item>
		<item>
		<title>Worst Captcha Ever</title>
		<link>http://feedproxy.google.com/~r/Geeky/~3/f4lIDfQGDIw/</link>
		<comments>http://depressedprogrammer.wordpress.com/2008/04/20/worst-captcha-ever/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 14:58:29 +0000</pubDate>
		<dc:creator>Arsenalist</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[Captcha]]></category>
		<category><![CDATA[Cats]]></category>
		<category><![CDATA[JCaptcha]]></category>
		<category><![CDATA[Rapidshare]]></category>

		<guid isPermaLink="false">http://depressedprogrammer.wordpress.com/?p=44</guid>
		<description><![CDATA[I&#8217;m trying to download a file from the evil Rapidshare (who make you wait about 2 painful minutes before giving you the file) and just after the wait time is over, I get a Captcha looking like this:

WTF man? I mean, does it really need to be this hard? Are you telling me that it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=44&subd=depressedprogrammer&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Fprogramming%2FWorst_Captcha_Ever_3' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe>I&#8217;m trying to download a file from the evil Rapidshare (who make you wait about 2 painful minutes before giving you the file) and just after the wait time is over, I get a Captcha looking like this:</p>
<p><img src="http://depressedprogrammer.files.wordpress.com/2008/04/worstcaptchaever.jpg" alt="" class="alignnone size-full wp-image-45" /></p>
<p>WTF man? I mean, does it really need to be this hard? Are you telling me that it has come down to us hiding domestic animals in our captcha characters in order to hold off bots?  Plus, there are only 3 &#8220;letters&#8221; in that image but its asking for four.</p>
<p>This is a sad day for the HCI crowd.</p>
<p>On an unrelated note, <a href="http://depressedprogrammer.files.wordpress.com/2008/04/soma1.jpg">here&#8217;s my cat</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/depressedprogrammer.wordpress.com/44/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/depressedprogrammer.wordpress.com/44/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/depressedprogrammer.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/depressedprogrammer.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/depressedprogrammer.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/depressedprogrammer.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/depressedprogrammer.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/depressedprogrammer.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/depressedprogrammer.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/depressedprogrammer.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/depressedprogrammer.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/depressedprogrammer.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=depressedprogrammer.wordpress.com&blog=3517081&post=44&subd=depressedprogrammer&ref=&feed=1" /></div>
<p><a href="http://feedads.g.doubleclick.net/~a/LU9D4XXEv-0KXaFnaiKqVq2Q-8U/0/da"><img src="http://feedads.g.doubleclick.net/~a/LU9D4XXEv-0KXaFnaiKqVq2Q-8U/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/LU9D4XXEv-0KXaFnaiKqVq2Q-8U/1/da"><img src="http://feedads.g.doubleclick.net/~a/LU9D4XXEv-0KXaFnaiKqVq2Q-8U/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Geeky/~4/f4lIDfQGDIw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://depressedprogrammer.wordpress.com/2008/04/20/worst-captcha-ever/feed/</wfw:commentRss>
		<slash:comments>215</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e984466bc905c9e853fe3f9f8f913958?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">Arsenalist</media:title>
		</media:content>

		<media:content url="http://depressedprogrammer.files.wordpress.com/2008/04/worstcaptchaever.jpg" medium="image" />
	<feedburner:origLink>http://depressedprogrammer.wordpress.com/2008/04/20/worst-captcha-ever/</feedburner:origLink></item>
	</channel>
</rss>
