<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
	<title>mojavelinux.com</title>
	<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/" />
	<modified>2008-10-07T17:37:45Z</modified>
	<tagline>Open Source Advocacy</tagline>
	<id>tag:www.mojavelinux.com,2008://1</id>
	<generator url="http://www.movabletype.org/" version="2.661">Movable Type</generator>
	<copyright>Copyright (c) 2008, Dan Allen</copyright>
		<entry>
		<title>Seam in Action at JavaRanch: Round 2</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/10/seam_in_action_at_javaranch_round_2/index.php" />
		<modified>2008-10-07T17:37:45Z</modified>
		<issued>2008-10-07T13:37:45-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.102</id>
		<created>2008-10-07T17:37:45Z</created>
		<summary type="text/plain">Now that Seam in Action is finally complete, I&apos;m back for some more Q&amp;A on the JavaRanch forums. This is your opportunity to challenge the...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Seam in Action</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>Now that <a href="http://mojavelinux.com/seaminaction">Seam in Action</a> is finally complete, I'm back for some more Q&A on the <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&amp;f=83">JavaRanch forums</a>. This is your opportunity to challenge the author on some tough (or not so tough) Seam questions and win a signed copy of the book. The participation last time was great and we just about emptied the water cooler discussing Seam-related topics.</p>
<p>The giveaway starts on Tuesday, October 7th 2008.<br />
The drawing will be held on Friday, October 10th 2008.</p>
</blockquote>
<p>See you at the ranch! And thanks for those that wished me luck on finishing the book during the last promotion. It must have done the trick, because I had the book out only a couple of weeks later.</p>]]>
			
		</content>
	</entry>
		<entry>
		<title>My wishlist for GlassFish</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/10/my_wishlist_for_glassfish/index.php" />
		<modified>2008-10-06T06:08:57Z</modified>
		<issued>2008-10-06T02:08:57-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.101</id>
		<created>2008-10-06T06:08:57Z</created>
		<summary type="text/plain">I received a response to my post about how to deploy a seam-gen project to GlassFish from the GlassFish Group Project Manager, John Clingan. He...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Java</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>I received a <a href="http://www.mojavelinux.com/blog/archives/2008/10/deploying_a_seamgen_project_to_glassfish/#comment1137">response</a> to my post about how to <a href="http://www.mojavelinux.com/blog/archives/2008/10/deploying_a_seamgen_project_to_glassfish/">deploy a seam-gen project to GlassFish</a> from the GlassFish Group Project Manager, John Clingan. He asked me to provide feedback on how to improve GlassFish. I drafted a message to him with several items, which I want to share publicly.</p>
<p>My first long standing wish has already been addressed by a <a href="http://blogs.sun.com/jluehe/entry/retain_session_data_during_redeployment">recent announcement</a>. In GlassFish V3, session data is now retained across a restart. It has always been an Achilles heel of Java EE that redeployments are disruptive to manual testing (let's face it, that's how most developers work). Hot deployment was a step forward, but ultimately preserving session data is what makes the deployment truly smooth. Good job and keep working on ways to make a redeployment or partial deployment transparent to the developer's process.</p>
<p>Here are my other "bones" I have with GlassFish:</p>
<ol>
<li>The JNDI MailSession in GlassFish does not support authentication over SMTP. In my opinion, this is a huge let down. With Gmail, and other providers, allowing their mail server to be used for free, it's the absolute easiest way for Java EE developers to setup JavaMail. GlassFish is all about easy, but alas, this task is not so since there is no support for authentication over SMTP.</li>
<li>It's not possible to establish a database connection in the console that uses an empty password. While it may appear silly at first, know that embedded databases such a HSQLDB work out of the box with the username "sa" and a blank password, so it just causes an inconvenience.</li>
<li>Developers have responded to my last post about GlassFish complaining that they cannot get the exploded EAR seam-gen project to work. There are two parts to this. First, perhaps there are some limitations with the exploded EAR in GlassFish. Second, I think it would go a long way for GlassFish developers to work with Seam developers to document how to customize a seam-gen application to deploy under GlassFish.</li>
<li>asadmin is a great tool, but one of the things it lacks is a set of built-in Ant tasks that a developer can incorporate into their build. You may notice from the <a href="http://code.google.com/p/seaminaction/wiki/DeployingToGlassFish">wiki page</a> that I have to create an Ant macros that calls out to asadmin from the commandline. I think it would be worthwhile to make &lt;asadmin> a bonafide target in Ant. Any other build tool you want to target would also be helpful, but at the end of the day, Ant is king.</li>
</ol>
<p>By no means is this a comprehensive list, but just happens to be what has been on my mind lately. If I think of other ideas, I will likely follow up with another post. However, what I am really interested in is if you have suggestions for John and the GlassFish team. Feel free to post them in the comments.</p>
<p><strong>UPDATE:</strong> I forgot to mention that I was impressed by how quickly Sun picked up on my initial post and was willing to ask for input. It shows that Sun (specifically the GlassFish team) is keeping a thumb on the pulse of the community, which I feel is critical part of having a successful and useful project.</p>]]>
			
		</content>
	</entry>
		<entry>
		<title>An author&apos;s most proud moment</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/10/an_authors_most_proud_moment/index.php" />
		<modified>2008-10-03T07:50:00Z</modified>
		<issued>2008-10-03T03:50:00-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.99</id>
		<created>2008-10-03T07:50:00Z</created>
		<summary type="text/plain">There are many &quot;firsts&quot; in a person&apos;s life, but as you grow older you have to start working harder to achieve them. I certainly didn&apos;t...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Personal</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>There are many "firsts" in a person's life, but as you grow older you have to start working harder to achieve them. I certainly didn't slack off leading up to the moment when I could take my book off the bookstore shelf and hold it in my hands.</p>

