Book Image

Seam 2.x Web Development

Book Image

Seam 2.x Web Development

Overview of this book

The Seam framework from JBoss allows developers to use JSF, Facelets, EJB, and JPA to write conversational web applications. But you will first have to learn how these standard technologies are integrated using Seam and how they can be built upon using additional Seam components. If you need to build a Java web application fast, but don't have time to learn all these complex features, then this book is for you. The book provides a practical approach to developing Seam applications highlighting good development practices. It provides a complete walk through to develop Web applications using Seam, Facelets, and RichFaces and explains how to deploy them to the JBoss Application Server. You can start using key aspects of the Seam framework immediately because this book builds on them chapter by chapter, finally ending with details of enterprise functionality such as PDF report generation and event frameworks. First, the book introduces you to the fundamentals of Seam applications, describing topics such as Injection, Outjection and Bijection. You will understand the Facelets framework, AJAX, database persistence, and advanced Seam concepts through the many examples in the book. The book takes a practical approach throughout to describing the technologies and tools involved. You will add functionality to Seam applications after you learn how to use the Seam Generator RAD tools and how to customize and fully test application functionality. Hints and tips are provided along the way of how to use Seam and the JBoss Application Server.
Table of Contents (17 chapters)
Seam 2.x Web Development
Credits
About the author
About the reviewers
Preface

Testing our Seam installation


Now that we have downloaded and installed both the JBoss Application Server and the Seam Framework, we can deploy one of the sample applications provided with Seam to ensure that we have got everything configured correctly.

To test our environment, we need to:

  1. 1. Start the JBoss Application Server

  2. 2. Deploy the sample application

  3. 3. Run the sample application

Start the JBoss Application Server

As we mentioned in the earlier section, starting the JBoss Application Server is a simple matter of either double-clicking on the run.bat file or executing the run.sh script. Startup the Application Server using the appropriate technique and ensure that there are no errors displayed within the console window.

Deploy the sample application

Each of the Seam sample applications can be built using pre-supplied ant scripts. These scripts allow applications to be built and deployed from the command line.

Before building and deploying these sample applications, we need to edit the <seam_home>/build.properties file to specify the location of the JBoss Application Server. We need to do this so that the compiled application can automatically be deployed to the application server. Edit this file and add a line that sets the jboss.home property to the location of the application server, as shown (/Applications/jboss-5.0.0.GA) in the following example screenshot:

Note

We need to be careful on Windows systems when using the "\" character because of the way that Java escapes characters. On a Windows system, we would declare the jboss.home property as either c:/jboss-5.0.0.GA or c:\\jboss-5.0.0.GA.

Run the sample application

Now that we have started the application server and specified its location within the Seam example configuration files, we can build one of the sample applications to ensure that it runs correctly.

Open up a command prompt (or command shell) and navigate to the <seam_home>/examples/numberguess directory. Within this directory, execute the ant deploy task, which will build the Number Guess example application and deploy it to our running instance of the application server. In the case of the JBoss Application Server, deploying the sample application is simply a matter of the application's .ear file being copied into the <jboss_home>/server/default/deploy directory.

Assuming that no errors were displayed whilst deploying the application, we can open up a browser and point it to http://localhost:8080/seam-numberguess to test the application, as shown in the following screenshot:

In addition to running the sample application, we can run the unit tests that are supplied with it by executing the ant test command. The Seam Framework provides excellent support for unit testing applications, which we will discuss in detail in Chapter 5. For the moment though, execute the test target command and note that several tests run successfully.

Note

When performing unit tests using the embedded JBoss Application Server, such as the ones performed in the Number Guess example application, we must use JDK 5 and not JDK 6. This is because the embedded JBoss Application Server does not yet work correctly with JDK 6.