List of Figures – Seam in Action

List of Figures

Chapter 1. Seam unifies Java EE

Figure 1.1. The great framework decision

Figure 1.2. A cross section of the technologies incorporated in the Seam stack

Figure 1.3. Seam’s stack matrix, with options for a state and persistence provider

Figure 1.4. Seam cuts down on superfluous XML configuration that’s difficult to keep in sync with the source code.

Figure 1.5. Interceptors trap method calls and perform cross-cutting logic around a method invocation.

Figure 1.6. The golf tips page, which renders the collection of tips at the top and a form for contributing a new tip at the bottom

Figure 1.7. Seam cuts out the middleman by eliminating the need for a JSF backing bean. Instead, the entity class and the EJB 3.0 session bean work together to capture data from the UI and handle the event to persist the data.

Figure 1.8. The lifetimes of the six scopes in a Seam application. The standard scopes are represented by dashed lines. The scopes that Seam contributes appear as solid lines. The business process scope is persisted to a database and can thus outlive the application scope across server restarts.

Figure 1.9. Using the extended persistence context to keep an object in scope for an entire use case, even across multiple page views. The extended persistence context avoids the need to merge detached entity instances.

Chapter 2. Putting seam-gen to work

Figure 2.1. Reverse engineering entity classes from an existing database schema, termed bottom-up development

Figure 2.2. The database connection screen for the H2 admin console

Figure 2.3. The H2 administration console, showing the database schema on the left and a query console on the right. The result set viewer can be used to modify records.

Figure 2.4. The seam-gen application generator examines an existing database and creates a CRUD application to manage the entities stored in the database tables.

Figure 2.5. The Seam project creation wizard that is included with the JBossTools Eclipse plug-in. This wizard performs the same work as the seamgen command-line tool but offers a more interactive experience.

Figure 2.6. The two deployment scenarios offered by seam-gen. On the left, an exploded WAR (or EAR) directory. On the right, a packaged WAR (or EAR) file. Incremental hot deployment is not available when using a packaged archive.

Figure 2.7. The splash page of an application created by seam-gen. The links in the upper menu bar represent each of the entities that seam-gen extracted from the database schema.

Figure 2.8. The Course List screen as created by seam-gen. This page includes a collapsible search form in the top half and a pageable, sortable result set of courses in the bottom half.

Figure 2.9. The course detail screen as generated by seam-gen. This page displays all the data for a given course and also uses a tabbed pane to show the associated facility, tee sets, and holes.

Figure 2.10. The login screen of an application created by seam-gen. The authentication provider is just a stub, so any username/password combination is accepted in the default configuration.

Figure 2.11. The course editor screen as generated by seam-gen. Not only does this form allow you to edit the basic properties of a course, but it also allows you to associate it with a facility.

Figure 2.12. The course editor enforcing a number value for the yearBuilt field. Validations occur in real time using Ajax.

Figure 2.13. The seam-gen script invokes Ant targets in the project’s build. This image shows the difference between executing the explode command from seam-gen and executing the explode target directly from the project.

Figure 2.14. The Eclipse import wizard identifying the seam-gen project as an existing Eclipse project and a candidate for import

Figure 2.15. The list of tee sets for a course. The value of the color property is being used to display a colorized box.

Figure 2.16. The external tool build configuration for Eclipse that seam-gen installs to execute Ant targets during the Eclipse build process. On the left is the list of Eclipse builders. The right screen shows the details of the Ant builder.

Figure 2.17. Opening a seam-gen project in NetBeans. The icon color indicates that NetBeans recognizes the folder as a valid project.

Figure 2.18. The NetBeans Project Properties screens showing the direct integration of the Ant targets from the seam-gen project build

Figure 2.19. The context menu of a project in NetBeans, which includes items that map directly to Ant targets in the build file created by seam-gen. The build.xml node can also be expanded to reveal all of the available Ant targets.

Figure 2.20. The list of tee sets for a course sorted according to the value of the position property

Chapter 3. The Seam life cycle

Figure 3.1. Translation from servlet path to UI component tree, which is built by Facelets

Figure 3.2. Requests are preprocessed by the Seam filter, proceeding to the JSF servlet or the Seam resource servlet.

Figure 3.3. A rudimentary look at event-driven behavior in JSF. Method-binding expressions on command buttons trigger methods on server-side components—in this case a Seam component—when activated.

Figure 3.4. The six phases of the JSF life cycle are executed in a clockwise manner.

Figure 3.5. The life cycle phases used on an initial request for a JSF page

Figure 3.6. During a postback, the full JSF life cycle is used unless short-circuited by an error.

Chapter 4. Components and contexts

Figure 4.1. Component instances are created from components by the Seam container

Figure 4.2. Sequence diagram of a component instance being requested from the Seam container

Figure 4.3. Seam will scan this classpath entry since it contains the marker file.

Chapter 5. The Seam component descriptor

Figure 5.1. How Seam interprets an XML element in a component namespace

