Nowadays RIA, Rich Internet Application, is a well-known acronym. But what is it? It refers to web applications with a rich user experience (like desktop applications).
At the begining of the WWW everything was plain HTML (HyperText Markup Language). So we had a document based technology. With plain HTML you have text, images, tables, forms and the most important: hyperlinks. When you click an hyperlink you are directed to another web page. All the content is replaced in your web browser window with the new HTML document: the previous one disappears. HTML forms are quite simple. What do you do if you want the user to input a date in a form? The only solution is to let the user submit the form and then if there are any input errors redirect the user again to the form showing those errors. And if you want the user to upload a huge file? Yes, there is an input component to submit files, but what happens when the file is big? The browser doesn’t tell the user how long it will take to upload it or which percentage has already been sent. It just says “sending request” and that’s everything but usable. And what happens if you want the user to select a “country” and a “state/province” in a form? In a desktop application you’ll put a combo box for selecting the country and another one to select the “state/province”. When the user selects a country the state/province combo is filled with the states or provinces of the selected country queried from a database for example. How can you do this with plain HTML? Sorry, you can’t. On balance HTML lacks of rich user experience.
Well, to solve these lacks JavaScript came into the scene. With JavaScript and the DOM API you can change everything on a web page. That’s cool and useful. You can do client-side form validation, you can let the user to pick a date in a calendar,… But what happens when you want to fetch data from the server like in the country-state example? The first trick was to use invisible frames or internal frames. With this hack you can load data in a separate frame and read it from another frame with JavaScript. That was the beginning of AJAX. Now we have XMLHttpRequest which is a more elegant way to perform this tasks.
So JavaScript provides functionality to build Rich Internet Applications! But… you know what? Some people doesn’t like JavaScript because it has several incompatibilities between browsers, it doesn’t support good OOP and usually breaks the accessibility and visibility (to search engines) of your web applications.
Well, if you don’t like JavaScript you have some non-JavaScript technologies to build Rich Internet Applications:
- Java applets. They are an old-fashioned solution but during some years was common to build applets for intranet applications. You can communicate with the server and fetch data using sockets. Probably you need to sign the applet for security reasons but that’s not a problem for intranet applications. And you need the users to have Java installed but again this is not a problem for intranet applications but maybe yes for internet applications.
- Adobe Flex. The approach is the same of the Java applets: through a plugin you put little applications in any HTML document. In this case you use the MXML and/or ActionScript languages to build the user interface and to code the logic. Then the code is compiled to a Flash movie (.swf) that can be executed by the Flash Player. Its benefits are:
- Flash is installed in almost any personal computer connected to the Internet (everybody watch videos on YouTube).
- No compatibility issues because there is just one Flash Player complete implementation.
- Easy development, good user experience, eye-candy graphical interface.
- OpenLaszlo based on the same approach of Flex with two major differences
- It is OpenSource. Ok, Flex will be, but not the Flash player by the moment.
- You can compile your code not only to Flash but also to HTML+JavaScript.
- Microsoft Silverlight is a new technology that competes with Adobe Flash and Flex.
And what if you like JavaScript but you don’t want to reinvent the wheel or you can use it as less as possible? You can use a server-side or client-side JavaScript based solution.
Some client side solutions (JavaScript libraries):
- Ext JS has a fantastic ready-to-use set of widgets such as grids, trees, dialogs,… I already talked about it in a previous post.
- Dojo is similar to Ext JS but in my opinion it’s more limited. However it has useful components to create mush-ups. For example you can easily integrate Google Maps into your application.
- Prototype is a popular JavaScript library that eases the use AJAX into your applications.
- Others: script.aculo.us that is built on top of prototype and provides an animation framework, drag and drop, AJAX controls, DOM utilities, and unit testing facilities; mootools also providing AJAX facilities and JavaScript effects.
Some server side solutions (server side frameworks):
- GWT (Google WebToolkit) is a Java web framework. With this framework you create graphical interfaces very similar as you will do with Swing and then, with some kind of magic, the Java code is compiled to JavaScript code. At development time you can test your application inside a Java Virtual Machine in a simulated environment with the benefit that you can use any of the development tools available for the Java programming language. It makes JavaScript transparent to the developer.
- JSF (Java Server Faces) is a Java technology derived from JSP (Java Server Pages). You write JSP files with the taglib set provided by JSF. These taglibs render rich widgets. Then you can write code in Java that responds to the events of those widgets (like a desktop application). Like GWT it also makes JavaScript transparent to the developer. JSF is designed to provide rapid application development. There are several graphical tools for creating JSF based web applications.
- Ruby-on-Rails (RoR) is a pioneer framework on providing AJAX facilities.
- Other frameworks: nowadays all the most popular frameworks available for any language provide functionalities for building Rich Internet Applications. Some examples: Symfony for PHP or TurboGears for Python.
Ok, is there any additional rich user experience we want in our applications? Let’s see. All these previous technologies are web based (you need a browser) and you cannot work off-line with them. If you are not connected to the Internet you cannot use them. To achieve this issue recently Google has released a new technology: Google Gears. With Google Gears you can access a local relational database with JavaScript so you can store large amounts of data in the client side. So you can replicate data on the client side letting the users to query those data when they are off-line. GMail supports Google Gears so if you have it installed you can read your mail off-line. Other Google services like Google Calendar also support this technology.
Anything more? Let’s go further. Now you want deeper desktop integration. You want the user to be aware to open your application with double click using a custom icon and you want your application to be ran in a separate window (not in the browser), without the typical tool bars in a web browser: address bar, bookmarks,… Has somebody thought about that before?
- Prism is a project from the Mozilla Fundation. You can launch your web-based applications like a desktop application: with a separate window without any toolbar, with a double-clickable icon, and basically that’s all by the moment.
- Adobe AIR (called Apollo in the alpha version) is a runtime environment that let’s you use several technologies such as Flex, Flash, HTML, AJAX and PDF. It has a built-in web rendering engine (WebKit) to support all those technologies and brings you some other features:
- You can make an installer for your application.
- Double-clickable desktop icon to launch your application in its own window.
- You can create local relational databases because it comes with SQLite.
- Drag-and-drop support with the underlaying operating system.
Fantastic. You have a huge set of technologies. Is there any more? Well, yes. There is another way of making Rich Internet Applications: you can avoid any web-centric programming language and create a desktop application written in any language that consumes data from web services. For example: Google Earth, Flickr Uploader or Twitterrific. With this approach you don’t have any limitation in the user experience. But you loose one big feature of web applications: installation and upgrades are transparent in web-based applications. With Adobe AIR you have the same problem. Is there a solution? From several years ago if you develop a desktop application using Java SE you can distribute it with Java Web Start. Using JWS (Java Web Start) you create an XML file in JNLP format and with .jnlp extension. In that file you define where the application is hosted, which version of the Java Runtime Environment is needed and much more. Then you put an hyperlink into your web linking to that JNLP file. If the user has that file type is associated to JWS (you can detect with JavaScript if the user has JWS installed) when the user clicks on the hyperlink Java Web Start downloads, installs and launches your application. Everytime the user runs the application Java Web Start asks the server for upgrades and downloads them if available. Of course this technology is only avaiable for Java applications. However if you don’t use Java or don’t want to use JWS you can always create your own upgrade system by hand.
Finally you can also create an hybrid as explained in a later post: Making double clickable Java EE web applications.
Anything more? Yes! I haven’t talked about mobile solutions! Maybe in a future post… By now remember this: Rich Internet Applications are here and all these technologies I have talked about are changing the way of how Internet applications are being developed.