Book Image

Learning Jakarta Struts 1.2: a concise and practical tutorial

By : Stephan Wiesner
Book Image

Learning Jakarta Struts 1.2: a concise and practical tutorial

By: Stephan Wiesner

Overview of this book

<p>Jakarta Struts is an Open Source Java framework for developing web applications. By cleanly separating logic and presentation, Struts makes applications more manageable and maintainable.<br />Since its donation to the Apache Foundation&nbsp; in 2001, Struts has been rapidly accepted as the leading Java web application framework, and community support and development is well established.<br /><br />Struts-based web sites are built from the ground up to be easily modifiable and maintainable, and internationalization and flexibility of design are deeply rooted. Struts uses the Model-View-Controller design pattern to enforce a strict separation between processing logic and presentation logic, and enables efficient object re-use.<br /><br />The book is written as a structured tutorial, with each chapter building on the last. The book begins by introducing the architecture of a Struts application in terms of the Model-View-Controller pattern. Having explained how to install Jakarta and Struts, the book then goes straight into an initial implementation of the book store. The well structured code of the book store application is explained and related simply to the architectural issues.<br /><br />Custom Actions, internationalization and the possibilities offered by Taglibs are covered early to illustrate the power and flexibility inherent in the framework. The bookstore application is then enhanced in functionality and quality through the addition of logging and configuration data, and well-crafted forms. At each stage of enhancement, the design issues are laid out succinctly, then the practical implementation explained clearly. This combination of theory and practical example lays a solid understanding of both the principles and the practice of building Struts applications.</p>
Table of Contents (20 chapters)
Learning Jakarta Struts 1.2
Credits
Preface
About the Book
Glossary
Literature

6.2 Struts Form Beans


Now that we have gone over the basic procedure, it is time for implementing the real shop. The Book class now requires further properties and we need another bean for authors. Since it is vital for storing a book, we will start with the Author bean. Create a new context called shop4, as a copy of shop3.

6.2.1 The Author Form

If you like a challenge, create the author form by yourself before reading further. It will need an ID, first name, and last name field. The ID could be created by the database (by specifying the column as AUTO_INCREMENT), but for our purposes we shall set it manually.

Note

Use the download from the book’s website to see the complete version of the class. In this section, we only look at the differences to the book form we created.

The form for entering author information looks like this:

Listing 6.5: The Struts Author Form
<html:errors/>
<html:form action="createAuthor" method="GET">
<bean:message key="author.id"/>
<html:text property...