Figure 5.2. How Seam interprets an external property setting in order to assign an initial value to the property of a component

Chapter 6. Absolute inversion of control

Figure 6.1. Bijection wraps a method call, performing injection before the call and outjection afterward.

Figure 6.2. The bijection interceptor traps a method call on a component instance and performs the four steps of bijection—injection, method invocation, outjection, and disinjection.

Figure 6.3. The decision process Seam follows when injecting a value into an @In property

Figure 6.4. The order in which the contexts are scanned when Seam searches for a context variable

Figure 6.5. A narrow-scoped component is injected into a wider-scoped component.

Figure 6.6. The decision process Seam follows when outjecting the value from an @Out property

Figure 6.7. A golfer’ profile page. The data is supplied by an outjected context variable.

Figure 6.8. The list of new golfers prepared as a JSF data model as a result of outjection

Figure 6.9. An example of two reentrant method calls on the RegisterAction component made by the collaborator component GolferValidator

Figure 6.10. The process that Seam follows to look up a context variable backed by a factory component

Chapter 7. The conversation: Seam’s unit of work

Figure 7.1. The conversation scope ties together individual requests, but is more granular than the session.

Figure 7.2. Passing an object using request parameters is akin to teleportation.

Figure 7.3. Conversation workspaces are isolated segments of the HTTP session, each assigned a unique identifier.

Figure 7.4. How the conversation propagation directives affect the conversation during a request

Figure 7.5. The wizard allows the user to enter a new golf course into the directory.

Figure 7.6. Nested conversations are branched off the main long-running conversation.

Figure 7.7. A basic conversation switcher that includes static outcomes for returning home and entering a new course.

Figure 7.8. A list of workspaces in a user’s session. The user can switch to one of the workspaces or destroy it.

Chapter 8. Understanding Java persistence

Figure 8.1. The Java persistence ecosystem

Figure 8.2. Managed entities are used to exchange data between the application and the database.

Figure 8.3. The entity life cycle in a Java persistence (ORM) framework

Figure 8.4. The overlap between JPA and Hibernate. Hibernate can be used natively or as a JPA provider.

Chapter 9. Seam-managed persistence and transactions

Figure 9.1. Contrasts the independence of a Seam-managed persistence context with the coupling of the container-managed persistence managers to their stateful session bean components.

Figure 9.2. The boundaries of the transactions are wrapped around the phases of the Seam life cycle by Seam’s transaction management. The RESOURCE_LOCAL transaction is delayed until the start of a conversation.

Chapter 10. Rapid Seam development

Figure 10.1. The Seam Application Framework hierarchy for JPA. There’s an equivalent one for Hibernate.

Figure 10.2. An industry trend toward adding more behavior to domain model objects. The Anemic Domain Model only holds state, whereas the Active Record pattern encapsulates state and performs data access logic.

Figure 10.3. The class diagram of EntityHome. Several supplemental operations have been excluded.

Figure 10.4. A Home manages an entity instance, negotiating with the persistence manager to retrieve it.

Figure 10.5. Sequence diagram showing how the Home object resolves an entity instance.

Figure 10.6. A Home acts as a façade for the domain object, delegates operations to the entity instance and the persistence manager, and facilitates communication between them.

Figure 10.7. The form for adding a new round, the final product of this section’s tutorial

Figure 10.8. The way Home assembles a message bundle key for a CRUD operation.

Figure 10.9. The class diagram of EntityQuery

Figure 10.10. The round search screen supported by a Query component

Chapter 11. Securing Seam applications

Figure 11.1. By authenticating (signing in), the user is revealing his or her identity to the application.

Figure 11.2. The security filter isn’t aware of a navigation event that happens inside the JSF life cycle.

Figure 11.3. Seam supports two authorization models. Role-based authorization compares role names to the user’s role principals. Rule-based authorization delegates the decision to Drools.

Figure 11.4. The set of conditions that are passed into a rule-based authorization check

Chapter 12. Ajax and JavaScript remoting

Figure 12.1. The Ajax4jsf request processing. Ajax4jsf filters the JSF response and the Ajax engine that receives the partial response stitches those changes into the rendered page.

Figure 12.2. An illustration of how changes in the UI component tree are channeled through the ICEfaces Ajax bridge and merged back into the rendered page in the browser. The numbers indicate the sequence of events

Figure 12.3. Live validation in the UI performed using partial submit

Figure 12.4. The translation of a method call on a stub to a method call on a server-side component

Figure 12.5. The trivia question prompt in which the member enters a response

Chapter 13. File, rich rendering, and email support

Figure 13.1. A PDF document showing basic course and tee set information

Figure 13.2. A PDF document showing a golf course scorecard

Figure 13.3. A bar chart with two series generated using the Seam chart component tags

Figure 13.4. A line chart with two series generated using the Seam chart component tags

Figure 13.5. A pie chart generated using the Seam chart component tags

Figure 13.6. An HTML email created by Seam’s mail component that includes an inline image

Figure 13.7. Themes add an extra dimension to resource bundle selection.