Runtime tools : Channels components : AJAX channel : Concepts : AJAX request lifecycle
  
AJAX request lifecycle
This section provides an overview of the lifecycle of an AJAX request in the AJAX channel.
Lifecycle of an AJAX request in the AJAX channel
This graphic is described in the surrounding text.
The following list is a detailed description of how an AJAX request is processed in the AJAX channel:
1 An AJAX request that has been initiated by a user is received by the AjaxRequestServlet servlet.
2 The AjaxRequestServlet class retrieves a thread and assigns necessary system resources that are required by the thread, and then delegates the service method of the servlet to the thread. The thread handles the request by running the service method.
3 The service() method delegates the AJAX request to BTTChannelDriver class, and then the driver assembles the necessary resources that are required to process the request, e.g create handlers, initial device, and pre-handle request data, create necessary channel data. The BTTChannelDriver then delegates the AJAX request to the AjaxRequestHandler.
4 The AjaxHtmlRequestHandler handler determines whether the AJAX request is a duplicated request. If the AJAX request is a duplicated request, it is ignored. For more information on the handling of duplicated requests, refer to the “Duplicated request handling” section.
5 The request operation instance is created from the operation definition file.
6 If the AJAX request is sent from an HTML processor page, the AjaxHtmlRequestHandler will restore the processor context from the cache, update the processor timestamp, and rebuild the processor context hierarchy.
7 If the AJAX request is not sent from an HTML processor page, the AjaxHtmlRequestHandler chains the AJAX operation context to a session context. If the AJAX request is sent from an HTML processor page, the AjaxHtmlRequestHandler chains the operation context to the processor context. Note that if the page has a state context, the current processor context is used as the state context.
8 Operations that execute with the context hierarchy retrieve necessary data from the context tree at run time. Attention that it is suggested to not update outer-scope contexts that are required by AJAX operations in the concurrency environment, as this may cause critical errors.
9 When an execution is complete, the operation context is unchained from the parent context.
10 The AjaxHtmlPresentationHandler method invokes the processReply() method, which updates the data for the HTTP response message.
11 If the AJAX request operation is sent from an HTML processor page, it updates the processor timestamp and saves the processor context into the cache.
12 The response data is sent to the browser.
13 The AjaxRequestServlet class determines whether the session has expired and thenit releases resources that are no longer required.
The processor context and environment must loaded and saved an AJAX request is received because, in an HTML channel, when a processor state changed, e.g. processor page navigated to next page, before state changed, it will load/create the processor environment and context from cache, and then do processor state change, then the processor environment and context will be saved into cache, then you can see the page new state page displayed. So if the Ajax operation will leverage outer-scope data to finish task, the AjaxRequestHandler method will first repeat the processor current environment and context hierarchy and save the processor context when Ajax request finished, so that for the processor itself it will seems that nothing happens.
Go up to
Concepts