<p><img src="/assets/pics/dan-holding-book.jpg" alt="Dan holding Seam in Action"/></p>

<p>Apart from experiencing this "first", I went into the bookstore to see my book because sometimes I forget that it actually exists outside of my office. Sure enough, there is was. And it was even facing out! (Honest, I did not give myself a better shelf placement).</p>

<p><img src="/assets/pics/dans-book-on-shelf.jpg" alt="Seam in Action on the shelf"/></p>

<p>While I am enjoying this hard-earned moment, at the same time I am starting to wonder whether I will have the energy to do it again. Having said that, you are probably wondering if I ever go on vacation. Well, here's proof that I do...occasionally.</p>

<p><img src="/assets/pics/dan-walking-on-beach.jpg" alt="Dan walking on beach"/></p>

<p>Granted, the day after this picture was taken (July 2008) I hopped on a plane to go to Italy for the Seam and Hibernate Planning Meeting. Hey, at least my feet touched the sand!</p>]]>
			
		</content>
	</entry>
		<entry>
		<title>Deploying a seam-gen project to GlassFish</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/10/deploying_a_seamgen_project_to_glassfish/index.php" />
		<modified>2008-10-03T07:45:00Z</modified>
		<issued>2008-10-03T03:45:00-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.100</id>
		<created>2008-10-03T07:45:00Z</created>
		<summary type="text/plain">seam-gen creates projects that deploy to JBoss AS out of the box. However, a Seam application can run on any Java EE application server or...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Java</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>seam-gen creates projects that deploy to JBoss AS out of the box. However, a Seam application can run on any Java EE application server or servlet container with the proper packaging. I have created a page on the <a href="http://code.google.com/p/seaminaction/wiki/DeployingToGlassFish">Seam in Action wiki</a> that provides instructions for how to modify the build script of a seam-gen WAR project to support deployment to <a href="https://glassfish.dev.java.net/">GlassFish</a> (in addition to JBoss AS), as I promised I would do in <a href="http://mojavelinux.com/seaminaction">Seam in Action</a>. Unfortunately, the configuration on applies to WAR projects at this time, though it's certainly possible to deploy seam-gen EAR projects to GlassFish. It's just a matter of putting the files in the right place and I haven't yet committed the time to finding the right build configuration. Keep an eye out for updates as I will likely update the instructions when I nail it down.</p>

<p>Before you run off to discover how to modify your build, I want to mention a couple of things about GlassFish. It's fairly well-known amongst my colleagues and readers of my book that I like GlassFish, and I have cited those reasons in the appendix of Seam in Action. But there is a specific reason that I like GlassFish as it pertains to the build configuration I set forth on the wiki page.</p>

