Custom JSP taglib lets you mimic HTML form with Ajax request. Tag AjaxForm performs
HTTP GET/POST request provided in form's action attribute via Ajax. For example:
Here tag lets you asynchronously submit request to /servlet/MVC. In order to use this tag you have to describe an external JavaScript file cjajax.js on your page.
An optional parameter handler lets you provide your own JavaScript function that will accept the requested data.
This function will get two parameters - obtained text and obtained XML document:
An optional attribute error lets you provide you own JavaScript function that will reports about errors. For example here we are updating some div area via Ajax call:
Also you can provide your own JavaScript functions that will be executed before and after the request. For example here we are showing/hiding progress indicator:
Tags are:
AjaxForm
Body tag mimics HTML form for Ajax. Parameters are:
1) id Optional parameter. Describes a CSS/DHTML id for your form.
2) name Optional parameter. Describes a name for your form.
3) method Optional parameter. Describes a method for your form. Possible values are
get or post. Default value is get.
4) action Optional parameter. Describes an URL for your form. By default it will be the same JSP file.
5) handler Optional parameter. Describes a function for the customized processing.
6) error Optional parameter. Describes a name for your own JavaScript function that will be called in case
of errors. By default is empty.
7) beforeAction Optional parameter. Describes a JavaScript function that will be called before
the request.
8) afterAction Optional parameter. Describes a JavaScript function that will be called upon the request
completion.
9) onSubmit Optional parameter. Describes a JavaScript function for the validation
before submitting.
for downloading:
Library: ajaxformtag.jar
Description: taglib.tld JavaScript library: cjajax.js Progress indicator:
See also Coldtags suite - the largest collection of custom JSP tags.