Using Seam 2 and JBoss Portal Pt.2

This is the second post in my quest to screw around with JBoss Portal and Seam…the first post is here.

Seam is an application framework based on several different technologies: JSF, Facelets, EJB3, and AJAX. If you are interested in creating rich internet applications then Seam or IceFaces are nice packages for Java based systems. Since I’m interested in building portlets for JBoss Portal using Seam is a good fit. If you’re interested in IceFaces I can say its a nice package too and I’ve used it successfully on other applications.

In this post I’m not really going to discuss in too many details the platforms and how they work – if you want more info on Seam then go to their site or Google it. The Seam site is really quite nice. I’m going to detail out how I got my system configured, what tips/tricks I learned, and make a decision on if I’ll use these tools on a real project that I have coming up.

Getting going with Seam is really quite simple. There’s one basic rule: RTFM. The Seam site is good and has great docs on getting everything setup so use it. Because I’m into self torture I’m going with the Seam 2.0 beta version and I’m going to use this with Elcipse 3.4 and add on top of that the latest JBoss Tools suite of plugins and features. I’ve grabbed all these from the JBoss CVS repo {CVS? dudes! SVN is way better!}. I’m also using the latest JBossAS 4.2 build for Win32 and MySQL 5.1 as well. I’m using JDK 1.6U7

I messed around with JSF about a year ago so the first thing I wanted to do was get a refresher on JSF. I found these sites useful:


I got thru those pretty quickly and started looking thru examples and then used the JBoss Tools in eclipse to generate and deploy a test seam application using this page as a guide. The tools interface is pretty nice.

The interface is pretty obvious if you are into Eclipse. In order to really work with seam you need to be in the right perspective. Once you are there the menu options for creating projects will have wizards and stuff. In this shot I’ve generated my basic project and deployed it within the environment to my jboss AS. The console output is right in the window. On the right are various widgets for the UI layout views. In the lower left is the properties panel – to me that’s in an odd place, but you can move it around.

I was able to deploy and then re-deploy this to my jboss server. You can make incremental updates to some kinds of things like xhtml documents and see the changes in the running app server. Other things in typical J2EE fashion require a full restart or a re-deploy action.

Now that I’ve got that working I’m onto my first attempt to use the application generation tools to reverse engineer a complete application. What I have is a MySQL database with a bunch of tables and relations and I want to generate some basic user interfaces from that. The process is pretty simple, just click click on your project and pick off “Generate Seam Entities” and off it will go. You can review some settings in your project if things do not work right. The output of this will be a complete set of hibernate objects, POJOs to work against them and a set of web content and forms to display and show data.

Doing this against my schema had some mixed results. Immediately following the generation I had several compile issues. In one class an annotation was duplicated for some reason. I deleted the second copy and that was solved. Another issue proved more difficult. I happen to have a table called “Messages” in my schema. When seam RE’s the table it names the object “Messages” of couse, but this causes a conflict with some internal objects in Seam itself called “Messages”. I refactored my objects to “BerenMessages”, but this does not fix all the references in the XHTML so I’ve got more work to do there. Here’s a shot of that:

I can’t see why that would cause an issue. I even fully qualified all the packages to see if that would fix the issue. I guess I’ll have to dig into this a bit more. In any case I got around this temporarily by just deleting the method and then removing the message functions from the xhtml menuing that was generated so that I wouldn’t get any errors at deploy time. With that done my application will deploy to the JBoss server with no errors.

What is produced is a bare bones set of DAOs, POJOs, controller logic, and a set of xHTML screens and forms for data entry/manipulation. There’s also a sample authentication mechanism that is while functional not actually authenticating against anything in particular, but it does show how sessions work.

seam_app_t5So well – hey that’s pretty darn cool. In about 2 hours a relatively ignorant person can generate an app like this? Not too bad.I suspect that my issues with the initial generation are due to using some MySQL specific things (like the enum type) and then perhaps some back luck with tables and things that are unfortunately named.

I’m going to play around with this and see how to get a few portal gadgets working and I’ll post my “part three” on this topic.


  1. Pingback: Setting up a Complete JBoss Stack on Fedora 10 « Tarn Aeluin

  2. Pingback: Liferay…I need a Life Jacket; Giving JBoss Portal a Try. » Tarn Aeluin

Leave a Reply