<p>GlassFish has a very sexy administrative console, but it also has a very sexy commandline tool known as asadmin. The asadmin tool gives you virtually unbounded control over the application server, including core tasks such as starting and stopping the application server, deploying and undeploying applications, and setting up database connection pools, amidst a plethora of other controls. You'll see that my modified seam-gen tool takes advantage of a handful of these commands. I encourage you to execute the help command to find out what else asadmin is capable of doing.</p>

<p>When choosing software, there is one thing that you should demand as a developer: efficiency. GlassFish gives you efficiency through automation, which is undoubtedly the most effective way to become efficient. As soon as you have to open up a configuration file, know that you are wasting time. Manual processes are not only slow, though. They are non-reproducible. As the wise authors of <a href="http://www.pragprog.com/the-pragmatic-programmer">The Pragmatic Programmer</a> advise, if you have to do something twice, script it. GlassFish volunteers itself to participate in a script and is the reason why I choose it as my preferred application server.</p>]]>
			
		</content>
	</entry>
		<entry>
		<title>Seam in Action is final, finally!</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/08/seam_in_action_is_final_finally/index.php" />
		<modified>2008-08-28T17:32:37Z</modified>
		<issued>2008-08-28T13:32:37-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.98</id>
		<created>2008-08-28T17:32:37Z</created>
		<summary type="text/plain">In the writing business, it ain&apos;t over until the book is printed. Well, in response to the question I have been asked countless times by...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Seam in Action</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>In the writing business, it ain't over until the book is printed. Well, in response to the question I have been asked countless times by family, friends, and colleagues over the last 15 months, "How's the book?", I can finally shout, "It's done!" (followed by an immediate collapse from exhaustion). In Winston Churchill's <a href="http://www.thinkarete.com/quotes/print/4123">words</a>, I have finally killed the monster and flung him out into the public.</p>

<p><a href="http://mojavelinux.com/seaminaction">Seam in Action</a> went to the printer two weeks ago and will be available September 5th on the bookstore shelves, online (<a href="http://mojavelinux.com/seaminaction">manning.com</a> or <a href="http://www.google.com/products/catalog?q=%22seam+in+action%22&btnG=Search&hl=en&show=dd&cid=425417071307208272">elsewhere</a>), and at the <a href="http://jsfone.com">JSFOne Conference</a>. I have held off doing an annoucement until today since there was still work to be done to get the ebook ready and I didn't want to say it is done until it is really available. I just checked in the official release of the <a href="http://seaminaction.googlecode.com/files/seaminaction-20080828.zip">source code</a> for the book this morning, which means that ebook can now be released into the wild. As of today, the ebook is being sent to subscribers and is available for purchase on <a href="http://mojavelinux.com/seaminaction">manning.com</a>. If you order the print version of the book, you get the ebook for free, exactly as it should be.</p>

<p>The last 15 months have been incredibly challenging on so many levels. With each weekend that passed by it seemed as though the end was getting furthur and furthur away, yet life did not pause. I had one job, took a sabatical, left that job, started another job, took another sabatical, changed computers three times, bought a car, my sister moved to NY to Knoxville to Atlanta and switched jobs three times, my college roommate got married, a life-long friend a baby, one of my cousins had a baby, my wife's cousin passed away, two of my neighbors moved away, I had my first speaking engagement at a conference, I attended four conferences, I traveled to Europe for the first time in my life, a family vacation came and went, an Olympics came and went, an NFL season came and went, and the list goes on.</p>

<p>The story of <a href="http://ramya.bhaavana.net/chaitanya/?p=38">"the last mile"</a> told by the authors of the <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=647_106">SOA Security</a> book mirrors exactly what I went through during the long tail of this project, so I will refrain from retelling it here. Thankfully, my enthusiasm for Seam and the support of my wife kept me going and I can now share with you the extensive research I have done over that time period. My only regret is that I would have gotten the book to you sooner, but Seam has such a bright future that by no means was a window missed. Thanks to all of you who remained patient and helped keep me atop Manning's MEAP bestseller list throughout most of the process.</p>

