StrutsInActionSrc
所属分类:Java书籍
开发工具:Java
文件大小:1460KB
下载次数:29
上传日期:2006-05-07 14:27:31
上 传 者:
卡罗
说明: 这是《Struts In Action》的源代码,不需要解压密码。
(This is the "Struts In Action" in the source code without extracting passwords.)
文件列表:
ajaxtags\customXMLGenerator.js (258, 2005-05-24)
ajaxtags\CVS (0, 2005-06-28)
ajaxtags\CVS\Entries (201, 2005-06-28)
ajaxtags\CVS\Entries.Extra (112, 2005-06-28)
ajaxtags\CVS\Entries.Extra.Old (112, 2005-06-28)
ajaxtags\CVS\Entries.Old (179, 2005-06-28)
ajaxtags\CVS\Repository (10, 2005-06-27)
ajaxtags\CVS\Root (43, 2005-06-27)
ajaxtags\index.jsp (6902, 2005-06-27)
ajaxtags\record.xsl (480, 2005-06-28)
ajaxtags\sarissa.js (25348, 2005-06-18)
ajaxtags\WEB-INF (0, 2005-06-28)
ajaxtags\WEB-INF\ajax-config.xml (4307, 2005-06-27)
ajaxtags\WEB-INF\CVS (0, 2005-06-28)
ajaxtags\WEB-INF\CVS\Entries (163, 2005-06-28)
ajaxtags\WEB-INF\CVS\Entries.Extra (100, 2005-06-28)
ajaxtags\WEB-INF\CVS\Entries.Extra.Old (100, 2005-06-28)
ajaxtags\WEB-INF\CVS\Entries.Old (163, 2005-06-28)
ajaxtags\WEB-INF\CVS\Repository (18, 2005-06-27)
ajaxtags\WEB-INF\CVS\Root (43, 2005-06-27)
ajaxtags\WEB-INF\lib (0, 2005-06-28)
ajaxtags\WEB-INF\lib\commons-beanutils.jar (118726, 2005-05-18)
ajaxtags\WEB-INF\lib\commons-codec.jar (29029, 2005-05-18)
ajaxtags\WEB-INF\lib\commons-digester.jar (109096, 2005-05-18)
ajaxtags\WEB-INF\lib\commons-logging.jar (38015, 2005-05-18)
ajaxtags\WEB-INF\lib\CVS (0, 2005-06-28)
ajaxtags\WEB-INF\lib\CVS\Entries (228, 2005-06-28)
ajaxtags\WEB-INF\lib\CVS\Entries.Extra (121, 2005-06-28)
ajaxtags\WEB-INF\lib\CVS\Entries.Extra.Old (121, 2005-06-27)
ajaxtags\WEB-INF\lib\CVS\Entries.Old (228, 2005-06-27)
ajaxtags\WEB-INF\lib\CVS\Repository (22, 2005-06-27)
ajaxtags\WEB-INF\lib\CVS\Root (43, 2005-06-27)
ajaxtags\WEB-INF\src (0, 2005-06-28)
ajaxtags\WEB-INF\src\ajax-config.dtd (1578, 2005-04-29)
ajaxtags\WEB-INF\src\build.xml (13596, 2005-06-28)
ajaxtags\WEB-INF\src\com (0, 2005-06-28)
ajaxtags\WEB-INF\src\com\CVS (0, 2005-06-28)
ajaxtags\WEB-INF\src\com\CVS\Entries (15, 2005-06-27)
ajaxtags\WEB-INF\src\com\CVS\Entries.Extra (18, 2005-06-27)
ajaxtags\WEB-INF\src\com\CVS\Entries.Extra.Old (0, 2005-06-27)
... ...
AjaxTags 1.0 Beta 3
Frank W. Zammetti
------------
Introduction
------------
The AjaxTags project is an effort to add Ajax (Asynchronous Javascript + XML)
functionality to the existing Struts HTML taglib. The idea is to make using
the techniques behind Google Maps and other well-known examples as easy as
possible for Struts developers. Note that this is NOT meant to be the
One True Way to do Ajax with Struts! Other people have other ideas about how
this should be done. However, this approach has some benefits, most
notably that it is drop-dead easy to add Ajax functionality to existing pages
without having to delve in to all the details of Ajax.
Note that AjaxTags has been tested on Internet Explorer 6.0 and Firefox 1.0.
Any LATER versions should be fine, any other versions or other browsers will
have to be tested.
-----------------
Building AjaxTags
-----------------
You will need to build AjaxTags for the version of Struts you wish to use.
The following versions are supported: 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4,
1.2.5, 1.2.6. Building AjaxTags amounts to compiling the code (for
AjaxTags as well as the sample app), updating the struts.jar, and the
struts-html.tld and struts-html-1.1.todl files.
The build procedure is as follows:
1. Place the appropriate (i.e., the version you wish to use) struts.jar
in ajaxtags/WEB-INF/src.
2. At a command prompt, enter ant and press enter while in the
ajaxtags/WEB-INF/src directory (obviously this assumes you already have
Ant installed and properly configured). Note that the build process
will abort and you will be informed if struts.jar is not found where
it is supposed to be.
That's it! At the end of the build process, the JAR will be
"Ajax-enabled" and ready for you to drop in your app. The updated JAR is
placed in ajaxtags/WEB-INF/lib, and also the updated TLD is placed in
ajaxtags/WEB-INF. This is all done so that the sample app is at that
point ready to be exeuted. You will also find javadocs have been
created in ajaxtags/WEB-INF/src. Note that the struts.jar in src IS DELETED,
so be sure it's not your only copy!
--------------
Using AjaxTags
--------------
Using AjaxTags couldn't be simpler (well, ok, it probably COULD be, but it's
still pretty darned simple)...
1. Build AjaxTags if you have not already done so.
2. Replace the struts.jar and struts-html.tld file in your project with the
AjaxTags version emitted by the build process. You should also replace
struts-html-1.1.tld if applicable. Note that you really should only have
to replace struts.jar because the TLDs are contained within it, but if you
need them to be external you can do so.
3. Add the AjaxInit plug-in to your struts-config.xml file like so:
4. Add the ajaxConfig init param to your ActionServlet entry in web.xml like so:
ajaxConfig
/WEB-INF/ajax-config.xml
You can of course place the config file anywhere relative to the app's root
you want and can name it whatever you want.
5. For any form element you wish to Ajax-enable, add an ajaxRef attribute to
it. In addition, add an ajaxRef to the containing form. Note that
ajaxRef elements are case-sensitive, so be sure they match exactly what
you put in the config file discussed in a moment!
6. Add the
tag to your page AFTER ALL OTHER AJAX-ENABLED FORM
TAGS! A good place to do this is right before the closing tag.
7. Create an ajax-config.xml configuration file. This maps the form elements,
based on ajaxRef's, to the functions you wish to perform in response to
which UI events.
That's all there is to it! Any form elements that you do not wish to
Ajax-enable you simply leave alone, they continue to work as usual.
--------------------------
Details Of The Config File
--------------------------
The AjaxTags are meant to be a declarative method of adding Ajax functionality
to your app. Therefore, it centers around an XML configuration file. The
following is a sample of such a file and an explanation of each element's
meaning...
customGenerateXML
customXMLGenetor.js
First of course is the doctype. The config file is validated against a DTD
that is added to the struts.jar.
The root element is always .
Next is a collection of optional elements. These define custom
request/response handlers. When an Ajax-enabled form element fires an Ajax
event, it makes a call to a request handler. These can be either one of the
standard built-in handlers or one you define yourself. When defining one
yourself you will create a element. The type attribute of the
element tells whether you are defining a request handler or a
response handler. Then comes two child elements; and .
is the Javascript function that will be called by the Ajax event.
is whether the function can be found. You can put one of two
things here: either the word "local" or a path to an external .js file.
Local indicates that you will take the responsibility of ensuring the function
is on the page (either hard-coded in or linked in or something else). If you
specify an external .js file, a script link will be added. This can be any
URL you might specify in a