The Source for Java Technology Collaboration
User: Password:



   

Laszlo: An Open Source Framework for Rich Internet Applications Laszlo: An Open Source Framework for Rich Internet Applications

by William Grosso
03/22/2005

Contents
Rich Internet Applications
An Overview of Laszlo
   Why Flash?
   Laszlo on the Web
A Very Simple Application, Built Using Laszlo
   The First Login Screen
   Adding Behavior to the Login Screen
   Adding a Personal Information Screen
   Turning the Crank with Live Data
Evaluating Laszlo
   Should You Use a Rich Internet Application Framework?
   Should You Use Laszlo?

Being a Java programmer sometimes feels like being in the movie Groundhog Day. In the movie, Bill Murray is stuck in a loop: every morning when he wakes up it's the same day (Groundhog Day). He relives the day over and over again, seemingly without reason. But the days are subtly different: each time he relives the same event, he learns a little bit more about how to be a better person. And, at the end of the movie, Bill Murray finally gets to move on and live the rest of his life.

Similarly, every year, without fail, Java developers get to see new programming frameworks and container models. And, in much the same way that Bill Murray gradually addresses his problems and becomes a better person, the frameworks are getting better, and helping us to become better programmers (or, at least, deliver higher quality applications in shorter time frames). But, in the same way that Bill Murray keeps seeing the same things happening over and over again, we keep getting presented with frameworks that keep solving the same problems over and over again. While JavaServer Faces looks much better than Struts, it doesn't enable anything new: it's just a better way of creating the same old HTML-over-HTTP web applications.

But just as Bill Murray eventually got to experience all of the days that come after Groundhog Day, we may be on the verge of changing how we build web applications. There's a growing restlessness in the air, and a growing movement towards rich internet applications. In this article, I'm going to give you a quick overview of Laszlo, an open source rich internet application development platform. First I'll give a high level overview of what Laszlo is, and how it works. Then I'll give you a quick tour through some of the basic features of Laszlo, and talk about what's involved in building an application in Laszlo. And, after that, I'll talk about where it works best, and when it makes sense to use Laszlo.

Rich Internet Applications

The phrase "rich internet application framework" is a lot like the word pornography: easy to identify (the old "I know it when I see it" standard) but hard to define. Generally speaking, when people say "rich internet application," they usually mean something that meets the following criteria:

  • The application is launched from (or even contained within) a web page.
  • The application provides immediate feedback to users when they interact with the application (instead of a two-to-four-second delay while a response is fetched from a server somewhere). And it eliminates the "white screen while we refresh the page" aspects of existing web applications.
  • The application uses modern user interface controls, such as tree controls or tabbed panels, instead of living with what was current at the time HTML 4.0 was drafted.
  • The application allows users to perform common "fat client" operations like drag and drop, or using keyboard navigation in a way that feels natural to them.
  • The application has the same the ease of deployment and almost universal reach of existing web applications.
  • The application does all of the above without requiring large amounts of platform- or browser-dependent JavaScript.

You'll note that the above list of criteria doesn't include a lot of technological guidance. That's because the field of rich internet applications is wide open, and there are a lot of frameworks and environments out there. Some of the leading contenders include:

However, while they use vastly different technologies, platforms for rich internet architectures have some interesting commonalities. Among them are:

  • They all use a client-side container model (see the sidebar The Client Side Container Environment). They achieve at least part of their performance boost by minimizing the amount of server communication--instead of loading an entire HTML page each time the user clicks, these frameworks either handle the click locally (without involving the server) or request data from the server, which they then process. This means that there really is a client-side application with state and a user interaction model--the client is a lot more than a web page generated on a server.
  • Most of them leverage web browsers for deployment. Web browsers are everywhere, and it makes sense to take advantage of this. Some frameworks are actually built in JavaScript (and thus stay completely inside of the browser), while others use browser extensions such as Flash to define their client applications.
  • Most of them use some form of XML-based language for defining user interfaces. HTML is, by far, the world's most popular way to define user interfaces. Almost all of the rich internet application platforms either use HTML, or use an XML language that resembles HTML, in order to take advantage of this familiarity.

An Overview of Laszlo