<p>There is still plenty I want to say about this experience, both at a personal and professional level, but right now I am having difficulty getting the words to flow. Keep watching for additional entries that are to come. Right now, I am just happy to say that I am finally done and can share the book with you. <strong>Get it. Read it. Learn from it.</strong></p>]]>
			
		</content>
	</entry>
		<entry>
		<title>Podcast from JavaOne</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/08/podcast_from_javaone/index.php" />
		<modified>2008-08-22T14:05:50Z</modified>
		<issued>2008-08-22T10:05:50-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.97</id>
		<created>2008-08-22T14:05:50Z</created>
		<summary type="text/plain">In between crashing parties at JavaOne, I was tracked down by Kito Mann to do a podcast interview for JSFCentral. Kito is the author of...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Seam in Action</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p><a href="http://www.jsfcentral.com/articles/allen-08-08.html"><img src="http://mojavelinux.com/assets/gfx/podcast.png" alt="Podcast icon" class="avatar" border="0" style="margin: -2px 15px 0 0;"/></a>In between crashing parties at JavaOne, I was tracked down by Kito Mann to do a <a href="http://www.jsfcentral.com/articles/allen-08-08.html">podcast interview</a> for <a href="http://jsfcentral.com">JSFCentral</a>. Kito is the author of <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=647_10">JavaServer Faces in Action</a>, runs JSFCentral, and holds a seat on the JSF 2 expert group. He asked me about Seam, my book (<a href="http://www.mojavelinux.com/seaminaction">Seam in Action</a>), and Seam's integration with Spring. Kito has diligently made the <a href="http://www.jsfcentral.com/articles/allen-08-08.html">transcript</a> available for those of you who don't suffer from long commutes.</p>
<p>The best way to extract loads of good information from me is to catch me in the middle of one of my rants. The fervor of JavaOne had me fired up on this particular evening, so this episode is sure to please. I was especially excited because this is my first podcast. I can proudly say that I am no longer a podcast virgin!</p>
<p>In the podcast, I discuss my book and what to expect from it, how Seam makes Java EE accessible, why integration with Spring is desirable and some of the differences in philosophies of the two frameworks (and its creators), how to respect the persistence context, and some of my wishes for JSF 2. I even talk some about my PHP port of Struts, a fling from my past. Pay close attention to what I have to say about the syntax for the view technology in JSF 2 because it brings to light an oversight in every view technology I know of.</p>
<p>I hope that this podcast gives you incentive to check out my book. As I say during the interview in the words of my readers, "nothing has gone into the detail and we have spent a lot of time with these problems and you have addressed [them in Seam in Action]." I really did labor over this book for my readers. This interview should help you understand why I did.</p>]]>
			
		</content>
	</entry>
		<entry>
		<title>Seam in Action promotion at JavaRanch</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/08/seam_in_action_promotion_at_javaranch/index.php" />
		<modified>2008-08-07T00:02:38Z</modified>
		<issued>2008-08-06T20:02:38-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.96</id>
		<created>2008-08-07T00:02:38Z</created>
		<summary type="text/plain">In the midst of the final countdown to the publication of Seam in Action, I will be answering questions about the book, and Seam in...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Seam in Action</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p><p>In the midst of the final countdown to the publication of <a href="http://mojavelinux.com/seaminaction">Seam in Action</a>, I will be answering questions about the book, and Seam in general, on the JavaRanch forums. Ask a question and enter to win a copy of the book. Better yet, just stop on by to say "Hi!" and pick my brain about Seam.</p></p>

<p><p>Here's the official announcement:</p></p>

<blockquote><p>We are thrilled to have Dan Allen on the ranch to promote the book
"Seam in Action".
The promotion will be held in the Application Frameworks  forum which can be found here:</p>
<p><a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&amp;f=83">Application Frameworks forum</a></p>
<p>Participate in this week's giveaway by asking Dan Allen a question or two and you may win a copy of the book!</p>
<p>The giveaway starts on Tuesday, August 5th 2008.<br />
The drawing will be held on Friday, August 8th 2008.</p>
</blockquote>
<p>See you at the ranch! And wish me luck on finishing the book. I'll need it!</p>]]>
			
		</content>
	</entry>
		<entry>
		<title>&quot;Seam in Action saved my life&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/05/seam_in_action_saved_my_life/index.php" />
		<modified>2008-05-07T07:58:05Z</modified>
		<issued>2008-05-07T03:58:05-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.95</id>
		<created>2008-05-07T07:58:05Z</created>
		<summary type="text/plain">If you know me, you know that I don&apos;t really like to talk about my successes. I guess part of it is because I absolutely...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Seam in Action</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>If you know me, you know that I don't really like to talk about my successes. I guess part of it is because I absolutely hate when I am the target of marketing, so I like to avoid putting other people in that situation. However, when I read the following <a href="http://www.seamframework.org/Community/TwoFreeChaptersFromSeamInActionAvailable#comment20624">post</a> on the <a href="http://seamframework.org/Community/SeamUsers">Seam Forums</a>, I decided I just had to share it. 

