JBoss.orgCommunity Documentation

Seam Dev Tools Reference Guide

Version: 3.0.0.beta1

April 2008


1. Introduction
1.1. What is Seam?
1.2. Installation into Eclipse
1.3. Other relevant resources on the topic
2. Creating a New Seam Project via the New Seam Project wizard
2.1. Create standalone Seam Web Project
2.2. Select the Project Facets
2.3. How to Configure Web Module Settings
2.4. Adding JSF Capabilities
2.5. Configure Seam Facet Settings
3. Directory Structure of the Generated Project
3.1. WAR Deployment
3.2. EAR Deployment
3.3. Renaming the Projects and Folders
4. Seam Menus and Actions
4.1. File Menu Actions
4.2. Navigate Menu Actions
4.2.1. Find Seam References/Declarations
4.2.2. Open Seam Component
5. Seam Wizards
5.1. New Seam Action
5.2. New Seam Form
5.3. New Seam Conversation
5.4. New Seam Entity
6. Seam Generate Entities
7. Seam Editors Features
7.1. Content Assist
7.2. OpenOn
7.3. Seam Validation
7.4. Structured components.xml Editor
8. Seam Views
8.1. Seam Components View
8.2. Project Explorer integration
9. Seam Preferences
9.1. General Preferences
9.1.1. Validator Preferences
9.2. Project Preferences
10. Generate a CRUD Database Application
10.1. What is CRUD?
10.2. How to create the CRUD Database Application with Seam
11. The CRUD Application Walkthrough
11.1. Using CRUD Application
12. Using TestNG project
12.1. What is TestNG?
12.2. Other relevant resources on the topic
12.3. How to use the generated Seam-test project to run Seam tests?

The Seam Framework - Next generation enterprise Java development.

All latest release versions of JBoss Developer Studio/JBoss Tools documentation you can find here.

The latest documentation builds are available here.

In this chapter we provide you with the necessary steps to start working with Seam Framework.

At first, we suggest setting the specific Seam perspective that combines a number of different views and editors needed for work with resources concerned. For that select Window > Open Perspective > Other > Seam or you can also access it through the button in the right top corner.


The best way to get started with Seam is to organise a simple Seam Project and experiment with it by creating variations.

Thus, you should select File > New > Seam Web Project to run the New Seam Project wizard. The wizard form allows you to create runtime and server instances in order to get started creating, running, and debugging J2EE (only) applications.

Seam Web Project wizard has an option for selecting the actual Server (not just WTP runtime) that will be used for the project. This allows the wizard to identify correctly where the required datasource and driver libraries need to go.

Let's get through the wizard step-by-step. First, you should enter a name and a location directory for your new project.


Clicking on New... button in the <proeprty>Target Runtime</proeprty> section will bring you to another dialog. Here, you can specify a new installed Runtime environment or the other type of runtime appropriate for configuring your project. Let's create a JBoss 4.2 Runtime. For that after choosing it click on Next button.


All what you need here is to name runtime, type the path to its install directory or locate it by using Browse button, select a Java Runtime Environment, and select which configuration you want.


Clicking on Finish returns you to the previous dialog. The next step is to define an installed server that you can do by clicking on New... button in the Target Server section. In appeared Server Dialog it's possible to select a server version.

If the chosen server has already got an installed runtime, there appears a combo box with all declared runtimes under the servers view. Here, you can indicate a server runtime that you need. Use Installed Runtimes... button to see or edit which runtimes are installed. If there is no any declared runtime for chosen server, click on Next to specify it on the next preferences page.


Next dialog allows you to verify the information for chosen server, set login credentials to authorize an access to the server and specify a directory for deploying. Leave everything as it is and click on Next .


On the last wizard step you can modify your project to configure it on server.


Once you have the Target Server defined click on Finish button to return to the first page of the New Seam Project wizard.

Tip:

We suggest that you look through our AS manager guide to find out more about runtimes and servers.


