Thursday, April 17, 2008

Flex and OpenLaszlo in NetBeans 6.1 Beta

As I blogged in NetBeans 6.1: A JavaScript IDE, the NetBeans 6.1 beta IDE has added tremendous support for JavaScript. This latest release of NetBeans also has added built-in support for the Spring Framework. While this newly added support for JavaScript and Spring is very helpful to me in my daily work, I'd also like to see support added for Flex and for OpenLaszlo. In this blog entry, I demonstrate how easy it is to associate Flex's MXML files (by extension .mxml) and OpenLaszlo's LZX files (by extension .lzx files) with XML so that at least XML color coding and XML checks can be used with these files.

Before demonstrating how simple it is to associate LZX and MXML files with XML in NetBeans 6.1 beta, it is worth noting that OpenLaszlo uses its own JavaScript subset for scripting. With NetBeans's excellent new JavaScript support, external JavaScript files (.js) accessed from LZX files can take advantage of some of NetBeans's JavaScript features. Flex ActionScript cannot enjoy the JavaScript additions as much because ActionScript has significant changes and improvements from more traditional JavaScript even though they are both ECMAScript implementations.

The next two images show how a Flex MXML file and an OpenLaszlo LZX file appear in NetBeans without any association of these files types with XML. Click on the images in this entry to see larger versions of the images.

MXML Source Code in NetBeans without Color Syntax Support

LZX Source Code in NetBeans without Color Syntax Support

To enable color coding for LZX and MXML files, one can use the main Tools drop-down menu in NetBeans, select Options, click on the Advanced Options button, expand IDE Configuration, expand System, expand Object Types, and select XML Objects. At this point, one can then click on the small button on the right (and to the right of the label Extensions and MIME Types) with three periods (...) to expand the list of file extensions and MIME types associated with XML objects.

The next two screen snapshots indicate how LZX and MXML files can be associated in NetBeans as XML files. Specifically, by adding mxml and lzx file extensions, NetBeans treats files with these extensions as XML, enabling color syntax and well-formed XML checking.

Associating MXML with XML via mxml Extension

Associating LZX with XML via lzx Extension

With the .lzx extension and the .mxml extension associated in NetBeans as XML, it is time to see how the sample code in both XML grammars now appears. The next two screen snapshots show the MXML and LZX source code shown above, but now with color syntax thanks to NetBeans recognizing these as XML format.

MXML with XML Color Coding Syntax in NetBeans

LZX with XML Color Coding Syntax in NetBeans

Associating LZX and MXML with XML in NetBeans also enables XML checking for well-formed XML documents to be performed on these files.

Enabling color syntax and XML checking for Flex MXML and OpenLaszlo LZX files is easy with NetBeans 6.1 beta. However, it would be nice in a future version of NetBeans to have more comprehensive support for Flex and for OpenLaszlo development.

Speaking (or writing) of NetBeans 6.1 beta, the NetBeans IDE 6.1 Beta Blogging Contest ends on Friday, April 19, 2008 (tomorrow or today depending on where you live). I intend to submit this blog entry for consideration in that contest because it covers features of NetBeans and expresses a desire of mine for additional NetBeans support of Flex and OpenLaszlo.


J. Adam Moore said...

Can you explain if it's even possible to use OpenLaszlo for a Web 2.0 application? Because I haven't seen a single example or tutorial explaining how to handle a Basic Authentication request in the docs. As far as I'm concerned OpenLaszlo is a heaping pile of shit if you can't manage such a simple thing.

Arnaud said...

A Netbeans plugin for Flex support (Flexbean) is in progress at sourceforge :

rpbarbati said...

Just wanted to post a URL for anyone thinking you can't do web 2.0 (whatever that actually means) in OpenLaszlo. Actually, OpenLaszlo looks to me like possibly the best all around web x.0 language. Anyway, here is the URL...

It is a full featured online diagramming tool like visio (only better in many ways...).

After you see gliffy in action, you won't have any doubts that openlaszlo can do you simple login.