AJAX FAQ for Java-developers

All of us could use technology AJAX (Asynchronous Java Technology and XML, Asynchronous technology Java and XML) and many of us open here for themselves the whole new world.

While many programmers will only casually collide{face} with AJAX within the framework of existing systems (so we shall translate further the term framework), you, probably, want to investigate this technology more deeply or to expand already available functionality.

This FAQ is intended for Java-developers who would like to add AJAX-functionality in the applications.



Whether it is necessary to use AJAX?


No doubt, AJAX it is now popular, but, maybe, he not absolutely approaches you: his{its} use is limited to web-browsers of the latest versions, and also forces to solve questions of compatibility of web-browsers and demands new knowledge and skills. Therefore before you with a head plunge in AJAX, you should read very good blog (blog) Alex Bosvorta (Alex Bosworth) on page AJAX Mistakes.

On the other hand, AJAX allows to create web-applications with rich interactive opportunities which react to actions of the user and are carried out really quickly.

Though the statement that the applications using AJAX, work faster, can seem disputable, it is impossible to deny that fact, that users feel immediate reaction of the application as AJAX provides for them active feedback while updating of the data occurs in a background mode " for the staff ".

If you are not afraid to solve questions of compatibility of web-browsers and are ready to reception of new skills, AJAX - that is necessary for you.

For the beginning try to change with help AJAX only small parts or components of your applications. All of us like new technologies, however it is not necessary to forget, that application AJAX should improve interaction with the user, instead of to be to him a handicap.



AJAX and Java: teamwork is possible{probable}?


Certainly. Java fine works together with AJAX! You can use JavaEE-servers (Java Enterprise Edition) to create AJAX-pages for client web-applications and to serve AJAX-searches acting from them, to operate on the party{side} of the server a status of the objects connected to client applications, using AJAX, and to give AJAX-clients various server resources.

Componental model JavaServer Faces perfectly approaches for definition and use of AJAX-components.



Whether give server systems of means for job with AJAX?


It is quite probable, that you already use advantages AJAX: many existing systems on basis Java provide certain{determined} AJAX interaction, and new systems and libraries of components are created with improved support AJAX.

I shall not begin to result here the list of all systems basing on Java and providing job with AJAX, from fear something to pass{miss}. The good list is resulted on a site www.ajaxpatterns.org/Java_Ajax_Frameworks.


If you yet have not chosen suitable system, I would recommend you to consider use of technology JavaServer Faces (JSF) and toolkit on the basis of this technology. Creation and use of JSF-components allows to abstract from consideration of many details of generation of a JavaScript-code, AJAX-interaction of the client and the server, processing of the DHTML-given and, thus, to simplify application of technology AJAX both developers of JSF-applications, and plug-ins in the JSF-compatible integrated environments of development (Integrated Development Environment, IDE), such as Sun Java Studio Creator.



With what to start?


If the system which you use, not quite approaches for the decision of your problems{tasks} and you want to develop own AJAX-components or additional functionality, start with clause{article} Asynchronous JavaScript Technology and XML (AJAX) With Java 2 Platform, Enterprise Edition.


The most simple example with an initial code is resulted in clause{article} Using AJAX with Java Technology. More full list of AJAX-resources is resulted on page Blueprints AJAX Home.


It is useful to study clause{article} AJAX libraries and frameworks to not invent a bicycle by development of own client AJAX-scripts.


Book AJAX in Action, written by Dejvom Crane (Dave Crane) and Eric Paskarelo (Eric Pascarello) together with Darrenom James (Darren James) is useful to the Java-developer as contains ready examples JavaScript.

What it is necessary to know to create own AJAX-functionality?


If you do not plan to use available AJAX-components, you should study the following technologies.


Dynamic HTML (DHTML) - the technology which is a basis for AJAX. DHTML provides interaction of the user with the application in a mode real time means of a browser. DHTML - combines JavaScript, Dokumentnuju Objective Model (Document Object Model, DOM) and Cascade Tables of Styles (Cascading Style Sheets, CSS).


* JavaScript is nestrogo the typified object-oriented language of scripts supported by all most popular web-browsers and necessary for organization of AJAX-search.es JavaScript a code it is caused on page in reply to some event, such as end of loading of page, click of the mouse or pressing of a key on an element of the form.

* DOM is API for job with the structured documents such as XML or HTML. In most cases DOM represents structure XML-or HTML-documents.

* CSS allows you to define{determine} appearance of page: fonts, colors, the sizes and an arrangement. CSS it is intended for clear split of the maintenance{contents} from external performance which can be changed programmno with help JavaScript.


Also it is important to understand, that essence HTTP of the report is the mechanism of searches / answers (request/response). Many hardly perceptible mistakes can arise, if you ignore distinctions between methods GET and POST at adjustment of client object XMLHttpRequest or at processing codes of HTTP-answers during callbacks.


JavaScript connects together all other parts of the client interface. First, he is used for creation of object XMLHttpRequest and start of asynchronous calls. Second, JavaScript allows to analyze and process the data returned from the server and the message. And at last, JavaScript allows to add the new maintenance{contents} in HTML the document and to change CSS styles, using DOM API.