Browse DevX
Sign up for e-mail newsletters from DevX


XUL: The Gatekeeper to Higher-level Web UIs : Page 3

Why wait for XAML? XUL is available now, tightly integrated with the Mozilla browsers and provides a full framework for building desktop or Web applications.




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

XUL Isn't Just For Desktop Applications
As XUL is integral in the Mozilla suite, you can use XUL to build browser-based applications, too. You have to make some minor changes to the XUL from this article, wrapping it with a <window> tag to accommodate the browser:

<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="gettemperature-window" title="Get Temperature" orient="horizontal" xmlns="http://www.mozilla.org "> <vbox id="root"> <groupbox> <caption label="Display"/> <text id="display"/> </groupbox> … </window>

You can load this XUL into your browser from the command line:

Firefox c:\xul\gettempbrowser.xul

This will render in the Mozilla Firefox browser as shown in Figure 3.

Figure 3. Browser World: You can load the XUL for the sample application into Mozilla Firefox.
Events within the XUL can be handled using JavaScript, in much the same manner as writing JavaScript to handle standard HTML applications. For example, if you add the following attribute to the <window> tag in the XUL:

onclick="alert(event.target.label); return false;"

Clicking any of the buttons will present a dialog with the label of the button.

The same functionality that is implemented in Java in the desktop application presented in this article could be built in JavaScript, and there are a number of JavaScript frameworks on the Internet for consuming Web services in SOAP. Perhaps the best of these, and certainly the most appropriate given the context of this article is the Mozilla SOAP API, which can be found at http://www.mozilla.org/projects/webservices/.

This article has barely scratched the surface of XUL's possibilities. If you are a Java applications developer, the clear benefits of defining your UI declaratively using XML are obvious. Internationalization, branding, clean upgrades and a host of other capabilities become a lot easier.

Don't forget that XUL also gives you a miniature Web server that you can embed in your apps to give peer-to-peer functionality, a scripting interpreter that is Python-based, and portal and template engines. It all adds up to a pretty compelling framework. With a rich and competent offering like Luxor XUL ready to use, it's easy to wonder why anyone would wait for XAML.

Laurence Moroney is a freelance enterprise architect who specializes in designing and implementing service-oriented applications and environments using .NET, J2EE, or (preferably) both. He has authored books on .NET and Web services security, and more than 30 professional articles. A former Wall Street architect, and security analyst, he also dabbles in journalism, reporting for professional sports. You can find his blog at http://www.philotic.com/blog.
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