<blockquote>Dan,
<br /><br />
I have never written a book review before but am unable to contain myself in this case. I bought the pre-release version from Manning out of desperation to make head or tails out of what I have been doing with Seam, JSF, EJB etc.
<br /><br />
My perspective may be a bit different in that I am relatively new (7-8 months) to web development of any sort and fairly new to Java. The learning curve has been steep and painful. Compounded with this is that I am running solo with no peer group to keep me on the narrow path.
<br /><br />
I chose SEAM after an initial web app strictly with JSF, EJB3. I was relieved at how much less code I had to write to accomplish things. However, Seam introduces a whole new set of complexities and some of the nuances have really thrown me.
<br /><br />
The Michael Yuan/Thomas Heute book is a good resource for whetting the appetite. However it covers v1.0 Seam and it fairly introductory.
<br /><br />
What I had been missing and was desperately needing was a full understanding of what is happening under the covers; something that fully connects the dots. Your book does just that! It has eliminated much of the confusion that was besetting me. I having been reading it voraciously since I downloaded it.
<br /><br />
The community will greatly benefit from this resource. I love the thorough, careful, methodical explanations that step you through what is really going one. The abundant charts and graphics expose detail and subtleties that a developer really needs to know.
<br /><br />
This will be my primary goto resource. I hope the example code will be available for download soon.
<br /><br />
Thanks for hitting a home run with this.
<br /><br />- <a href="http://www.seamframework.org/Community/TwoFreeChaptersFromSeamInActionAvailable#comment20624">Andy Conn</a></blockquote>

Writing <a href="http://www.mojavelinux.com/seaminaction">Seam in Action</a> has been intriguing, but extremely laborious for me. Therefore, when I read something like this, it makes it all worthwhile. Hell, it almost brings me to tears, like when gold medalists cry after having dedicated their lives to achieving the Olympic grail.</p>

<p>BTW, if you are wondering what is going on with Seam in Action, I am currently pushing it through copy editing. I am taking my time because I want it to be right.</p>]]>
			
		</content>
	</entry>
		<entry>
		<title>Avoid this common JSF mistake</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/05/avoid_this_common_jsf_mistake/index.php" />
		<modified>2008-05-01T06:51:21Z</modified>
		<issued>2008-05-01T02:51:21-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.94</id>
		<created>2008-05-01T06:51:21Z</created>
		<summary type="text/plain"><![CDATA[Don't access the database in a method that feeds a UIData component! (e.g. &lt;h:dataTable&gt;) I see this mistake being made all the time. It's bad...]]></summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>JavaServer Faces</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>Don't access the database in a method that feeds a UIData component! (e.g. <span style="font-family: monospace;">&lt;h:dataTable&gt;</span>) I see this <a href="http://java.dzone.com/articles/use-mediator-pattern-jsf-appli">mistake</a> being made <a href="http://www.developeriq.com/articles/2008/apr/08/using-database-jave-server-faces/">all the time</a>. It's bad advice and just plain bad practice. <strong>Don't do it!</strong></p>

<p>What most people don't realize (perhaps because they are not watching the SQL log output in their ORM tool) is that value expressions are resolved more than once during the JSF life cycle--usually <em>a lot</em> more than once. Every time the value expression that feeds the UIData component is resolved in this scenario, your database takes a hit. On top of that, the result set could change depending on what you are retrieving and how you are doing it.</p>

