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.

 Seam  

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.

Implementation

For the elements from the UICommand family and output links, it is necessary to select AJAX aware components when resolving the element type. This makes sense, since standard components would invoke a standard event rather than going through the AJAX mechanism. These alternatives are presented in the overview of the element descriptor.

For elements of other types, it suffices to employ an AJAX extender. Seam provides such extender, in a4j:support component. We illustrate the use of this component with a simple specification.

The specification is as follows.

EVENT DESCRIPTORS

id

event-source

parameters

handler

handler-class

security

call-type

5 forms[main].elements[in].onchange   {bean.refresh}     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

result-seg inline           events[5]  

These elements and segment are shown in the source content below.

<input type="text" id="in" />

<!--aws:segment id="result"?-->

	<h:outputText?id="result"?value="#{bean.countryName}"/>

<!--/aws:segment?-->

The implementation code is shown below.

<h:inputText id="in" value="#{bean.countryCode}">

????<a4j:support?event="onchange"?action="#{bean.refresh}" reRender="result"/>

</h:inputText>

<h:outputText?id="result"?value="#{bean.countryName}"/>

The segment to re-render is inline, without behavior, that has a single component within; therefore the re-rendering could target the single component.

AJAX Extender

The extender provided is a4j:support. The event descriptor mapping to the component attributes is provided in the table below.

descriptor attribute a4j:support description
id   The event descriptor id is used for specification identity only
event-source event The source part of the event-source, would point to an element, which would the element to extend The event part would correspond to the event attribute of the extender.
handler action The method binding to an event handler.
handler-class actionListener An anonymous listener could be specified
parameters   Without an explicit specification, all parameters on the component tree are the parameters. This might be harmless, however there is potential for harm, since conversions and validations for these parameters would occur. To limit the parameter to that involving the event source, specify ajaxSingle = "true".
security    
call-type: immediate immediate  
call-type: ajax   This is the flag that provided the indication that an AJAX extender is required.
call-type: auto-postback n/a  
Reflected in the segment descriptors reRender comma-separated list of Id's, for all segments that register a particular AJAX event as a redering event.