Book Image

Seam 2.x Web Development

Book Image

Seam 2.x Web Development

Overview of this book

The Seam framework from JBoss allows developers to use JSF, Facelets, EJB, and JPA to write conversational web applications. But you will first have to learn how these standard technologies are integrated using Seam and how they can be built upon using additional Seam components. If you need to build a Java web application fast, but don't have time to learn all these complex features, then this book is for you. The book provides a practical approach to developing Seam applications highlighting good development practices. It provides a complete walk through to develop Web applications using Seam, Facelets, and RichFaces and explains how to deploy them to the JBoss Application Server. You can start using key aspects of the Seam framework immediately because this book builds on them chapter by chapter, finally ending with details of enterprise functionality such as PDF report generation and event frameworks. First, the book introduces you to the fundamentals of Seam applications, describing topics such as Injection, Outjection and Bijection. You will understand the Facelets framework, AJAX, database persistence, and advanced Seam concepts through the many examples in the book. The book takes a practical approach throughout to describing the technologies and tools involved. You will add functionality to Seam applications after you learn how to use the Seam Generator RAD tools and how to customize and fully test application functionality. Hints and tips are provided along the way of how to use Seam and the JBoss Application Server.
Table of Contents (17 chapters)
Seam 2.x Web Development
Credits
About the author
About the reviewers
Preface

Preface

This book provides a complete walk-through of developing Web applications using Seam, Facelets, and RichFaces, and explains how to deploy them to the JBoss Application Server.

This book introduces you to the fundamentals of Seam applications, describing topics such as Injection, Outjection, and Bijection. You will understand the Facelets framework, AJAX, database persistence, and advanced Seam concepts, through the many examples explained in the book.

A practical approach is taken throughout the book to describe the technologies and tools involved. You will add functionality to Seam applications after you learn how to use the Seam Generator RAD tools and how to customize and fully test application functionality. Hints and tips on how to use Seam and the JBoss Application Server are provided along the way.

What this book covers

Chapter 1 provides an overview of the Seam Framework, and describes the benefits that we, as Java developers, will gain by using the framework. We learn that Seam is much more than a framework, and that it comes packed with support for numerous other features.

Chapter 2 teaches you how to develop applications using Seam, and explains some of the features discussed in previous chapter. In this chapter, we will learn the basic structure of a Seam application and learn more about Seam components. We will also see exactly how Seam bridges the gap between the Web tier and the Server tier.

Chapter 3 takes you through page navigation using Seam page flows. We also see how we can define page flow within the pages.xml file of our applications by defining both static rules and rules encompassing JSF expression language.

Chapter 4 shows you why Facelets is recommended, and what it offers over JSP. We'll also look at the SeamGen tool and see why this is a much better way of creating Seam applications and building scripts. Finally, we bring both SeamGen and Facelets together and re-create the Vacation Planner project that we wrote in Chapter 3, (realizing in the course of doing so how much easier and more advanced it is), using these technologies

In Chapter 5, we take a look at TestNG and see how it can be used to build sets of test suites. We have a look at how Seam provides excellent facilities by allowing us to perform testing of our applications, at the class, Seam component, and user interface levels.

In Chapter 6, we take a look at RichFaces and learn that it's a JSF component library that allows us to easily build rich user interfaces within web applications. This chapter explains how Seam is fully integrated with RichFaces, and that applications generated by SeamGen require no special configuration to allow RichFaces to be used. This chapter also lists all of the components available within RichFaces.

Chapter 7 introduces database persistence with Seam. We take a closer look at how SeamGen helps us to create and configure our applications, allowing test, development, and production profiles to be configured.

Chapter 8 takes a closer look at what exactly a conversational application is and why they make web application development easier and more functional. We also take a look at different component scopes and see why they are important to Seam.

In Chapter 9, we take a look at AJAX and how it can be applied to Seam applications. We also take a closer look at the two different AJAX technologies within the Seam framework: Seam Remoting and AJAX4JSF.

Chapter 10 discusses how security is implemented within a Seam application highlighting the most common features, such as logon pages, user access rights, CAPTCHAs, and so on, which are used to secure Seam applications. We also highlight some of the more advanced security features that can be used.

Chapter 11 walks through some of the more advanced features of Seam, such as internationalization, URL rewriting, PDF document generation, and so on, and also discusses how these can be used within our web applications.

Who this book is for

This book is for Java EE application developers who are new to Seam and who are interested in developing with Seam 2.x.

You need a basic understanding of Java EE and must also be aware of EJB3, although you do not need to know it in detail. Experience with JBoss AS would be an advantage, but all you really need is to be comfortable using any application server. Knowledge of AJAX and JavaScript would also be beneficial, although not necessary.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The <page> element defines the pages to which the enclosed navigation rules are applicable."

A block of code will be set as follows:

<exception class="com.davidsalter.HolidayException">
<redirect view-id="/error.jsp">
<message severity="ERROR">
Whoops. Better make sure we write some better tests !
</message>
</redirect>
</exception>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be shown in bold:

@Entity
@Name("customer")
@Table(name="CUSTOMER_TABLE")
public class Customer {
// .. Omitted for brevity
@Id
@GeneratedValue
@Column(name="CUSTOMER_ID")
public Long getId() {
return id;
}

Any command-line input or output is written as follows:

[input] Enter the JDBC URL for your database [jdbc: hsqldb:.] [jdbc:hsqldb:.]

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "The following action that is within this class is executed when the user clicks on the Select button on our web page."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to , and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note via the SUGGEST A TITLE form on www.packtpub.com or by sending an email to .

If there is a topic that you have expertise in and that you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/5920_Code.zip to directly download the example code.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.