<p>I will present a brief example and then show how to fix it using Seam.</p>
]]>
			<![CDATA[<p>Let's assume that you are using the class shown below to retrieve a list of <span style="font-family: monospace;">User</span> entities. The bean delegates the task of querying the database to a <span style="font-family: monospace;">UserService</span> instance.</p>

<pre>package example;

public class UserListBean {
    private UserService userService;

    public List<User> getUsers() {
        return userService.findAll();
    }
}
</pre>

<p>Now let's configure this class as a managed bean in the JSF configuration file. The <span style="font-family: monospace;">UserService</span> instance is injected using an EL value expression (perhaps using an EL resolver that pulls the bean from the Spring container). <em>By the way, choosing the session scope for this bean would be another bad practice that I am not going to get into here. Take a look at Seam's conversion scope if you are tempted to use the session.</em></p>

<pre>&lt;manage-bean&gt;
  &lt;managed-bean-name&gt;userList&lt;/managed-bean-name&gt;
  &lt;managed-bean-class&gt;example.UserListBean&lt;/managed-bean-class&gt;
  &lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt;
  &lt;managed-property&gt;
    &lt;property-name&gt;userService&lt;/property-name&gt;
    &lt;property-value&gt;#{userService}&lt;/property-value&gt;
  &lt;/managed-property&gt;
&lt;/manage-bean&gt;
</pre>

<p>Feeding to <span style="font-family: monospace;">getUsers()</span> method from the <span style="font-family: monospace;">UserListBean</span> managed bean to a UIData component demonstrates the bad practice I am talking about.</p>

<pre>&lt;h:dataTable id="users" var="user" value="#{userList.users}"&gt;
  &lt;h:column&gt;
    &lt;f:facet name="header"&gt;Name&lt;/f:facet&gt;
    #{user.name}
  &lt;/h:column&gt;
&lt;/h:dataTable&gt;
</pre>

<p>In this case, the SQL log would show several queries during render and several additional queries on a JSF postback, assuming there is a UICommand component somewhere on the page.</p>

<p>The correct way to do this would be to bind the list to a context variable using a Seam factory component so that the list of users is populated exactly once per page, regardless of how many times the variable is resolved. Note that we are scrapping the managed bean definition and using a Seam component instead. The choice of page scope for the <span style="font-family: monospace;">users</span> variable ensures that the list is not refetched on a JSF postback either.</p>

<pre>package example;

@Name("userList")
public class UserListBean {
    @In
    private UserService userService;

    @Factory(value = "users", scope = ScopeType.PAGE)
    public List<User> getUsers() {
        return userService.findAll();
    }
}
</pre>

<p>Now we can use the context variable named <span style="font-family: monospace;">users</span> in the JSF view.</p>

<pre>&lt;h:dataTable id="users" var="user" value="#{users}"&gt;
  &lt;h:column&gt;
    &lt;f:facet name="header"&gt;Name&lt;/f:facet&gt;
    #{user.name}
  &lt;/h:column&gt;
&lt;/h:dataTable&gt;
</pre>

<p><strong>Please don't fall into the aforementioned trap again!</strong> If you want to know how to inject Spring beans in your Seam components using bijection, check out my latest series, <a href="http://www.javaworld.com/javaworld/jw-04-2008/jw-04-spring-seam.html">Spring into Seam</a>.</p>]]>
		</content>
	</entry>
		<entry>
		<title>Heading to JavaOne 2008</title>
		<link rel="alternate" type="text/html" href="http://www.mojavelinux.com/blog/archives/2008/04/heading_to_javaone_2008/index.php" />
		<modified>2008-04-29T06:19:47Z</modified>
		<issued>2008-04-29T02:19:47-05:00</issued>
		<id>tag:www.mojavelinux.com,2008://1.93</id>
		<created>2008-04-29T06:19:47Z</created>
		<summary type="text/plain">I almost decided to pass on JavaOne this year, but the free CommunityOne pre-conference and the JBoss Party gave me reason enough to make the...</summary>
		<author>
			<name>Dan Allen</name>
			<url>http://www.mojavelinux.com</url>
			<email>dan.allen@mojavelinux.com</email>
		</author>
		<dc:subject>Java</dc:subject>
		<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.mojavelinux.com/">
			<![CDATA[<p>I almost decided to pass on <a href="http://java.sun.com/javaone/sf/">JavaOne</a> this year, but the free <a href="http://developers.sun.com/events/communityone/">CommunityOne</a> pre-conference and the <a href="http://www.jboss.org/files/events/javaone2008terms.htm">JBoss Party</a> gave me reason enough to make the trip (and the effort). Attendance at CommunityOne gets you a free pass to the General Sessions and the pavilion on the first day of JavaOne. How could I pass on free?</p>

<p>I am looking forward to the JBoss party as an opportunity to meet with the Seam developers, most of whom I have only communicated with via e-mail. Aside from that, though, I am going to play it cheap and not actually pay for the conference pass. I have other plans for that money<sup>1</sup>. Still, I couldn't just sit this one out. Given that I have pretty much dedicated this entire last year to Seam--and Java in general--I am very excited to mingle with all the Java enthusiasts in San Francisco this year. Catch up with me if you want to chat about Seam (and perhaps I will hook you up with a Seam in Action coupon).</p>

<p><small><sup>1</sup> I need to purchase myself a computer so that I actually own the one I use.</small></p>]]>
			<![CDATA[<p>The rest of this entry is somewhat of a diary about how I made the arrangements. If you know me, you know that I freak out when it comes to selecting an itinerary. The problem is that I am too much of a perfectionist. Actually, that's not it. I just hate to discover later that I selected the wrong dates and then have to live with them. This year, I am trying to keep the cost as low as possible and still make the trip worthwhile. The problem is, CommunityOne is on Monday and the JBoss party is on Thursday, the two events I want to attend. That puts me in San Francisco for the entire length of the conference. That's when I went hunting for a deal...</p>

<p>I already knew about Kayak.com, and my brother clued me in on SideStep.com. Both sites look identical, but in the end I found Kayak to return more consistent results for airline tickets. Before I get to the results, I want to say a word about these meta-search engines and online travel sites in general.</p>

<p>The information these sites are able to bring back is truly amazing. The trouble is that the task of nailing down itinerary used to be a task (burden?) that a travel agent or assistant would handle. But with the power at your finger tips, you feel inclined to find the deal yourself. While you can potentially save a lot of money, what you lose out on is <em>time</em>. You now have to dedicate at least a half a day to flipping through result after result trying to find a deal that lets you sleep at night. If you ever hope to have a chance at success, you have to know what your plans are, or you quickly get lost in the sea of potential results. As a person who writes software, I can admit to having made the comment "We can have to user handle that task." As I user, I can testify that I feel that extra burden. Sometimes I just want to have the computer tell me when to go, how to get there, and where to stay. Are you with me?</p>

<p>Okay, on to the details. I used Kayak.com to find my tickets. It was giving me great prices for round-trip tickets from Washington, DC to San Francisco (right around $400). However, I was attempting to fit a very tight window of time so as to minimize the hotel cost. When I got one side of the trip locked down, the other side went up in price when using the same airline. Then I got smart and realized that using the same airline on the return trip wasn't necessary. Once I started searching the two legs individually, I had the maximum flexibility and ultimately found the best price. I am getting there and back now for $338 at the exact times I want! The outbound is even a direct flight. I am saving on hotel cost by flying out early on Monday and then taking the redeye back late Thursday night.</p>

<p>Hotels were a bit tougher, because the search is not just about price, but also about quality, comfort, and distance from the Moscone Center. Trying to fit all of that into a search is pretty difficult. I found that I needed to supplement my Kayak search with a Hotels.com search. I like how both offer a distance from address option (e.g. the Moscone Center), in addition to all of the other information. They still lack the ability to filter by distance and price at the same time, which would have helped me tremendously.</p>

<p>The biggest factor in a hotel search, aside from proximity, is the reviews. I just have to know that someone else could tolerate the hotel before I even step foot in it. After skipping over the Bay Bridge Inn (because of its name) for at least the first ten searches, I finally gave it a chance. The reviews were very positive. The real kicker, though, was that many of the reviewers recounted attending conferences at the Moscone center and how this little family-owned inn was a well kept secret for that purpose. At a room rate of $93 and wireless internet, it just couldn't be beat. It practically made the decision for me. What's interesting, though, is that room rate didn't come from hotels.com, but from the partner website of the hotel itself. Even with all of its discount parading, hotels.com still couldn't beat that deal.</p>

<p>So I am ready for the Java frenzy, all for under $700!</p>]]>
		</content>
	</entry>
	
</feed>
