Table of Contents
We invented this technology to make it possible to create web applications that are delightful to use.
Every computer user knows the power of the Internet, and every web surfer has been awed at one time or another by the vast wealth of the Web. But at the same time everyone knows, even if they only know it subconsciously, that web-based applications running in a browser offer a user experience that is inherently inferior to that of locally-running programs. There is something almost retrograde about interacting with websites; they're anomalous, like rotary telephones in a touch-tone world.
The reason for this is clear. It's not because web designers don't know anything about usability or visual design or software engineering. It's because they have not had the tools they require to build the web experience they conceive.
HTML is a great thing; DHTML is a great thing. Adobe's Flash™ is a great thing. But none of them allow developers to create astounding user experiences, because all of them are based on fundamentally limited models. The variants of HTML are based on the metaphor of a "page," which forces users to process information in arbitrary discrete chunks separated by jarring transitions and "page refreshes." Flash offers the possibility of a much more continuous user experience, but its "movie" metaphor forces developers to leave behind many essential tools and techniques of modern software development.
The result is applications that are delightful to use. Now, delightfulness is in the eye of the beholder, of course, and that's why we suggest that you right now click on our e-commerce application. This program communicates with Amazon.com's data servers and allows you to browse their products, create a wish list, fill a shopping cart, and so forth. So in many ways it's just like any other similar e-commerce site. But notice that there are no screen refreshes, and that you can move items by dragging them with the mouse, that it's hard to get "lost." Now consider that this program was written in a few hours using a simple text editor.
We suggest that you play around with any of the dozens of other sample applications here or on the Laszlo Systems website to get a feel for what a Laszlo application is like. One sometimes hears the phrase "Rich Internet Application" to describe programs like these, and their defining characteristic is that they make people smile. A growing body of empirical studies shows that when people have a more pleasant experience on a website, the longer they stay there, and on commercial sites, the more commerce they transact.
We also hope that this guide will be accessible to web developers who know HTML and CSS but haven't yet worked with object oriented languages, and to developers and designers familiar with Flash or FlashMX. If this describes you, you may have a little homework to do outside the scope of this book, but in general you should have no trouble becoming a fluent LZX developer. A good place for you to start learning would be with the tutorials.
OpenLaszlo applications can be compiled to run in any of several runtimes, and in either of two deployment modes. Some capabilities are available in only a subset of these use cases. OpenLaszlo's "core" APIs run on all target runtimes, and they get the most attention in this Guide. The "Core API" is kind of loose concept, since there's no formal definition, but what it means is that unless you see indication to the contrary, you can assume that the topic under discussion applies to all runtimes. Similarly the default deployment mode is assumed to be SOLO.
Nevertheless, as a developer you have to decide whether to:
optimize for swf (employ swf-only APIs, (and maybe even touch Flash APIs))
optimize for dhtml (employ dhtml-only APIs)
code to lowest common denominator ("core" APIs only)
conditionalize (include both. An example would be including comma separated list of embedded and system fonts; when compiled to swf you get embedded font, to dhtml you get system font).
The focus of the OpenLaszlo Application Developer's Guide is (3), the lowest common denominator; runtime-specific APIs and engineering approaches are presented as adjuncts. Graphic devices ("glyphs") in the margin call attention to non core/non SOLO information.
Depending on which approach you're taking, you'll make different engineering decisions and different approaches to reading the this Guide. For example, if you're determined to deploy SOLO, you can just skip all the chapters marked with the "Server Required" device, etc.
Finally, this Guide does not address any browser-specific considerations. If a thing does not run on all supported browsers for a given runtime, it's by definition not supported and thus should not be cluttering up our lovely Guide. Nonstandard, browser-specific things are described in the release notes or the OpenLaszo Wiki.
This Guide contains hundreds of "live" examples, that is, Laszlo Applications that are embedded in this page. You'll have more fun and get more out of this document if you "play with the code." To do so, simply click on the "Edit" link at the bottom left corner of each example. This will cause a new window to pop up that is a self-contained environment for modifying and executing Laszlo applications. Edit the sample code then click "update" and see the results displayed in the right-hand side of the window. To return the sample code to its initial state, click "Reset."
If you would like to save a copy of the application for later use, click on the "Save As" button.
Designing, Developing and Deploying Laszlo Applications is intended for sequential and random access. In general, each chapter draws on the concepts covered in the chapters that precede it, but not (too much) on those in the chapters that follow it. If you start with Chapter One and read to the end, you won't get lost.
At the same time, each chapter is designed to be encyclopedic: the chapter on Animation covers the entire subject of animation, and so forth.
Short, self-contained examples appear throughout. Links are provided to longer examples.
Code is displayed thus:
var a = f(2). Tags are displayed thus:
<canvas> and their attributes are displayed like this:
height. Function names are displayed like this:
setAttribute(). Longer sections of code and other verbatim information is displayed in a separate paragraph:
An example file that spans several lines
Example programs are shown thus:
<canvas height="20"> <text>Hello World!</text> </canvas>
Some example programs are run within the page. The running application is shown first, followed by the application source code, followed by an Edit button that allows you to try out the effect of making changes to the application source code.
<!-- * X_LZ_COPYRIGHT_BEGIN *************************************************** * Copyright 2007, 2008 Laszlo Systems, Inc. All Rights Reserved. * * Use is subject to license terms. * * X_LZ_COPYRIGHT_END ****************************************************** -->
In addition to this OpenLaszlo Application Developer's Guide, please see also
The LZX Reference Manual. This online, hyperlinked, comprehensive reference for LZX contains entries for each LZX tag and API. Its format will be familiar to users of JavaDoc(tm) and similar systems.
The best way to use the LZX Developer's Guide depends on your experience.
Web/Flash developers with no Object-Oriented experience: We suggest that you start with the tutorials in order to get a general feel for LZX programming. Don't worry about mastering the subjects they cover; your goal is to begin to get comfortable with the language.
If you need to, learn the basics of XML.
Then read the rest of Chapter 4, Overview of OpenLaszlo Application Development.
The best way to learn any programming language is to draw upon the experience and goodwill of its development community (and to write code! as the saying goes, nobody learned to ride a bicycle by reading about it). The LZX developer community has a home at http://www.laszlosystems.com/developers/community/forums/. There you will find an active discussion of all aspects of the language, and a place to ask questions of your own.
Copyright © 2002-2008 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.