DESCRIPTION

XUL-Node is a rich user interface framework for server-based Perl applications. It includes a server, a UI framework, and a Javascript XUL client for the Firefox web browser. Perl applications run inside a POE server, and are displayed in a remote web browser.

The goal is to provide Perl developers with the well known XUL/Javascript development model, but with two small differences:

XUL-Node works by splitting each widget into two: a server half, and a client half. The server half sends DOM manipulation commands, and the client half sends DOM events. A small Javascript client library takes care of the communications.

The result is an application with a rich user interface, running in Firefox with no special security permissions, built in 100% pure Perl.

DEVELOPER GUIDE

Programming in XUL-Node feels very much like working in a desktop UI framework such as PerlTk or WxPerl. You create widgets, arrange them in a composition tree, configure their attributes, and listen to their events.

Web development related concerns are pushed from user code into the framework- no need to worry about HTTP, parameter processing, saving state, and all those other things that make it so hard to develop a high-quality web application.

Welcome to XUL

XUL is an XML-based User interface Language. XUL-Node exposes XUL to the Perl developer. You need to know the XUL bindings to use XUL-Node. Fortunately, these can be learned in minutes. For a XUL reference, see XUL Planet (http://www.xulplanet.com/).

The application name is the last part of its package name. So the package XUL::Node::Application::PeriodicTable can be run using the application name PeriodicTable. All applications must exist under @INC, under the namespace XUL::Node::Application.

So for example, to run the splitter example on a locally installed server, you would browse to:

http://localhost:8077/start.xul?SplitterExample#1

The installation also creates an index page, providing links to all examples. By default it will be available at:

http://localhost:8077

Widgets

To create a UI, you will want your start() method to create a window with some widgets in it. Widgets are created by calling a function named after their tag:

Listener receive a single argument: the event object. You can query this object for information about the event: name, source, and depending on the event type: checked, value, color, and selectedIndex.

XUL-Node API vs. the Javascript XUL API

There is no difference between attributes, properties, and methods. They are all attributes.

There exist constants for common attribute key/value pairs. See XUL::Node::Constants.

Works around Firefox XUL bugs.

INTERNALS

XUL-Node acts as a very thin layer between your Perl application, and the Firefox web browser. All it does is expose the XUL API in Perl, and provide the server so you can actually use it. Thus it is very small.

It does this using the Half Object pattern (http://c2.com/cgi/wiki?HalfObjectPlusProtocol). XUL elements have a client half (the DOM element in the document), but also a server half, represented by a XUL::Node object. User code calls methods on the server half, and listens for events. The server half forwards them to the client, which runs them on the displayed DOM document.

The Wire Protocol

Communications is done through HTTP POST, with an XML message body in the request describing the event, and a response composed of a list of DOM manipulation commands.

Here is a sample request, showing a boot request for the HelloWorld application:

Each command in a response is built of the widget ID, the attribute/property/method name, and an argument list.

The Server

The server uses POE::Component::HTTPServer. It configures a handler that forwards requests to the session manager. The session manager creates or retrieves the session object, and gives it the request. The session runs user code, and collects any changes done by user code to the DOM tree. These are sent to the client.

Aspects are used by XUL::Node::ChangeManager to listen to DOM state changes, and record them for passing on to the client.

The XUL::Node::EventManager keeps a weak list of all widgets, so they can be forwarded events, as they arrive from the client.

A time-to-live timer is run using POE, so that sessions will expire after 10 minutes of inactivity.

The Client

The client is a small Javascript library which handles:

Client/server communications, using Firefox XMLHTTPRequest.

Running commands as they are received from the server.

Unifying attributes/properties/methods, so they all seem like attributes to the XUL-Node developer.