JBoss Tools 3 Developers Guide
上QQ阅读APP看书,第一时间看更新

Chapter 5. Struts Tools

Struts Tools is a complex and complete solution for developing web applications using the Struts framework. Based on views, editors, and wizards, Struts Tools provides powerful support for developing and managing Struts configuration files, validator files, tiles files, and other Struts components. In this chapter we will see how to exploit these features of Struts Tools to develop a Struts application faster and easier than you have ever done before.

Speaking of Struts applications, in the following sections we will develop a classic Struts application that will take advantage of the most used Struts capabilities, such as Struts tags, validation, and tiles. The example consists of a simple JSP page containing a Struts form with three fields, as follows:

  • name—this is a text field that will allow the user to insert his name
  • zip—this is a text field that will allow to the user to provide a zip code
  • email—this is a text field for the user's email address

The information provided by the user will be client-side validated, submitted (using a Struts </html:submit> button), server-side validated, and displayed again in a new JSP page. As a particularity, both JSPs will have the same header and footer, which will be represented by a small and simple HTML code.

Tasks such as building the form, preserving information between pages, transitions between JSPs, copying header and footer in both JSPs, validating information, and so on, will be accomplished based on Struts capabilities and respecting Struts architecture. Obviously, because we want to do this fast and easy, we will use Struts Tools.

The following diagram presents our application in Struts style and using Struts terminology (to understand it, think in Struts!). This may look a little complicated at the moment, so you may want to come back to it after you have read a little further and things start becoming clearer.

Struts Tools