Ajax taglib ver. 1.8


    Custom JSP taglib lets you deploy Ajax approach in your application. Tag AjaxDiv lets you define an area in your HTML code that will be periodically updated through asynchronous HTTP requests. The typical pattern - Ajax include. You can build your HTML page dynamically via set of Ajax requets. asseFor example:
 


<script language="JavaScript" src="cjajax.js"></script>

<%@ taglib uri="taglib.tld" prefix="a" %>

<a:AjaxDiv id="i1" url="newContent.jsp" timeout="10">
  this content will be updated every 10 seconds
</a:AjaxDiv>

In the above mentioned example tag will request the file newContent.jsp and update your area every 10 seconds. In order to use this tag you have to describe an external JavaScript file cjajax.js on your page.

You can directly update your area (right from JavaScript) via the following call: update_idForYourArea(). E.g. in the above mentioned example (area id is i1) this call looks so: update_i1().

Timeout (in case of setting this parameter in tag) will be available through the JavaScript variable timer_idForYourArea. E.g. in the above mentioned example (area id is i1) you can stop process by this call: clearTimeout(timer_i1).

Also you can provide your own JavaScript function for error reports. E.g.:
 


<script language="JavaScript" src="cjajax.js"></script>

<script language="JavaScript">
function onError() { alert("Count not get data"); }
</script>

<%@ taglib uri="taglib.tld" prefix="a" %>

<a:AjaxDiv id="i1" url="newContent.jsp" timeout="10" error="onError">
  this content will be updated every 10 seconds
</a:AjaxDiv>

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:
 


<script language="JavaScript">
function myHandler(txt, xmlDoc)
{
  your own processing for the requested content
}
</script>

Attributes beforeAction and afterAction lets you provide your own JavaScript code that marks start/end phase of request. For example you can show/hide here some loading image etc.

A negative value for timeout attribute simply disables area's update.

Tag AjaxScrollArea lets you add request content to some area. For example:
 


<script language="JavaScript" src="cjajax.js"></script>

<%@ taglib uri="taglib.tld" prefix="a" %>

<a:AjaxScrollArea id="i1" style="overflow:auto;height:200px" url="newContent.jsp" timeout="10" direction="up">
  this content will accumulate all the data returned by newContent.jsp
</a:AjaxScrollArea>

Tags are:

AjaxDiv

Body tag defines a div block updated via Ajax call. Parameters are:

1) id Describes a CSS (DHTML) id.
2) url Describes an URL for your requests.
3) className Optional parameter. Describes your own CSS class for this area.
4) style Optional parameter. Describes your own CSS style for this area.
5) timeout Optional parameter. Describes a timeout for the periodical calls (in seconds).
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) handler Optional parameter. Describes a name for your own JavaScript function that will accept the requested content. By default this function updates (replaces) content in the described area.
8) beforeAction Optional parameter. Describes a name for your own JavaScript function that will be called at the beginning of request. By default is empty.
9) afterAction Optional parameter. Describes a name for your own JavaScript function that will be called at the end of request. By default is empty.

AjaxScrollArea

Body tag defines a scrollable div block updated via Ajax call. Parameters are:

1) id Describes a CSS (DHTML) id.
2) url Describes an URL for your requests.
3) className Optional parameter. Describes your own CSS class for this area.
4) style Optional parameter. Describes your own CSS style for this area. Default value is overflow:auto.
5) timeout Optional parameter. Describes a timeout for the periodical calls (in seconds).
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 name for your own JavaScript function that will be called at the beginning of request. By default is empty.
8) afterAction Optional parameter. Describes a name for your own JavaScript function that will be called at the end of request. By default is empty.
9) direction Optional parameter. Possible values are up and down. Describes how (where) to add new content relatively existing data. Default value is down.
 

for downloading:

 Library: ajaxdivtag.jar     Description: taglib.tld  JavaScript library: cjajax.js

 © Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.


     

Also in Coldtags: