Chapter 3. Seam Tutorial
- 3.1. Using the Seam examples
- 3.2. Your first Seam application: the registration example
- 3.3. Clickable lists in Seam: the messages example
- 3.4. A complete Seam application: the Hotel Booking example
- 3.5. Nested conversations: extending the Hotel Booking example
- 3.6. Bookmarkable URLs with the Blog example
3.1. Using the Seam examples
Seam provides a number of example applications that demonstrate the use of a variety of Seam's features. This tutorial guides you through a few examples to help you start learning Seam. The Seam examples are located in the
examples subdirectory of the Seam Demo file distributed with Red Hat JBoss Web Framework Kit. The first example, on registration, is in the examples/registration directory.
All examples have similar directory structure based on Maven project structure defaults:
- The
<example>-eardirectory contains enterprise application submodule files such as aggregator for web application files, and EJB project. - The
<example>-webdirectory contains web application submodule view-related files such as web page templates, images, and stylesheets. - The
<example>-ejbdirectory contains Enterprise Java Beans components and integration tests. - The
<example>-ftestdirectory contains functional tests.
- The
<example>-web/src/main/webappdirectory contains view-related files such as web page templates, images, and stylesheets. - The
<example>-[ear|ejb]/src/main/resourcesdirectory contains deployment descriptors, and other configuration files. - The
<example>-ejb/src/main/javadirectory contains the application source code.
Note
Seam examples are built and run from the Maven
pom.xml file, so you must have at least version 3.x of Maven installed before you get started.
3.1.1. Running the examples on Red Hat JBoss Enterprise Application Platform
Seam examples are configured for use on JBoss Enterprise Application Platform.
Set
JBOSS_HOME as the environment variable. Start the application server and build examples by typing mvn install in the example's root directory. To deploy an example, change the directory to *-ear or *-web and use the command mvn jboss-as:deploy. The example gets deployed to a URL like /seam-example, where example is the name of the example folder. For instance, if JBoss Enterprise Application Platform is running on port 8080, the URL for the Registration example is http://localhost:8080/seam-registration/.
If, on the other hand, the example is packaged as a WAR, then it deploys to a URL like
/${name}-web.
Note
Examples like groovybooking, hibernate, jpa, and spring can only be deployed as a WAR.
3.1.2. Running the example tests
Most examples come with a suite of JUnit and Arquillian integration tests. The easiest way to run the tests is to run the command
mvn verify -Darquillian=jbossas-managed-7.