[ start | index | login ]

XUL

Created by mpecher. Last edited by mpecher, 6 years and 78 days ago. Viewed 1,528 times. #7
[diff] [history] [edit] [rdf]
labels
attachments

Related Links:


>> XUL Programmer's Reference   |   >> XUL Element Reference   |  

Abstract

The XML User Interface Language (XUL) is a markup language for creating user interfaces. It is a part of the Mozilla browser and related applications and is available as part of Gecko.

XUL was designed for creating the user interface of the Mozilla application including the web browser, mail client and page editor. XUL may be used to create these types of applications. However, it may also be used any place you would currently use a web application, for instance, when you need to be able to retrieve resources from the network and require a sophisticated user interface. Like HTML, in XUL you can create an interface using a markup language, use CSS style sheets to define appearance and use JavaScript for behavior. You also have access to programming interfaces for reading and writing to remote content over the network and for calling web services. Unlike HTML however, XUL provides a poweful set of user interface widgets for creating menus, toolbars, tabbed panels, and hierarchical trees to give a few examples. This means you don't have to look for third party code or include a large block of JavaScript in your application just to handle a popup menu. XUL has all of these elements built-in.

XUL is an XML language and you can use numerous existing standards including XSLT, XPath and DOM functions to manipulate a user interface, all supported directly by Gecko. In fact, XUL is powerful enough that the entire user interface in the Mozilla application is implemented in XUL.

In addition to the many built-in user interface widgets available in XUL, you may create additional custom widgets using a related language called the Extensible Bindings Language (XBL). This language may be used to create custom tags and implement custom functionality.

XUL applications may be either opened directly from a remote Web site, or may be downloaded by the user and installed. Mozilla's XPInstall technology allows an application to be placed on a remote site and installed using only a couple of clicks of the mouse.

XUL may also be used to create standalone applications that embed the Gecko engine or may be used as part of the browser. A feature in XUL called an overlay allows a third party to create extensions to the browser itself, for example to add a custom toolbar, change menus, or add other features.

Gecko also supports various Web Services technologies such as XML-RPC, SOAP and WSDL. These technologies have been used recently to create an application to browse for products on amazon.com.

In Mozilla, all document types, whether they are HTML or XUL, or even SVG are all handled by the same underlying code. This means that the same CSS properties may be used to style both HTML and XUL, and many of the features can be shared between both. However, there are some features that are specific to HTML such as forms, and others which are specific to XUL such as overlays. Since XUL and HTML are handled in the same way, you can load both from either your local file system, from a web page, or from an extension or standalone XULRunner application.

Security

Content from remote sources, regardless or whether they are HTML or XUL or another document type, are limited in the type of operations they can perform, for security reasons. For this, reason, Mozilla provides a method of installing content locally and registering the installed files as part of its chrome system. This allows a special URL form to be used called a chrome URL. By accessing a file using a chrome URL, the files receive elevated privileges to access local files, access preferences and bookmarks and perform other privileged operations. Obviously, web pages do not get these privileges, unless they are signed with a digital certificate and the user has granted permission to perform these operations.

Chrome System

This chrome package registration is the way in which Firefox Extensions are able to add features to the browser. The extensions are small packages of XUL files, Javascript, style sheets and images packed together into a single file. This file can be created by using a ZIP utility. When the user downloads it, it will be installed onto the user's machine. It will hook into the browser using a XUL specific feature called an overlay which allows the XUL from the extension and the XUL in the browser to combine together. To the user, it may seem like the extension has modified the browser, but in reality, the code is all separate, and the extension may be uninstalled easily. Registered packages are not required to use overlays, of course. If they don't, you won't be able to access them via the main browser interface, but you can still access them via the chrome URL, if you know what it is.

Mozilla itself is actually just a set of packages containing XUL files, JavaScript and style sheets. These files are accessed via a chrome URL and have enhanced privileges and work just like any other package.

The chrome URL always begins with 'chrome://'. Much like how the 'http://' URL always refers to remote web sites accessed using HTTP, the 'chrome://' URL always refers to installed packages and extensions. When accessing content through a chrome URL, it gains the enhanced privileges described above that other kinds of URLs do not.

If you are going to use XUL on a web site, you can just put the XUL file on the web site as you would an HTML file, and then load its URL in a browser. Ensure that your web server is configured to send XUL files with the content type of 'application/vnd.mozilla.xul+xml'.

Mozilla uses a distinctly different kind of document object for HTML and XUL, although they share most of their functionality. There are three main types of document in Mozilla: HTML, XML and XUL. For example while the form controls on an HTML page are accessible via the 'document.forms' property, this property isn't available for XUL documents since XUL doesn't have forms in the HTML sense. On the other hand, XUL specific features such as overlays and templates are only available in XUL documents. See Chrome for more info.


Syntax Notes

  • XUL elements and attributes should all be entered in lowercase as XML is case-sensitive (unlike HTML).
  • Attribute values in XUL must be placed inside quotes, even if they are numbers.
  • XUL files are usually split into four files, one each for the layout and elements, for style declarations, for entity declarations (used for localization) and for scripts. In addition, you may have extra files for images or for platform specific data.
Please login to post a comment.

Menu:
Java & J2EE
Development
Books

Help:
Help FAQ
Formatting


< May 2012 >
SunMonTueWedThuFriSat
12345
6789101112
13141516171819
20212223242526
2728293031


Logged in Users: (0)
… and a Guest.



Disclaimer: Views and opinions are that of the individual author, and not that of Marand Custom Solutions. This site is an open forum for technical content, and the company accepts no liability for any content or view expressed.