Ajax and Ria html

Ajax and Ria

Despite of what the title may suggest this is not about a greek mythological drama about a hero and a woman. But it ís about interaction and exchanging of information. RIA is an acronym for Rich Internet Applications while AJAX stands for Asynchronous JavaScript and XML.

A truly interactive web application based on J2EE (or .NET) is quite difficult to achieve. Interaction can be that the user enters some data on a page, the page is sumitted to the server and a response page is generated and sent to the client. This can hardly be called interactive and cannot be compared to e.g. Flash or the traditional client applications. A big improvement would be to get rid of many of the the page submits.
This is where Ajax comes in.

Ajax provides a mechanism for asynchronous client-server communication. This means that in the background (i.e. non-intrusive for the user) the webpage can exchange data with the server and present that to the user. The most well known examples are Google suggest and Google mail where user is provided with suggestions (like emailadres) while he/she types in a text field. This is done with javascript and the so called XMLHttpRequest. Despite the name it is not tied to XML. The javascript code is actually quiet simple and contains something like:

        // create an XMLHttpRequest for non IE browsers
    xmlHttpReq= new ActiveXObject("Msxml2.XMLHTTP");
        // or for IE
    xmlHttpReq= new ActiveXObject("Microsoft.XMLHTTP");

        // prepare the request
    http.open('GET/POST', url,true);
        // be ready for a response
        xmlHttpReq.onreadystatechange = function() {
                if (xmlHttpReq.readyState == 4) {
                    var respons = xmlHttpReq.responseText;
                    // do something with the response
                }
            }
            // submit the request
        xmlHttpReq.send(<URLQueryString>);

On the server an ordinary servlet can react to this request. That could be something like:

public MyAjaxServlet()
{
    public void doGet(HttpServletRequest request, HttpServletResponse response)  throws ....
    {
            // retrieve the values from the request, actually from the URLQueryString e.g.
        String param1 = request.getParameter("param1"));
            // do something with this request and the parameters
            // create a (html) respons may be by forwarding to a jsp
    }
}

An example of this can be found at this site.
More ajax examples can be found at fiftyfoureleven.com

The response mechanism of ajax is only one part of the story. The other part is what the page and the user can do with this data. HTML is quite limited. It offers only a few elements like textboxes, images, etc. It would be great to have more controls like trees and sliders, a single page interface, drag-and-drop functionality, text and other effects, etc. etc. The combination of javascript and XHTML has a lot to offer, but is very hard to do if you’re not really experienced in these fields.

Fortunately, the dutch company Backbase has developed an impressive product for developing rich internet applications that can be integrated with j2ee and .net applications. Take a look at the demo’s and be surprised.