Solo is Simple!

With OpenLaszlo release 3.0 you can deploy a wide range of Laszlo applications without having the OpenLaszlo Server installed on the deployment machine. You simply use the OpenLaszlo Server to compile your source to .swf format, thereafter the applications operate without communicating with the server.

These are called Standalone OpenLaszlo Output, or SOLO, applications. On the deployment machine, all you need is a web server, such as Apache or IIS. In fact, you can even send SOLO Laszlo applications as email attachments.

In this Tip of the Week we'll take a quick look at how to get simple SOLO applications up and running. Subsequent tips will go into more detail and handle more complex applications. For an in-depth discussion, be sure to consult the Developer's Guide.

Preliminaries
----------------

This tutorial assumes that you:

* have the OpenLaszlo SDK installed
* have an application whose code you understand that runs on your development machine
* have write-access to an already-running Apache web server (or equivalent). For example, if you're using
a Mac, you can put the SOLO files in the "Sites" folder of your home directory and enable sharing through the control panel.

If you are completely new to Laszlo, we suggest that you start with Laszlo in Ten Minutes.

We'll make the logical distinction between

* *Development machine*, where you have OpenLaszlo installed and do application development
* *Deployment machine*, which you will use to make your application available on the web

Of course, these functions may actually reside on the same physical computer.

The SOLO develop/deploy process
-----------------------------------------

In general, the develop-deploy process looks like this:

  1. Develop and debug the application using the OpenLaszlo Server
  2. Test the deployment on the development machine (using the web server, not the OpenLaszlo Server)
  3. Move the application and all supporting files to the deployment server.

Depending on the complexity of the application, the number of supporting files that you need to move to the deployment machine will increase.
For starters, however, we'll look at the simple case where no supporting files are required.

Compiling your application
----------------------------------
As explained in the Developer's Guide, there are different ways to compile applications for SOLO deployment. For the sake of simplicity, in this tutorial we'll use the proxied="false" attribute on the <canvas> tag.

Compiling your Laszlo application for SOLO deployment gives you a target file that ends with .lzx.swf. That is, if you compile the program mytoy.lzx for SOLO deployment, the compiler will produce the file mytoy.lzx.swf in the same directory.

In addition to the swf file, you may also have resource files, libraries, and an html "wrapper" file that embeds the Laszlo application. We'll get to these
shortly.

Debugging
-------------

The debugger requires a running OpenLaszlo Server. Therefore you should debug your SOLO application with the Laszlo server on your development
machine before deploying it.

The Simplest Case
----------------------

In many cases, the process of deploying a SOLO application is a simple as copying the compiled application (the object file with the .lzx.swf extension) to the
web server's directory on the deployment machine.

Consider the Laszlo application solo.lzx:

[code lang="xml"]



[/code]

To compile it for SOLO deployment, we add the proxied="false" attribute to the canvas:

[code lang="xml"]



[/code]

When we browse to that file, the OpenLaszlo compiler gives us solo.lzx.swf (which will appear in the same directory as the source .lzx program). To make this available on the web as a SOLO application, we simply copy the .swf file to the web server directory. That's it, we're done! Here's a link to that file deployed from the machine that serves this blog.

Next we'll see how to place a Laszlo application within an HTML "wrapper" page, for example, as below:

data="/files/solo.lzx.swf" width="500" height="210">

Adding a Wrapper
---------------------

Now let's put the Laszlo application inside an HTML "wrapper" web page. This is a five-step process:

1. Create the wrapper page by compiling the Laszlo application using the ?lzt=html-object request type
2. Use your browser's "view source" function to display the contents of the wrapper page
3. Copy the contents into an editor
4. Edit the file and save it as a .html file
5. After testing, copy the wrapper (along with the .swf) to the deploy directory.

For example, here's the wrapper that's returned by compiling solo.lzx with
?lzt=html-object:

---------------
[code lang="xml"]
< !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


href="http://www.laszlosystems.com/favicon.ico">
Laszlo Application



data="solo.lzx?lzt=swf"
width="500" height="400">



[/code]
------------------

Editing the wrapper
------------------------

In the file above, note the lines

<object type="application/x-shockwave-flash" data="solo.lzx?lzt=swf" width="500" height="400">

and

<param name="movie" value="solo.lzx?lzt=swf">

Edit the data and value attributes to

data="solo.lzx.swf"
value="solo.lzx.swf"

Then, to demonstrate that this is indeed working as we think it is, let's put text above and below the Laszlo application, and save the file as solo.html:

----------------------
[code lang="xml"]
< !DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


href="http://www.laszlosystems.com/favicon.ico">
Laszlo Application


Here is some text above the Laszlo application.

data="solo.lzx.swf" width="500" height="400">

Here is some text below.



[/code]

--------------------
Now copy this file to the deploy directory, point the browser to solo.html. That's all there is to it.

You can see the result here.

Comments are closed.