Laszlo Systems was founded in 2000 to "advance the web experience." In the early years of the company, "advancing the web experience" meant building and selling a Flash-based rich internet application framework to large enterprises. But in mid-2004, Laszlo went open source, and Laszlo is now a mature and powerful framework for rich internet applications that also happens to be free. And that's pretty compelling.

The Laszlo platform consists of two pieces: a declarative XML-based language called LZX that is used to write client applications, and an application server (and LZX compiler) called the presentation server.

The presentation server plays two different roles in a production Laszlo system. The first is that it compiles LZX applications into Flash movies when the applications are requested by a browser. In Laszlo, client-side deployment is the standard web model: to launch an application, the user loads a web page. The web page contains an object tag, which launches the Flash movie. The presentation server also maintains a cache of the compiled LZX programs (it only recompiles LZX programs when they have changed).

The presentation server also brokers data requests from client applications (basically, it forwards the requests to your server-side code). This was originally part of the architecture because of security restrictions inherent in Flash movies when Laszlo was originally architected, and will probably be removed in a future version of Laszlo.

LZX, the language that Laszlo programs are written in, is a hybrid language that looks a lot like XHTML. LZX has an XML tag syntax to define pages and user interface constructs, and uses JavaScript for procedural logic and state variables. This has two significant benefits:

  • It's easy to read. Laszlo programs often look like very clean HTML programs.
  • JavaScript is a very well-known programming language, with a loosely typed interpretation model. It works very well for defining client applications.

In a nutshell, developers write applications in a combination of LZX (for the client application) and some server-side code. The presentation server takes the LZX and compiles it into Flash movies, which are sent to the web browser.

Why Flash?

The choice of Flash as a delivery vehicle for rich internet applications is an interesting one. Many people think of Flash as either eye candy for the Web or as the delivery mechanism for silly, yet addictive, games. What's more, a sizable portion of the Web's most influential people think of it as actively bad. But Flash, especially Flash 5 (which Laszlo uses), has some very strong advantages.

  • Flash is designed for visually rich applications.
  • Flash is everywhere. In September of 2004, 97.3 percent of all web browsers already had a player installed that could play Flash 5 movies. This is even more impressive when you compare it to other technologies: Java is present in 87.9 percent of the browsers out there, and PDF is in 80 percent. Macromedia has done an amazing job of making Flash ubiquitous.
  • Flash is the same everywhere. The Flash player for Firefox behaves exactly the same as the Flash player for Internet Explorer. This stands in stark contrast to Java (different versions of the JVM behave very differently) and DHTML (which is implemented differently in every major browser).
Laszlo on the Web

Actually finding Laszlo on the Web can be somewhat confusing; there are a lot of sites out there, each of which contains a small part of the big picture. Here are some of the websites you should visit if you want to learn more:

Major Sites:

  • Laszlo main site: This is the website for Laszlo-the-company (as opposed to Laszlo-the-product). Up until October, they sold Laszlo as an enterprise platform for rich internet applications; now they're turning into a professional services and development company based on Laszlo applications and expertise.
  • Open Laszlo: As the site says, If you're interested in actively shaping the future of the Laszlo platform, and taking part in one of the coolest open source projects on the internet, this is where you belong.. It's still a bit bare-bones (Laszlo's only been open-source for a couple of months at this point) but it's worth watching.
  • IBM's Eclipse Plugin: This is a set of Eclipse plugins that help you to write Laszlo applications.

Relevant Weblogs:

  • David Temkin's weblog: David Temkin is the CTO, and one of the founders, of Laszlo. He's not a very prolific blogger, but a lot of what he has posted is interesting.
  • Oliver Steele's Weblog. Oliver Steele is the chief software architect at Laszlo, and a prolific blogger (though most of his blog entries aren't about Laszlo).
  • Sarah Allen's Weblog: Sarah Allen works at Laszlo. In particular, she's one of the people working on Laszlo mail.

Interesting Additional Components and Code:

  • Blogbox. These are small applications that fit within a website or weblog. There are quite a few of these, and the source code is provided. They also seem to have their own weblogs. For example, Soundblox also has a Blogger weblog. I really like the idea of weblogs (and RSS feeds) for widgets and documentation.
  • My Laszlo. This is, apparently, a place where people can post small applications and demo code. Right now, it only has four applications.

Pages: 1, 2, 3

Next Page » 

View all java.net Articles.

 Feed java.net RSS Feeds