about this book

Welcome to Laszlo in Action. This book presents a comprehensive overview of the fundamentals of the Laszlo LZX language. We’ve taken a slightly different organizational approach than is used by most books on programming languages, where the concepts are neatly laid out in a methodical order. But we believe this isn’t the way most people learn new languages; people need to be immersed in a language to gain fluency in it. So we organized our book to have an intensive set of introductory chapters, and then, at the earliest opportunity, we begin applying our rudimentary Laszlo LZX knowledge toward creating an initial prototype for a Rich Internet Application (RIA) called the Laszlo Market. Each chapter is designed both to cover the fundamentals of Laszlo LZX and to incrementally build our application.

This approach has the benefit of allowing us to first demonstrate concepts in a simple stand-alone manner, and then later apply these concepts within an application context. Because we are continually building and enhancing the work of previous chapters, this provides a scale that would not be achievable through other presentation methods. As a result, we strongly recommend that you read the chapters in consecutive order rather than skipping around.

An additional advantage of this approach is that we give you a full-featured initial working application that you can later tweak to create entirely new applications. This should save you lots of time and aggravation attempting to get many of these features working for the first time. The source code for the Laszlo Market application is available at www.manning.com/klein as well as at www.laszloinaction.com.

Who should read this book

Since Laszlo LZX was designed to be a natural extension of XHTML and JavaScript, it should be accessible to a wide audience of developers. Enterprise-level web developers accustomed to working with object-oriented languages should feel comfortable working with its blend of prototype and class-based objects. LZX is a natural evolutionary step for Ajax developers, and once they become accustomed to working with the delegate-event and data-binding communication systems, they will appreciate the corresponding productivity increase that it delivers. Although many Ajax developers are adamant about only working with open standard technologies, such as Dynamic HTML (DHTML), they are generally open to using proprietary Flash-based solutions as long as they are compartmentalized. This approach allows DHTML applications to be extended with multimedia capabilities. Because the Flash-based code is compartmentalized, it can be easily replaced with an equivalent open source solution in the future. Laszlo supports multiple platforms, and thus provides an optimum solution for creating hybrid applications. We have dedicated an entire chapter, chapter 15, to explaining how these applications can be built.

We also hope that the Laszlo Market application is compelling enough to reach beyond this immediate audience and to the larger community of DHTML web developers. We selected an online store as our sample application for many reasons. It provides a tutorial application that nicely illustrates the major features of Laszlo LZX; also, online shopping is still the killer app of the Web. Online store applications have the largest audience, produce the most revenue, and have the largest web developer community. We believe that the benefits provided by an RIA approach will result in the widespread upgrading of many existing HTML-based stores to use newer technologies such as Laszlo. Because our book delivers a working online store, DHTML developers only need to tweak the Laszlo Market to support their store’s product line. In addition, the architecture of a store can be easily modified to support many other different types of applications. We’re sure that developers will continually surprise us with their innovative uses for the Laszlo Market.

Roadmap

Laszlo in Action consists of 18 chapters that are divided into five parts and supplemented by two online appendixes that provide information on the supporting HTTP server applications. Each chapter’s material is applied to the incremental construction of the Laszlo Market application. In the later chapters, this application is connected to an HTTP server, featured in the appendixes, to supply the application with XML data from a database. By the book’s conclusion, you will have built and optimized a Laszlo online store application containing a branded appearance that can execute across both the Flash and DHTML platforms.

In the book’s first part, “The basics,” which covers chapters 1 through 5, we cover the preliminary Laszlo LZX skills necessary to design and create an initial prototype. In the first chapter, we provide a system-level view of Laszlo. In chapter 2, we examine the declarative and imperative architecture of Laszlo LZX applications. In the third chapter, we make the transition from an abstract to a hands-on approach to Laszlo LZX by taking a look at its language fundamentals. Chapter 4 explores the feature set of the LzView object, which serves as the superclass for all visible objects in Laszlo. By the end of chapter 5, you’ll have created a functional skeleton prototype for the Laszlo Market that clearly illustrates its overall operation.

Part 2, “Prototyping the Laszlo Market,” covering chapters 6 through 9, takes our initial skeleton prototype and begins to embellish it by defining the appearance of its interior screens. In chapter 6, we’ll use the layout object to organize the visual appearance of a screen into a series of patterns. Chapter 7 introduces components that provide a wide variety of interface elements that solve many presentation issues. In chapter 8, we explore the publisher-subscriber communications by demonstrating the relationship between event handlers, methods, events, and attributes. In chapter 9, we look at how services are used to support user and system input functionality. Finally, we apply these services to the Laszlo Market by adding a modal login window and beginning the construction of a drag-and-drop network. This network will be continually enhanced in subsequent chapters.

