Michael Yuan

“Science is a wonderful thing if one does not have to earn one’s living at it” — Albert Einstein

September 30th, 2006

New Home for my blog

I decided to move and consolidate all my blogs to wordpress. I really like wordpress for a couple of reasons: multiple author support; comment moderation; categories; content pages; rich UI; many many useful plugins (e.g., the Google Adsense-Deluxe, Google Analyticator, and Code Syntax Hilighter plugins)…

So, from now on, I will disable my old blog. The old blog home page and RSS feeds are automatically redirected to the new one. So, if you are subscribed my old RSS, you are automatically getting the new entries as well. But still, I’d encourage you to subscribe to the new feed — you can subscribe by category to filter out posts you do not want!

The new blog home page:
http://www.michaelyuan.com/blog/
RSS feed:
feed://www.michaelyuan.com/blog/feed/

Entries for the Java / technology category:
http://www.michaelyuan.com/blog/category/java/
RSS feed for the Java catgory:
feed://www.michaelyuan.com/blog/category/java/feed/

Where did my old posts go? Well, I backed them up in my personal archive, and they are no longer available for public access. However, I did move a few important and relevant posts to this new blog.

September 17th, 2006

JBoss Seam: Book Released

“JBoss Seam: Simplicity and Power Beyond Java EE 5.0″ is the first book on Seam — the next generation “web framework”. It is writen by yours truly and Seam project lead Thomas Heute. The book is published by Prentice Hall and is now available as a Safari Rough Cuts title.

Get the book here

Safari Rough Cuts provides PDF access to son-to-be-published books. For $3 more than the listed price, you can get early access to the PDF version of the book as it goes through the editing process, and then get a printed book shipped to you when it comes out in Dec 2006! I think it is a great deal. You do need to create a Safari login name in order to get access to the book — but rest assured that you are not required to sign up for the Safari subscription service. You will only be charge once for the price you select during your purchase.

If you are a Java EE developer, you probably have heard of JBoss Seam by now. It is an annotation-based framework to elegantly extend the EJB3 component model to all aspects of a web application. It is incediblly powerful for developing stateful web applications, and it eliminates almost all the unecessary XML artifacts and Java boilerplate code commonly plauged previous generations of web frameworks. Seam supports advanced web application features such as AJAX, multiple workspaces, business process integration, etc. Check it out if you have not done so!

The book focuses on the basic concepts behind Seam and uses several full examples to explain how various parts fit together in a Seam application. It complements the official Seam reference documentation and examples very well. Safari already has 16 chapters of the book. We will keep adding new contents and revising existing chapters based on user feedback until the book is signed off to the printers!

September 11th, 2006

Use Ajax4jsf with Seam + Facelets

This post is out-dated for Ajax4jsf 1.0.2+. Please refer to this post instead.

Ajax4jsf is a very nice open source framework for adding Ajax features into existing JSF components. I have been playing with it in my Seam + Facelets applications. It is great fun. However, as most other Ajax JSF components, Ajax4jsf requires some tweaking to get around the JBoss ClassLoader when working with Seam. The official docs recommend that you put all Ajax4jsf and Facelets library jars into $JBOSS_HOME/server/default/lib as shared libraries. However, the problem is that those frameworks are not designed to be shared. If you have multiple web applications deployed on the same server, the shared lib approach might causes some problems. In this post, I present an alternative approach to use Ajax4jsf inside Seam.

The short answer:

  • Bundle the ajax4jsf-seam-war.jar and jsf-facelets-seam-war.jar (if using Facelets) in your WAR file’s WEB-INF directory.
  • Bundle the regular required JAR files of Ajax4JSF and Faclets in the EJB3 JAR file in your EAR file.
  • Follow instructions in Ajax4JSF docs to setup web.xml and faces-config.xml to use Ajax4JSF with Facelets.

The explanation:

The problem with AJAX JSF frameworks and Seam is that the framework libraries need to be “seen” from both the WAR and EJB3 JAR files. (Non-Ajax frameworks do not have this requirement since they do not need to access the EJB3 “backing beans”.) But libraries in the WAR file is invisible outside of the WAR. So, the solution is to place the libraries in the EJB3 JAR file, which on the classpth of all components in the EAR. But it is not that simple: JSF only searches the WAR for tag definitions and configuration files. So, all the .tld, .taglib.xml, and faces-config.xml files in the library JAR’s META-INF directory needs to re-pakcaged into a seperate JAR and be placed into the WAR file. That’s where the *-seam-war.jar files come from.

But then, why do we need to re-package jsf-facelets.jar as well? The reason is that Ajax4JSF needs to load Facelets by itself. So, it needs to “see” jsf-facelets.jar from outside of the WAR as well.

September 3rd, 2006

BBQ, Camping, and Golfing in Lockhart

Have not blogged for a very long time! We went to Lockhart this weekend for some really great Texas BBQ, camping in the woods, and a nice round of golf in the cool morning breeze. Checkout the pictures here.

Our tent on the campground
2006-09-02-camp01.jpg

Golf swing
2006-09-02-golf01.jpg

Golf putt
2006-09-02-golf02.jpg

Ju’s playing Golf
2006-09-02-golf03.jpg