The last section on this wizard step is Configuration. Here, you can select one of the pre-defined project configurations either associated with Seam 1.2 or with Seam 2.0. Furthermore, you can create your own configuration by pressing the Modify... button. It will open the dialog which allows to configure your own set of facets for adding extra functionality to your project.

Pass to the next section to find out more details on this dialog.

The last wizard step is related to Seam facet and allows you to do the following:


  • Create Seam runtime and define Seam home folder.

For that click on Add button in the General section. Notice that in this wizard presented below you can create a Seam runtime only for that version which was selected in the Project Facets wizard (version 1.2 in our case).


  • Select EAR or WAR deployment by checking a necessary radio button.

  • Select a Database Type


  • and then specify a Connection profile appropriate for your database.


You can edit chosen profile by using Edit button or organise a new one by clicking on New button and selecting necessary for you type of connection profile.


On the other dialog you'll be asked to enter its name and description. And then you should select a proper driver and adjust connection details. Press Next to preview all the adjusted settings and complete the creation of the new profile.


The next block of settings in the Seam Facet wizard are describing a Database and a connection to it.

In the Code Generation section the wizard have already put the names for your Session Bean, Entity Bean and Test packages. Of course, you can change them into the others which you like.


Click on Finish to generate a project.

In this chapter we describe where the Seam wizard puts the generated files for both EAR and WAR deployments.

The Seam Project wizard generates projects like Eclipse WTP style in order to utilize Eclipse WTP features and to have a correct classpath. To be more precise it generates one project per artifact.

In this chapter we provide a description of Seam actions that are available from

  • Menu bar

  • Toolbar

  • Context menus in views

In the next sections we are going to describe Seam actions which can help you to easily navigate through the source code.

This chapter introduces you with Seam Components.

All the Seam component generations options known from Seam-gen are available as wizards (with sensible auto-defaulting) for creating various common Seam components:

  • Seam Action

  • Seam Form

  • Seam Entity

  • Seam Conversation

Go to File > New and select the component wizard.


The wizards create multiple resources and place it in the appropriate folders depending on your project structure (WAR or EAR).

Let's create a WAR project using the New Seam Project wizard.


After the project is created you need deploy it on server.

Let's create two customers c1 and c2. Enter the name in the text field and press the Save button. Customer should be successfully created. Press Done. Do the same for c2 customer. The result should be:


The main purpose of this chapter is to tell you about Seam Generate Entities.

Generate Entities is available directly from within Eclipse using Hibernate Tools plugin for the standard seam-gen generation.

Generate Entities generates a set of CRUD Seam components and web pages based on existing tables in a database or on existing entities in your application.


In the Generate Seam Entities wizard there are two generation modes: Reverse Engineer from database and Use existing entities.

The Reverse Engineer from database mode can be described in four steps:

  1. The wizard gets in database, extracts the tables and their connections

  2. On basis of this metainfomation the Entity classes are generated into org.domain.project.entity package

  3. For the entities from step 2 the classes EntityList and EntityHome are generated into org.domain.project.session package

  4. The xhtml pages are generated.

Checking the Use existing entities mode the wizard executes only 3 and 4 steps. It generates missing classes and xhtml pages.

Read the Generate a CRUD Database Application chapter in order to see how the Generate Seam Entities wizard can be used.

In this chapter you get to know how Seam preferences can be modified during the development process.

Seam preferences can be set using the Seam preference page. Click on Window > Preferences > JBoss Tools > Web > Seam.

On this page you can manage the Seam Runtime. Use the appropriate buttons to Add more runtimes or to Remove those that are not needed.


Clicking on Edit button you get the form where you can change the path of Seam runtime home folder, modify name and version. Press Finish to apply the changes.


  • First, you should download a database and start it by running ./runDBServer.sh or runDBServer.bat from the database directory.

  • Create a new Seam Web Project using New Seam Project wizard or main menu File > New > Seam Web Project.


  • Name your project as crudapp, specify Target Runtime, Server and Seam Runtime configuration. Then press Next and follow the next wizard steps keeping default settings.


