Table of Contents
Part 1 - Teeing off with Seam
1 Seam unifies Java EE
2 Putting seam-gen to work
Part 2 – Seam fundamentals
3 The Seam life cycle
4 Components and contexts
5 The Seam component descriptor
6 Absolute inversion of control
Part 3 – How Seam manages state
7 The conversation: Seam's unit of work
8 Understanding Java persistence
9 Seam-managed transactions and persistence
10 Rapid Seam development
Part 4 – Sinking the business requirements
11 Securing Seam applications
12 Ajax and JavaScript remoting
13 File uploads, rich rendering, and email support
14 Managing the business process
15 Spring integration
Appendix A. Seam starter set
Appendix B. Seam annotations quick reference
Appendix C. JSF component libraries
Licensed to Jaroslaw Gilewski <jgilewski@unizeto.pl>
1
Seam unifies Java EE
Is JSF worth a second look? Is EJB really fixed? Is it worth sticking with Java rather than jumping ship for
Ruby on Rails?
With the release of JBoss Seam 2.0, you can now confidently answer yes to all of these questions. Seam is
a progressive application framework for Java EE that makes writing web-based applications easier by finally
delivering on the promise of a unified component architecture. Seam builds on the innovative changes in Java
EE brought about by the Enterprise JavaBeans (EJB) 3 specification. These changes include favoring
annotations over container interfaces and relying on configuration by exception rather than verbose and
laborious XML descriptors. Seam tares down Java EE's remaining heavyweight legacy by spreading EJB 3's
pivotal changes across the platform, leveraging more annotations, more configuration by exception and
extending the platform as designed, weaving functionality into the JavaServer Faces (JSF) life cycle, and using
the unified EL to allow these technologies to communicate. With Seam, the pain typically associated with
using Java EE has vanished and JSF, in particular, appears completely revamped and worthy of attention.
In this chapter, you discover why Seam is the most exciting technology that has landed in Java's turf since
its inception and the reasons why you should make Seam your framework of choice. I demonstrate how Seam
solves your current problems with the Java EE platform by blending innovative concepts with existing
standards. In a world inundated with frameworks, JBoss Seam is the unframework. It does not force a new
programming model on you. Instead, Seam pulls together the standard Java EE APIs, makes them more
accessible, functional, and attractive, and then finishes them off with modern upgrades such as page flows,
JavaScript remoting, PDF rendering, email composition, charting, file upload management, business processes,
and Groovy integration. Like a classic car, underneath the hood Seam has all the muscle of Java EE, but on the
surface it appears stunning and elegant.
Putting Seam's strengths aside, the fact remains that there are many qualified frameworks that you have to
choose from. In the next section, I provide you with advice that can hopefully put an end to your search and
move you towards developing your application. Despite the fact that no one can tell you what framework is
right for you, you are probably going to ask anyway, right? Don't worry, I came prepared.
1.1 Which framework should I use?
In a world full of framework options, how do you choose one? There are so many frameworks available for the
Java platform, some proven, some promising, that the decision is downright agonizing! Does figure 1.1 speak
to you?
Licensed to Jaroslaw Gilewski <jgilewski@unizeto.pl>
Figure 1.1 The great framework decision.
The choice is so bewildering that the framework inquiry is now the dominant greeting exchanged between
developers at conferences. While the question "What do you do?" may have traditionally served in the role of
sizing up a person's abilities, these days you are judged based on the merit of what framework you use for
software development (or the advice that you can give pertaining to that choice). Just when you've made a
decision, a new framework arrives on the scene promising to bury its predecessors.
These choices can be harmful, especially to productivity. Barry Schwartz argues in The Paradox of Choice
that having a bewildering array of options floods our already exhausted brains. The result is that your ability to
write a quality application stalls. You keep believing that the best framework is the one you haven't tried yet.
As a consequence, you spend more time researching frameworks than you do designing functional
applications. The search consumes you. You develop a false sense of how busy you are. While you may appear
busy, the fact is, you aren't accomplishing much.
If any of these choices were truly satisfying, than you probably would not be reading this book. You
would already have a set of tools that you know, beyond all doubt, allows you to be highly productive. But,
you don't, do you? You are still searching for a framework that is new, yet familiar. Lightweight, yet powerful.
You are in need of a platform that integrates the vast landscape of Java technologies into a unified stack. Seam
might be just the framework you are looking for.
1.2 Choosing Seam
You might be tempted to think that Seam is just another web framework, competing in an already flooded
market. In truth, to tag Seam as a web framework is quite unfitting. Seam is far more broad than a traditional
web framework, such as Struts, and is better described as an application stack.
1.2.1 A complete application stack
Let's consider the distinction between an application stack and a web framework. Web frameworks are
analogous to the guests that show up just in time for dinner and then leave immediately after eating. They
entertain and soak up the limelight, but they are mostly unhelpful. They go out the same way they arrived, with
lots of commotion. An application stack, on the other hand, is like the person who helps to plan the dinner
party, shops for the groceries, cooks, sets up, serves, makes the coffee, and then ultimately cleans up when it is
all over. They are steadfast and resourceful. Sadly, their work goes mostly unrecognized.
In a world where everyone wants to be a rock star (i.e. web framework), Seam is your practical sidekick,
your sous chef. The Seam stack includes the framework, the libraries, the build script and project generator, the
Licensed to Jaroslaw Gilewski <jgilewski@unizeto.pl>