Update: Use the 0.2 version of the plugin for Seam 1.2.1 GA and JBoss AS 4.0.5 GA.

Petr Pisl of Sun has just released a first-look Seam Gen plugin for NetBeans. It allows you to generate complete Seam CRUD applications in NetBeans much the same way Red Hat Developer Studio allows you to do in Eclipse. I am extremely excited. So, here is a mini tutorial with some screen shots (taken from a Vista box — NetBeans look pretty good on Windows Vista).

Tutorial

1. Download and install the Seam module in NetBeans 5.5.1. We recommend you to install the Facelets support modules as well. Use “Tools -> Update Center -> Install Manually” to install those nbm files.

2. Install JBoss AS 4.0.5 with EJB3 support and set up a database with some existing data. Register the JBoss server and database connection in NetBeans. This is standard NetBeans stuff. If you are not familiar with that, read the Notes at the end of this post. You should see something like this in the Runtimes window after you are done.
seamgen01.png

3. Use “Files -> New Project” to create a new Seam project. You need to point it to the Seam 1.2.0 PATCH1 installation directory. You need to also specify the JBoss AS instance and the database connection registered in NetBeans.
seamgen02.png
seamgen03.png
seamgen05.png

4. The project is then created. You can open any XHTML file to see the capability of the Facelets support module (e.g., syntax highlighting, auto-completion etc.)
seamgen06.png

5. Right click on the project and select Deploy to build and deploy the project to the selected JBoss AS instance.
seamgen07.png

6. Start the JBoss AS server in the NetBeans server manager.
seamgen08.png

7. You can see the basic web page in your browser.
seamgen09.png

8. Select “New -> Files” in the project and select generate-entities to generate a complete CRUD application based on the data in the database connection.
seamgen10.png

9. Java classes and UI XHTML files are generated into the project.
seamgen12.png

10. Deploy the app and refresh your browser. You now have a complete AJAX CRUD application (see it in action here).
seamgen13.png


Notes: Set up JBoss and database server

a. Install JBoss AS 4.0.5 GA from the installer and choose the EJB3 profiler when asked.

b. Register the server in NetBeans via “Runtime -> Servers -> Add Server” in context menu and select the JBoss AS installation directory.

c. Download and expand the following zip file for a HSQL database, and start the database by running the runDBServer script. Of course, if you have an existing DB running, you can skip this step.

d. Add the DB driver via “Runtime -> Databases -> Drivers ->New Driver” in context menu and select the hsqldb/lib/hsqldb.jar file. If you are using other DB servers, you need to add its JDBC driver.

e. From the context menu over the added HSQLDB driver, select “Connect Using …”

- Database URL: jdbc:hsqldb:hsql://localhost:1701

- Username: sa

- and the schema is PUBLIC

That’s it!