Tip:

Please have a look here how to create Target Runtime and Seam Runtime in order to get started creating, running, and debugging J2EE applications.

  • On Seam Facet page click New... next to the Connection profile section to create a new Connection profile.


  • On New Connection Profile dialog select the HSQLDB connection profile type, name it cruddb and click Next.


  • On the next page click the round icon next to the Drivers field to select a database driver.


  • Now you should see the New Driver Definition dialog. On the first tab select the HSQLDB JBDC Driver. Underneath in the Driver name field you can change its name if you need.


  • You may notice the note on the previous figure. It prompts that you should specify the driver of the type you pointed. Set the location of the driver by switching to the next tab and press Add JAR/Zip button.


  • On the Properties tab set the Connection URL, Database Name and User ID and click OK.


  • After clicking OK to submit the newly created driver you can observe and if you need edit all specified connection details.


  • Now click Test Connection to be sure that connection can be established.


  • Validate JDBC Connection profile settings and press Finish or Back if something is wrong.


  • After clicking Finish two projects crudapp and crudapp-test will be created.


  • Have a look at the created projects. You can expand WEB_CONTENT folder and open home.xhtml or login.xhtml with JBoss Visual Editor.


  • Switch to Database Development perspective with Window->Open Perspective->Other... and connect to the cruddb database.


  • Expand cruddb nodes to view its Schemas , Tables , Columns etc.


  • Switch back to the Seam perspective. From the toolbar select New->Seam Generate Entities to create a set of CRUD Seam components and web pages based on existing tables in the database. In the Generate Seam Entities dialog keep everything by default and press Finish .


  • Under WebContent folder you can find a lot of generated xhtml files:


  • And under src folder java classes are created.


  • Switch to Hibernate perspective with Window->Open Perspective->Other... . On Hibernate Configurations view expand the crudapp configuration. Right click on Customers and select Open Mapping Diagram from the popup menu.


  • Observe that Mapping Diagram is opened in the editor. Here you can see the relations between models and database tables. Select Customers entity model, right click and select Open Source File .


  • This will open the Customers.java file in the java editor.


After that you are ready to deploy your application to J2EE application server. This is described in the next chapter.

After you familiarized oneself with example of creating the CRUD Database Application with Seam, you can read this charter.

With the help this chapter you will get to know with TestNG.


  • Add Seam Action to your project via File > New > Seam Action.


  • Fill out the wizard fields. New Seam Action wizard will create resources and place them in the appropriate folders dependent on EAR project structure.


  • When Action is created you will see actionPage.xhtml in Package Explorer view. ActionBean.java will be automatically opened in Java Editor.


  • Select ActionLocalTest.xml in Seam-test project and run the test with right click Run As > TestNG Suite.


The test process will start and its output will be written in Console View.


  • After running TestNG you will have the test results in test-output folder in Seam-test project (press F5 to refresh the Package Explorer view). Open index.html file with Web Browser or simply use the TestNG view.

The below view shows a successful run of the test.


You can see the test results in Web Browser.


After clicking on ActionLocal Tests link you will see the Results for ActionLocal Tests.


Select a result on the left-hand pane and its details will be displayed on the right-hand one.


Thus with Seam tooling you can easily take advantage of TestNG framework. As you can see, it generates its own TestNG project as a separate module within which you can easily monitor the tests execution and their output.

In conclusion, the main goal of this document is to get you know with a full featureset that JBoss Tools provides to support Seam development. Thus if you have some questions, comments or suggestions on the topic, please fell free to ask in the JBoss Tools Forum. You can also influence on how you want to see JBoss Tools docs in future leaving your vote on our page here.

A set of movies on Seam tooling is available here.