Coding your second Jakarta Struts Application
Did the title of the article make you curious? If this is the second application then what was the first one? The answer is, the first application was presented in my previous article about Jakarta Struts, "Stepping through Jakarta Struts". Here I showed you:
The "application" that I used as the example was a simple HTML page containing a form with the common controls--text and textarea fields, radio buttons, a checkbox, a selection list (drop down), and a submit button. The submit button would simply submit the form to the page again, and despite the simplicity of the application, all of the main pieces of the Struts framework were being used.
In this article I'll show you how to take one more step up the Struts ladder. This time we'll build a classic list-detail application with the well-known CRUD-actions: Create, Read, Update, and Delete.
Reuse is a good thing, so I decided to take the specs for our second application from a previous article of mine, "Java and JDOM: the perfect couple". Here, a small web application that could manage a collection of DVDs was built. The DVD information is held in an XML file. The application consists of two pages, a DVD List page and a DVD Detail page. Here's the List page first:
When you click on one of "Id"-hyperlinks you'll go to the Detail page:
As you can see there are 7 functions in total to implement: list, detail, save, update, create, delete and cancel. The flow of the application is as follows:
In the JDOM article, I used a very simple MVC-architecture using only jsp-pages (even for the controllers) and JavaBeans. The beans can be re-used in the Struts application, and also the html layout. To finish the Struts application we'll have to:
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/4082/viewspace-1002354/，如需转载，请注明出处，否则将追究法律责任。