马上行动 - Action Now
===========================================================
Coding your second Jakarta Struts Application
===========================================================

Coding your second Jakarta Struts Application

http://javaboutique.internet.com/tutorials/Struts2/

Introduction

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:

  • how to download and install Struts
  • the directory structure of a Struts application
  • how to create the first pieces of a new application
  • the contents and purpose of the configuration files
  • how to build a simple Struts HTML page using taglibs
  • how to code an ActionForm class
  • how to code an Action class
  • and finally how to test your application

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.

The DVD library application

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:

  • write the proper configuration files (struts-config.xml and ApplicationRessources.properties)
  • code ActionForm and Action classes for the 7 functions
  • write the two jsp-pages using Struts tags

nmtcolin 发表于:2008.04.11 23:14 ::分类: ( IT ) ::阅读:(38次) :: 评论 (0)

发表评论
标题

在此添加评论
表情符号: smile laughing tongue angry crying sad wassat wink

称呼

邮箱地址(可选)

个人主页(可选)




自我介绍
切换风格
新闻聚合
博客日历
文章归档...
最新发表...
博客统计...
Blog信息
网站链接...