spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / xul / 1 To page 1current pageTo page 3
[previous][next]

An Introduction to XUL

Subject Matter Expert - Managed Services (PA)
Next Step Systems
US-PA-Wayne

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Here, we use the fancy XUL tag to provide the user with a better navigation experience. We'll see that code shortly. There's no Dynamic HTML or fancy styling here, just tags. The grey button at the top is an ordinary XHTML form submission button. We can take the content from the tabbox and submit it via an ordinary HTML form. As an alternative (not shown), we could submit the content directly from anywhere in XUL - for example, we could add a submit tab to the tabbox, one that contained a submission button.

But to give this page the finishing touch, we'd have to use a touch of JavaScript to copy data from XUL to the HTML form, or to send the XUL data direct to the Web server.

Figure 3 show the contents of the other tabs in the tab box.

Figure 3: Contents of other tabs in the tab box.

Each tab is revealed with a single user click. All the content of the tabs is loaded at once, so there are no server CGI programs to write. Note how some XUL form elements are hidden "underneath" others. You can't do that in plain HTML, from either a design or a navigation point of view. Although most of the form elements look like HTML form elements, XUL has a wide variety of controls and widgets to choose from.

Finally, we come to the XUL content source itself. Listing 2 shows the code for the XUL document that contains a sole tabbox.

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<window
title="Checkout Station"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>
   <script src="checkout.js"/>
   <tabbox>
      <tabs>
          <tab id="t1" label="Sign In"/>
          <tab id="t2" label="Shipping"/>
          <tab id="t3" label="Payment"/>
          <tab id="t4" label="Gift Wrap"/>
      </tabs>
      <tabpanels>

          <tabpanel>
            <vbox>
               <description>Please enter your username and password.</description>
               <textbox id="username"/>
               <textbox type="password" id="password"/>
            </vbox>
         </tabpanel>

         <tabpanel>
           <grid>
              <columns><column/><column/></columns>
               <rows>
                    <row>
                      <description>Please enter the delivery address.</description>
                    </row>
                    <row>
                      <description pack="end">Full Name</description>
                      <textbox id="fullname"/>
                   </row>
                   <row>
                      <description pack="end">Full Address</description>
                      <textbox id="address"/>
                   </row>
                   <row>
                      <description pack="end">Contact Details</description>
                      <textbox id="contact"/>
                 </row>
                </rows>
            </grid>
         </tabpanel>

         <tabpanel>
            <vbox>
                    <description>Please enter your credit card number</description>
                    <textbox id="creditcard"/>
            </vbox>
         </tabpanel>
         <tabpanel>
           <vbox>
                  <description>Enter your wrapping preference for the delivery</description>
                  <checkbox id="wrapping" label="Wrap my delivery" checked="true"/>
                  <hbox align="center">
                      <listbox id="wraptype" seltype="single" rows="3">
                           <listitem label="Brown Paper"/>
                           <listitem label="Cellophane"/>
                           <listitem label="Birthday Paper"/>
                           <listitem label="Christmas Paper"/>
                      </listbox>
                      <description>Choose your preferred wrapping</description>
                 </hbox>
            </vbox>
          </tabpanel>

      </tabpanels>
   </tabbox>
</window>

Listing 2. XUL document holding a four-tab tabbox

All the tags above are XUL tags. While they might seem unfamiliar, it's easy to guess what most of them are. <description> is a piece of text, <textbox> is, well, a textbox, and so on. There are a couple of things new at the top of this file, though. The string:

http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul

is Mozilla's geeky way of identifying an XUL document. XUL is sometimes pronounced "zool", so this string is a pun on and a side-reference to the character of that name from the movie Ghostbusters.

home / programming / xul / 1 To page 1current pageTo page 3
[previous][next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: March 27, 2003
Revised: May 25, 2004

URL: http://webreference.com/programming/xul/1