dWebSpec Dictionary
CONTEXT: descriptors->event->call-type->ajax




All Details Standard Only Platform Only
Structured Web info and helpTechnologies
 Home Page
 Product Page
 Download Page
 Feedback
Javascript Tree Menu

Results for:

 event.call-type.ajax 
 Topic 

AJAX events specifications are similar to the regular POST and GET events in most areas. The few differences are highlighted here, as well as some implementation implications.

Event Source

Like with non-AJAX based events, the event source is depicted with the identity of the event source and the event type, as shown below.

       form[categoryForm].element[source element].change

For standard event, the even type must be related to server event. For AJAX event, it is a client event type that must be specified.

       form[categoryForm].element[source element].onchange

Parameters

Like non-AJAX events, parameters passed to the event need to be specified. The point of note here is the need to be more explicit in specifying parameters. For example, because the form post involves all elements in the form, the parameters for such events need not be explicit. For component based framework, the component tree is represented on the server and client side, so the issue of parameters could be implicit.

As a default it is possible to pass the page view as parameters; however performance would be enhanced if a subset is passed. This is the case, especially when the AJAX interaction involves a small fraction of components on the page.

 Struts 1.x  

Struts 1.x does not include in-built AJAX call processing facilities. However, it is easy to include such facilities. This is owing to the plethora of JavaScript frameworks that include AJAX routines, like Prototype, DOJO and Scriptaculous, just to name a few, combined with the ease of using JavaScript with Struts. The transformations of the specification to implementation code vary for the different AJAX framework, but the connection points are usually easy to identify.

We illustrate this with a simple implementation, involving an AJAX action invoke to update a segment, shown below.

EVENT DESCRIPTORS

id

event-source

parameters

handler

handler-class

security

call-type

getOrderDetail forms[orderList].elements[details].click orderparam {getOrderDetail}     ajax

The event source element would be represented in the element descriptor, only the AJAX event is captured above. The segment to be re-rendered must also be demarcated in the segment descriptor, with the link with the AJAX event (event-id).

SEGMENT DESCRIPTORS

id

type

visible

enable

value

base-page-id

extends

event-id

description

orderDetail div           events[getOrderDetail]  

The Parameter used is shown below

PARAMETERS DESCRIPTOR

id

orderparam

parent-id

 

caption

 

description

 

value

    

 

       
PARAMETER DESCRIPTOR

id

value

required

orderId {orderListForm.selectedId}  

One convenient part is s that it is easy to prototype the AJAX operations. For instance, a mock segment (orderDetailData.html) could be used as shown in the code below.

<script type="text/javascript">
function getDetails(){
	var url = 'orderDetailData.html';
	var pars = 'orderId=ABC';
	var myAjax = new Ajax.Updater(
			'orderDetail',
			url,
			{
				method: 'get',
				parameters: pars,
				evalScripts: true
			});
}
</script>
	.
	.
	.

<input type="submit" value="Save" onclick="getDetails();" />

The implementation for this would involve the replacement of the mock entries and tag replacements.

<script type="text/javascript">
function getDetails(){
	var url = '/getOrderDetail.do';
	var pars = 'orderId=${orderListForm.selectedId}';
	var myAjax = new Ajax.Updater(
			'orderDetail',
			url,
			{
				method: 'get',
				parameters: pars,
				evalScripts: true
			});
}
</script>
	.
	.
	.

<html:submit value="Save" onclick="getDetails();" />

This example illustrate the ease of implementing AJAX call specifications on the Struts 1.x platform.