Edvin has posted 8 posts at DZone. View Full User Profile

Business Applications in the browser – finally a viable alternative

12.03.2012
| 4475 views |
  • submit to reddit
Web 2.0 applications are great. They are visually appealing, fast, intuitive and responsive. However, for large ERP systems and the like, the paradigms of the browser has traditionally been an ill match.

A customized design for our first Eclipse RAP application

Realizing the requirements for a business application in the browser is absolutely possible, but requires tremendous amounts of work. Hence you must choose from one of the available AJAX frameworks out there, or go bankrupt while trying to create your own. Some of the hardest things to get right and cross browser compatible are:

  • MDI and docking framework - you want to work with multiple windows and tabs, and arrange them to suit your workflow
  • Transactional state - processes in your business app very seldomly match the HTTP transaction cycle. Often you end up changing the UX to make it easier for you to cope with HTTP. Take multi page Wizards for example - they are often discarded in the web version of such applications.
  • Background tasks and progress - continue to work while the report is being compiled in the background and progress is reported to the user
  • Tables with keyboard navigation, sorting and inline editing
  • Forms framework with server side validation and conversion

I could go on and on, but you get the point. You might be thinking "I have already solved all of these in my app, I just glue it together with JQuery, ExtJS and some backend language". Well, I dare you to take a good long look at that code and ask yourself:

  • Is it pretty and maintainable?
  • Do you dance to the tune of HTTP or your own business application humm?
  • Do you write HTML, CSS, JavaScript, and PHP or Java, or are you just working with your favourite language in your favourite IDE?
  • How much time is spent writing actual business logic?

Most web apps tends to feel like a webpage, and not an actual application. Try to double click somewhere, and a large amount of text will be momentarily selected, for example. For a business application to feel good on the web, all these details needs to be ironed out.

Things were better before

I used to love writing business applications. I used Delphi as my only tool and stayed in the IDE 100% of the time. Nowadays you deal with cross browser compatibility issues, tragically bad JavaScript debugging, CSS issues and converting data between your server side and your client side technologies. A lot less time is spent on your actual application logic.

A solution available today

Well, I finally found the holy grail: Eclipse RAP. Finally I get the complete Eclipse platform, rendered to HTML. I don't have to write a single line of HTML or JavaScript, and finally: I can program solely in Java. The best part is however that I'm 100% free of the HTTP lifecycle. Let's say I want to present a dialog to the user, and act on the result. I don't have to jump back and forth between methods and glue different HTTP requests and responses together. I'll simply write:

PersonSearchDialog dialog = new PersonSearchDialog("Select a person from the list");
if (dialog.open() == OK) {
    Person selected = dialog.getResult();
    UI.info("You selected " + selected);
}

In the above example, there would be a minimum of one HTTP transaction to render the user interface for the dialog, another one to get the result and a third to show the popup to the user. This is encapsulated for me. I can still keep all the business logic where it belongs, and totally forget about HTTP or converting response payload to and from my domain objects. And before you say "I could do all this client side" - well sure, for this example you could, but a real life example would involve the need for some backend processing, and you're back to square one.

Single sourcing

With Eclipse RAP I can write my source code once, and compile both a Web client as well as native desktop applications for all major operating systems. There is even the possibility to create mobile versions using roughly the same code base with the new Eclipse Tabris framework. I personally prefer a native client, but for some applications you need to be web enabled, and you just can't afford writing your applications twice just because a customer with an iPad demands that he should be able to swich and swirl and make gestures to operate your app and refuses to use a keyboard like a grownup :)

Design

Most business applications written using a framework looks like that framework. It is often too hard to adapt the look and feel of the application, so it's just not done. Another problem is that the framework adds elements and paradigms to your UI that you just don't want. Eclipse RCP and NetBeans RCP Applications tends to look like their IDE counterparts.

In our organization, that was just not acceptable. We already had a design hacked out, so if Eclipse RAP was to be used, the design changes had to be incorprated. I found that by writing a small custom topmenu-component and some CSS that RAP converts to cross-browser CSS for me, I could easily get the design we wanted, and still benefit from everything RAP gives us by default.

But wait - you hate Eclipse RCP!?

Eclipse RAP is essentially Eclipse RCP with a different target platform. There is plenty of problems in the Eclipse camp, as I pointed out a couple of years ago. This time around, some of the points aren't valid as I'm targeting the web, and others I've solved by now developing in IntelliJ IDEA, and made wrappers for the unpleasant and old fashioned parts of the Eclipse platform. I now enjoy generics and fluent interfaces everywhere, and write a minimal amount of boiler plate. This is an example EditorPart that creates a table and lets you double click a row to open an editor for the selected element:

public class ProductListEditor extends TableEditorPart {
	public void init() {
		addColumn("#", "id");
		addColumn("Name", "name");
		doubleClickEditWith(ProductEditor.class);
	}

	public List getElements(ProductCategory category) {
		return erp.productsByCategory(category);
	}
}

No HTML pages, no CSS, no JavaScript, just pure Java code and developer bliss. I benefit from hot code replace, and the container reloads in 1.8 seconds if I need to restart. I will probably throw JRebel into the mix as well to further enhance my development cycle.

If you are interested to know how I configured my Eclipse RAP project so that I could develop in IntelliJ IDEA, please let me know. In the meantime, I urge you to take a look at Eclipse RAP 2.0 for your next business application project!

Published at DZone with permission of its author, Edvin Syse.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)