Struts Applications
 
   

AjaxTags

PDF
PDF

Overview

This project has the goal of adding AJAX (Asynchronous Javascript+XML) functionality to the existing Struts HTML taglib, and providing a declarative method for using the functionality. The basic idea is that an EXISTING Struts-based app using the HTML taglib can add AJAX functionality without disrupting the existing code and without the developer having to know any of the details of how AJAX works. This project is the brainchild of the lead (and currently only!) developer, Frank W. Zammetti

Features

  • Existing code will NOT be broken by using this modified taglib
  • AJAX functionality is defined in a declarative fashion (i.e., an XML config file)
  • Using AJAX functionality is relatively non-intrusive (i.e., requires very little change to existing pages)
  • A number of "standard" AJAX functions are provided out-of-the box
  • New functions can easily be added as the developer sees fit

What's New

AjaxTags (in its current form!) is dead... long live AjaxTags!

7/1/2005 - AjaxTags has evolved... it is no longer a Struts-only solution! AjaxTags can now function with any framework out there, or with no framework at all, with the same degree of ease and codeless implementation as it gives developers now. New versions of AjaxTags, not being Struts-specific any longer, will not be distributed on this site (what is here now will of course remain though). AjaxTags is being rolled into the Java Web Parts project, and all new versions will proceed from there. Although the generic version is not strictly-speaking backwards-compatible, you will find that the transition is quite easy. Your configuration files ARE NOT changed in ANY WAY, only what is on your JSPs are slightly different. I highly encourage anyone using AjaxTags now, or considering using them, to head on over to The Java Web Parts site and grab and download and check it out. The Java Web Parts Site

v1.0 beta 3 released

6/28/2005 - This version contains some good bug fixes, and one new handler, XSLT, contributed by Ricky Tong. Note that with this version, support for Struts 1.2.7 HAS BEEN REVOKED! Read the history and readme files for details.

v1.0 beta 2 released

5/22/2005 - A fairly major upgrade... most importantly, almost all Struts versions in the 1.2.x brancy (1.2.0 through 1.2.6 at present) are now supported!

v1.0 beta 1 released

5/12/2005 - I think I got everything set up now on SourceForge, so there is now an official first release! It is feature-complete except for all the planned standard handlers, but those will be coming shortly (and others can pitch in if they wish!). The code seems quite stable, a number of people have been playing with it for a while with no problems reported, so although it's officially in beta, I feel fairly confident in it right now.

Usage

It is highly recommended that anyone thinking of using this project review the readme file that accompanies the release. This will give you, hopefully, every answer you will need.

However, here is a brief overview of the steps involved in using this new taglib, to give you an idea of what is required to use this modified taglib and what you can do with it right away...

  1. Drop a copy of struts.jar in the src directory and build AjaxTags (just a simple Ant script, no properties to set or anything)
  2. Optional: Replace your struts-html.tld file with the AjaxTags version. If you do not keep the TLDs outside the struts.jar, you can skip this step.
  3. Add the AjaxInit plug-in to your struts-config.xml file like so:
    <plug-in className="org.apache.struts.taglib.html.ajax.AjaxInit" />
  4. Add the ajaxInit init param to your ActionServlet entry in web.xml like so:
    <init-param>
      <param-name>ajaxConfig</param-name>
      <param-value>/WEB-INF/ajax-config.xml</param-value>
    </init-param>
  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. This can be any value you wish, it is a reference value to a configuration file.
  6. Add the <enableAjax> tag to your page AFTER ALL OTHER AJAX-ENABLED FORM TAGS!
  7. Create an ajax-config.xml configuration file. Here is an example of one:
    <!DOCTYPE ajaxConfig PUBLIC "ajaxConfig" "ajaxConfig">
    <ajaxConfig>
     <form ajaxRef="example1">
      <element ajaxRef="button">
       <event type="onclick">
        <requestHandler type="std:QueryString">
         <target>example1.do</target>
         <parameter>firstName=firstName,lastName=lastName</parameter>
        </requestHandler">
        <responseHandler type="std:InnerHTML">
         <parameter>example1_resultLayer</parameter>
        </responseHandler>
       </event>
      </element>
     </form>
    </ajaxConfig>

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.

Contact

Please contact Frank W. Zammetti with questions, comments and suggestions.

Contributors

Aside from Frank W. Zammetti, the following people have contributed to the AjaxTags project:

  • Aron Gombas - Contributed a patch to fix some typos and implement more robust logging
  • Günther Wieser - Found some issues with the build process and did some troubleshooting under Resin
  • Ricky Tong - Contributed the stdXSLT handler for transforming XML returned from a server via XSL, as well as caught a problem with the build process, and some other contributions as well
Valid HTML 4.01!Valid CSS!Built with Apache Forrest logo