Part 3, “Laszlo datasets,” covering chapters 10 to 12, deals with Laszlo’s approach to data handling, which is performed through its data-binding system. Chapter 10 starts by introducing resident datasets, which can contain XML data. Chapter 11 expands on the data-binding techniques introduced in the previous chapter by adding the ability to manipulate a data-binding relationship to traverse the data elements in an XML document. Chapter 12 introduces the concept of “scoreboarding” an application. This creates a central repository, in this case a dataset, that provides a set of interface methods to tabulate information. This central repository implements the Laszlo Market’s shopping cart.

Part 4, “Integrating DHTML and Flash,” covering chapters 13 through 15, examines usability issues. In chapter 13, we explain how animation can be used to impart a sense of physicality to an application’s operation. Since this conforms to a user’s experience dealing with physical objects, it makes the operation of an application appear intuitive. In chapter 14, we brand the application to have an appearance that is appropriate for its target audience. In addition, we examine the issues involved with maintaining an identical appearance across different platforms. In chapter 15, we describe the advantages of building hybrid or cross-platform applications and how they can be used to address shortcomings within a platform.

Part 5, “Server and optimization issues,” covering chapters 16 through 18, integrates our Laszlo application with a back-end server, which also introduces optimization issues. In chapter 16, we show how to seamlessly transition from using resident datasets for development to HTTP-supplied datasets for production. Chapter 17 introduces a multifaceted approach to handling these optimization issues using lazy replication to control the allocation of resources for the current display and paging to redistribute the loading of data pages. Finally, in chapter 18, we extend this concept of redistributing costs to handle system optimization to reduce an application’s startup time.

Two online appendices supplement this book and are available for download from the publisher’s website at http://www.manning.com/klein or http://www.manning.com/LaszloinAction. To supply our Laszlo Market with XML data, appendix A contains a Java-based Struts server-side application and appendix B provides a Ruby on Rails server-side application. The purpose is to demonstrate how to provide server-side support for a Laszlo application. These appendices are not intended to be authoritative sources on either Struts or Ruby on Rails development. Please refer to other sources, such as Manning’s Struts in Action or Ruby for Rails, for further information.

Code conventions

All source code in listings or in text is in a fixed-width font to separate it from ordinary text. We make use of several different programming languages—JavaScript, Java, and Ruby—as well as markup languages—XML, HTML, and CSS—in this book, but have maintained a consistent approach to their usage. This fixed-width font is used for method and function names, object properties, XML elements, and attributes in text.

We have used a system of code annotations to provide explanatory assistance and highlight important concepts. Several styles of code annotations are used: numbered bullets link to explanations that directly follow the listing, and arrows are used to indicate in-line explanations.

Code downloads

Source code for all of the working examples in this book is available for download from http://www.manning.com/klein or http://www.manning.com/LaszloinAction.com.

Code listings are divided into two categories: a code listing that builds the Laszlo Market on a chapter basis and a code listing for the individual examples used in each chapter.

Installing the Laszlo Market application requires that several servers, in addition to the OpenLaszlo server, be installed and configured. Since the installation procedures for new versions of these servers are continually being updated, and are already extensively covered by their online documentation, we suggest visiting these URLs for this information:

  • Tomcat: http://tomcat.apache.org
  • OpenLaszlo: http://www.openlaszlo.org/documentation
  • Struts: http://struts.apache.org/
  • Ruby on Rails: http://www.rubyonrails.org/docs
  • Red5: http://osflash.org/red5
  • MySQL: http://dev.mysql.com/doc
  • For those readers who don’t have a suitable hardware environment to support these servers or don’t have an adequate amount of product data, we have created an operational Laszlo Market at the http://www.laszloinaction.com website. This website also features a number of useful links and resources to assist the development of your own store.

    If you decide to install the Laszlo Market in your local environment, please be aware that it’s also necessary to copy the zipcodevalidator.lzx file into the $LPS/lps/components/validators directory and then update its library.file to include it. Further information on this procedure is included in chapter 7. If you encounter any problems with this local configuration, the Laszlo forums are probably the best place to seek further information and assistance.

    Author Online

    Purchase of Laszlo in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/LaszloinAction or www.manning.com/klein. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum.

    Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the book’s forum remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions, lest their interest stray!

    The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.