Chapter 4. Seam Wizards

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

Go to File > New and select the component wizard.

Seam Component Wizards

Figure 4.1. Seam Component Wizards


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.

Seam Project WAR Deployment

Figure 4.2. Seam Project WAR Deployment


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

4.1. New Seam Action

To create a New Seam Action you should select a necessary project, type a name for Seam component, POJO class, Method, Page and select a Package using Browse button.

New Seam Action Wizard

Figure 4.3. New Seam Action Wizard


You can see the action page in WebContent folder. Click on it to open in JBoss Tools HTML Editor.

Action Page in JBoss Tools HTML Editor.

Figure 4.4. Action Page in JBoss Tools HTML Editor.


Note:

You don't need to restart the server to see how the action component works. Just use context menu Run As > Run On Server.

Action component was hot-deployed. Forms and Conversations will work the same way.

Action Component

Figure 4.5. Action Component


4.2. New Seam Form

Click on actionMethod in the internal browser and add a form in your project using the New Seam Form wizard File > New > Seam Form.

Select a necessary project, type a name for Seam component, POJO class, Method, Page and select a Package using Browse button.

New Seam Form Wizard

Figure 4.6. New Seam Form Wizard


The Form Page was created in WebContent folder.

Form Page in JBoss Tools HTML Editor.

Figure 4.7. Form Page in JBoss Tools HTML Editor.


Deploy the form on server. Right click on Form Page, select Run As > Run On Server.

Form Component

Figure 4.8. Form Component


Form component was hot-deployed.

4.3. New Seam Conversation

Enter some value in the text field (e.g. value1) and click on formMethod.

Add a conversation using the New Seam Conversation wizard File > New > Seam Form.

You should select a necessary project, type a name for Seam component, POJO class, Method, Page and select a Package using Browse button.

New Seam Conversation Wizard

Figure 4.9. New Seam Conversation Wizard


Conversation page was created in WebContent folder.

Conversation Page in JBoss Tools HTML Editor.

Figure 4.10. Conversation Page in JBoss Tools HTML Editor.


Right click on Conversation page, select Run As > Run On Server.

Conversation Component

Figure 4.11. Conversation Component


Conversation component was hot-deployed.

Click on Begin and Increment buttons to check the conversation functionality.

4.4. New Seam Entity

Entities cannot be hot-deployed, so we need to stop the server.

Create an Entity using the New Entity wizard File > New > Seam Entity.

You should select a necessary project, type a name for Entity class, select a Package using Browse button, type a name for Master Page and Page.

New Seam Entity Wizard

Figure 4.12. New Seam Entity Wizard


The Master Page and the Entity were created in WebContent folder.

Master Page in JBoss Tools HTML Editor.

Figure 4.13. Master Page in JBoss Tools HTML Editor.


The Entity page is:

Entity Page in JBoss Tools HTML Editor.

Figure 4.14. Entity Page in JBoss Tools HTML Editor.


Run the Entity page on server. This is what you get:

Customer Page

Figure 4.15. Customer Page


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:

Two Customers Are Created

Figure 4.16. Two Customers Are Created