You want to avoid typographical errors in the various Struts configuration files and make editing and maintenance of these files easier.
One of the most common causes of errors in web applications is
typographical mistakes. In general, most modern software
applications—Struts included—rely on configuration files
and deployment descriptors in some form of ASCII text, typically XML.
Using a validating XML editor can help alleviate mistakes; however,
it does not eliminate the mistyped path, form-bean
name, or class name.
The Struts Console, available for download at http://www.jamesholmes.com, provides a graphical editor for the Struts (struts-config.xml), Validator (validation.xml and validator-rules.xml), and Tiles (tiles-defs.xml) configuration files. Instead of hand-editing these files, you use the Swing-based editor provided by Struts Console. In addition to reducing the typos, Struts Console gives you a birds-eye view of these files for easier browsing. You will find this feature invaluable when your configuration files start to get large.
Struts Console provides "smart"
graphical editors for the XML-based configuration files used in
Struts development. Figure 1-2 is the view of the
struts-config.xml file for the
struts-example
application.
The Editor tab presents two panes. The left pane contains a tree view of the elements that make up the configuration file. The right pane contains a graphical editor window. Different editors are shown depending on the element selected in the tree view. In Figure 1-2, the /saveSubscription action mapping is selected in the tree view and the Action editor displays all the details.
In a read-only window, the Source tab displays the XML source of the configuration file. As you make changes using the graphical editors, the source is updated as well. However, changes are not committed to disk until you save the file.
Warning
Because the Struts Console parses and manages actual XML data, when the file is resaved, it won't contain any custom formatting or comments in the original file.
One aspect that sets Struts Console apart from a conventional XML editor is that the Struts console understands how the elements interrelate. For example, in Figure 1-2, a drop-down list of the available Form Beans can be displayed. Clicking the View button to the right of the Form Bean drop-down will display the selected Forms definition. The Form Bean editor will be displayed and the selected element in the left pane tree view will be updated to reflect the form bean being viewed.
As of this writing, Struts Console Version 4.4.1 supported creation and editing of the following files:
Struts Configuration (for Struts 1.2, 1.1, and 1.0); e.g., struts-config.xml
Tiles Configuration; e.g., tiles-defs.xml
Validator Configuration (for Struts 1.1, and 1.0); e.g., validator-rules.xml, validation.xml
JSP Tag Library Descriptor (TLD) (JSP Version 1.2, 1.1); e.g., struts-html.tld
In addition to its use as a standalone application, Struts Console can be plugged into most Java IDEs such as Eclipse, NetBeans, and IntelliJ IDEA.
The best recommendation before using any graphical editing tool is to become familiar with the structure and meaning of the elements with the Struts configuration files. Only then do you want to rely on using a tool that hides this structure from you. It's similar to when you learn a new programming language—before you start relying on an IDE to do the heavy lifting, you must learn how to use the language using simple text editors and the command line. Though graphical tools are useful and will save you debugging effort in the long run, you need to understand the basics of these files so you can diagnose configuration issues when they occur.
James Holmes's web site is where you get the Struts Console. His excellent site provides additional detail on the Struts Console. James is working on other tools, so visit him at http://www.jamesholmes.com.
Struts 1.2 includes a plug-in, the
ModuleConfigVerifier
,
that is designed to catch errors in your Struts configuration file
when your application initializes. For details on this plug-in, see
http://struts.apache.org/api/org/apache/struts/plugins/ModuleConfigVerifier.html.
MyEclipse is a customized version of the Eclipse IDE. This excellent IDE provides an environment tailored to developing J2EE applications. At the time of this writing, the latest MyEclipse version was based on Eclipse 3.0, so it is quite up to date. MyEclipse is not free; however, the annual subscriptions are under $50 and well worth it if you are looking for a one-stop-shop IDE. Check it out at http://www.myeclipse.com.
Struts Studio is an ambitious undertaking bringing a commercial-grade graphical development to Struts developers. It's located at http://www.exadel.com/products_strutsstudio.htm.
Get Jakarta Struts Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.