Browse DevX
Sign up for e-mail newsletters from DevX


Build Rich Web Applications with OpenLaszlo  : Page 3

OpenLaszlo, an open source framework for creating dynamic and highly interactive Web applications, makes your (and end users') life easier by using the ubiquitous Flash runtime on the client side. Find out how to get started building RIAs with OpenLaszlo.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Object-oriented Features
OpenLaszlo is a scripting framework with full support for essential object-oriented features. The example application uses a custom class for an inbox row representation. I simply declare a new class "row" with custom appearance properties (see the supplied source for the full listing):

<class name="row" height="30" bgcolor="0xE7E7D6" width="100%"> <attribute name="minheight" value="30"/> <attribute name="maxheight" value="150"/> ... </class>

Later, I use it as shown here to render the UI:

<view width="${parent.width-16}"> <row datapath="result"/> <simplelayout axis="y"/> </view>

OpenLaszlo supports inheritance as well. If for example, you wanted the application to be able to designate certain rows as"high importance," you can simply declare it with the keyword "extends":

<class name="highImportanceRow" extends="row"> <view bgcolor="red"/> </class>

Another important aspect of OpenLaszlo's object orientation is that methods and events are supported as standalone elements that can be attached to other visual components. In the following example I am declaring the anonymous method attached to the button. (This method maximizes and minimizes the preview area for each e-mail):

<basebutton resource="tab_top_mid" clickable="true" width="${parent.width}" stretches="both"> <method event="onclick"> if (classroot.height == classroot.minheight) { classroot.open.setAttribute('visible',true); newheight = classroot.maxheight; } else { classroot.open.setAttribute('visible',false); newheight = classroot.minheight; } classroot.animate('height', newheight, 600); </method> </basebutton>

However, you could also define standalone methods that could be invoked from other components. The syntax would look like:

<class name=”sample”> ... <method name="reposition" args="newLocation"> this.move(newLocation); </method> </class>

The method could be executed as:

<class name="demo" onmouseover="this.changeSize(50)"> ... </class>

As you may have noticed, OpenLaszlo's method syntax looks a lot like JavaScript, for which there is a strong rationale: Authors of OpenLaszlo found it easier to implement the framework—and believed that developers would be inherently more productive—by adopting a syntax that is identical or similar to existing standards, including XML, XPath, HTML, and JavaScript. This pragmatic approach should lower the learning curve significantly.

Running the Laszlo Scripts
Installation and testing of the OpenLaszlo scripts is easy. For the deployment of my example application I used OpenLaszlo Server 3.0, which includes the Jakarta Tomcat 5.0 server. OpenLaszlo also includes complete documentation, numerous demos and examples, as well as a "my-apps" directory that is used for learning, testing, and prototyping custom scripts. To run the inbox component I simply placed inbox.lzx, inbox.xml, and supporting images into this directory and invoked the inbox.lzx from the Web browser:


As with any other interpreted scripting language, changes to the OpenLaszlo scripts are immediately available simply by reloading the URL.

Figure 1 shows the look and feel of the OpenLaszlo explorer runtime, as well as the component that I just implemented (Inbox) running in it. This workbench ships with the server and allows for runtime debugging, optimization, and preview of the source code, as well as access to the documentation.

Other installation options for OpenLaszlo include installation of the OpenLaszlo server as a J2EE Web application on the servlet container of your choice. OpenLaszlo can also be installed in a minimalist distribution, which consists just of a Laszlo servlet that is mapped to handle .lzx files.

Rich and Exciting Alternatives
OpenLaszlo is an extraordinarily rich Web framework, and reviewing all of its features could take several articles. What I like best about this framework is that it is simple and straightforward to develop with. It is well documented and feature rich, has active user forums for support, and offers an alternative to commercial Flash-based frameworks. While Macromedia's Flex is equally engaging, exciting, and feature rich, it can't match OpenLaszlo's budget friendliness.

As more and more companies begin to investigate rich client architecture in order to deliver applications that offer a combination of usability, aesthetics, and dynamic features, OpenLaszlo should be seen as a capable and appropriate platform option. I hope that you will find a good use for this great framework in your applications.

Edmon Begoli a software architect with 14 years of professional experience on large commercial and federal software projects. He is a member of the R&D staff at Oak Ridge National Laboratory.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date