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.
AjaxScrollArea Body tag defines a scrollable div block updated via Ajax call. Parameters are: 1) id Describes a CSS (DHTML) id.
for downloading: Library: ajaxdivtag.jar Description: taglib.tld JavaScript library: cjajax.js See also Coldtags suite - the largest collection of custom JSP tags.
|
Also in Coldtags:
|