XML
  Home arrow XML arrow Page 3 - An Introduction to XUL Part 4
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
XML

An Introduction to XUL Part 4
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2005-06-13


    Table of Contents:
  • An Introduction to XUL Part 4
  • Using the RDF/XML Syntax
  • Creating the Wizard
  • Adding to the installed-chrome.txt file

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    An Introduction to XUL Part 4 - Creating the Wizard
    ( Page 3 of 4 )

    Now that you have your RDF file in place, you need to create the wizard and save it in the same directory. The syntax for this is really easy; just exchange the <window> element for a <wizard> element, and then define each of the pages of the wizard as a <wizardpage>.  You can use almost all of the elements we have discussed so far in a wizard, including all of the form controls.  Create this basic wizard:

    <?xml version="1.0"?>

    <wizard id="danswizard" title="The 'Create a
     Wizard' Wizard" xmlns="http://www.mozilla.org/keymaster/
     gatekeeper/there.is.only.xul">

     <wizardpage description="Create the XUL file">
       <description>This page will help you create a 
         XUL wizard</description>
       <spacer height="10"/>
       <description>First set the XML declaration in the 
         normal way:</description>
       <spacer height="10"/>
       <description><![CDATA[<]]>?xml version="1.0"?>
         </description>
       <spacer height="10"/>
       <description>Then add the wizard tag with title and
         namespace attributes:</description>
     
     <spacer height="10"/>
       <description><![CDATA[<]]>wizard id="danswizard"
         title="The 'Create a Wizard' Wizard"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/
         there.is.only.xul"></description>
      
    <spacer height="10"/>
       <description>Next, add the first page of the wizard with
         the wizardpage tag:</description>
       <spacer height="10"/>
       <description><![CDATA[<]]>wizardpage description="Create
         the XUL file"></description>
      
    <spacer height="10"/>
      
    <description>Add your page content using the normal XUL
         element tags:</description>
      
    <spacer height="10"/>

       <description><![CDATA[<]]>description>Content...
         <![CDATA[<]]>/description></description>
       <spacer height="10"/>
       <description>When the page is ready, close off the
         wizard page tag and repeat the process for as many
         pages as necessary</description>
      
    <spacer height="10"/>
      
    <description><![CDATA[<]]>/wizardpage></description>
       <spacer height="10"/>
       <description><![CDATA[<]]>wizardpage>Page 2
         content...etc
    <![CDATA[<]]>/wizardpage></description>
       <spacer height="10"/>
       <description>When the wizard is finished, close off the
         wizard tag and save your file in a folder, preferably
         one called chrome</description>
       <spacer height="10"/>
       <description><![CDATA[<]]>/wizard></description>
     </wizardpage>

     <wizardpage description="Create the RDF file">
       <description>This page will help you create the RDF
         file</description>
      
    <spacer height="10"/>
       <description>Once again, begin with the XML declaration:
         </description>
       <spacer height="10"/>
       <description><![CDATA[<]]>?xml
         version="1.0"?></description>
      
    <spacer height="10"/>
       <description>Now add the RDF container and include the
         necessary namespaces:</description>
       <spacer height="10"/>
       <description><![CDATA[<]]>RDF:RDF
         xmlns:RDF="http://www.w3.org/1999/
         02/22-rdf-syntax-ns#"
         xmlns:chrome="http://www.mozilla.org/
         rdf/chrome#"></description>
       <spacer height="10"/>
       <description>Add your bag baby, and tell Mozilla the
         name of your wizard:</description>
       <spacer height="10"/>
       <description><![CDATA[<]]>RDF:Bag
         about="urn:mozilla:package:root"></description>
       <description><![CDATA[<]]>RDF:li
         RDF:resource="urn:mozilla:package:yourfilenamehere"/>
         </description>
      
    <description><![CDATA[<]]>/RDF:Bag></description>
       <spacer height="10"/>
       <description>Then create an RDF description code block
         giving the program the various bits of information. 
         Remember to change the filename and details to your
         own:</description>
       <spacer height="10"/>
       <description><![CDATA[<]]>RDF:Description
         about="urn:mozilla:package:yourfilenamehere"
         </description>
       <description>chrome:displayName="yournamehere’s Wizard"
         </description>
      
    <description>chrome:author="yournamehere"</description>
       <description>chrome:name="yourfilenamehere"
         </description>
       <description>chrome:extension="false"/></description>
       <spacer height="10"/>
       <description>Finaly, close off the RDF container:
        
    </description>
      
    <spacer height="10"/>
       <description><![CDATA[<]]>/RDF:RDF></description>
       <spacer height="10"/>
       <description>Save this file as contents.rdf in the same
         folder as your wizard</description>
     </wizardpage>

     <wizardpage description="Register the wizard with
       Mozilla">
     
    <description>This page will help you register your
        file</description>
       <spacer height="10"/>
       <description>Look in the main Mozilla program directory,
         there will be two files of use to you here, chrome.rdf
         and installed-chrome.txt</description>
       <spacer height="10"/>
       <description>First of all, delete the chrome.rdf file.
         This is a file that is automatically generated by
         Mozilla each time the program is launched.
        
    </description>
       <spacer height="10"/>
       <description>Now open the installed-chrome text file.
         You might want to use something a little better that
         Windows Notepad here because unfortunately it can't
         seem to read this file property.  I use nPad2, a
         perfectly adequate free text editor</description>
       <spacer height="10"/>
       <description>At the very end of the file, you'll need to
         add some code that tells Mozilla where your wizard is
         located  I have put my file in a folder called chrome,
         that sits in a folder called XUL on my C drive, so the
         code I would add is:</description>
       <spacer height="10"/>
       <description>content,install,url,file:///C|/XUL/chrome/
         </description>
       <spacer height="10"/>
       <description>Make sure you press return after adding the
         above line of code to the file and then save
         it.</description>
     
    </wizardpage> 

     <wizardpage description="Veiwing the wizard">
       <description>This page will help you run the
         wizard</description>
       <spacer height="10"/>
       <description>Open Mozilla and in the address bar type
         the following command:</description>
       <spacer height="10"/>
       <description>chrome://yourfilenamehere/content/
    </description>
       <spacer height="10"/>
       <description>Your wizard should now be displayed and
         should have a title at the top and working buttons at
         the bottom.  Additionally, the final page of the
         wizard (this one) will have an appropriate ending
         title</description>
       <spacer height="10"/>
       <description>All you have done is provide the basic
         containers and the content itself, Mozilla and XUL do
         the rest!</description>
       <spacer height="10"/>
       <description>Go back to the Mozilla directory and open
         the chrome.rdf file that you deleted earlier with a
         text editor, do a find for your wizards name and there
         should be several references to it</description>
       <spacer height="10"/>
     </wizardpage> 

    </wizard>

    You’ll notice that it’s an awful lot of code, 97 lines to be exact, but it is easy code and I’m sure you’ll agree that it’s a lot less than it would be if you have to script the page change and button behaviors manually.   You’ll notice that the lines of text in the wizard that represent code have had the first angle bracket enclosed within a <![CDATA[]]> element. This is to ensure that Mozilla treats part of the text as character data and doesn’t try to parse it. Try getting the wizard to display the text <?xml version=”1.0”?> without using the CDATA method. Normally this information would go into a DTD file to keep the wizard file cleaner; in fact, all of the string information could go into a DTD file and all of the wizard text could be read in using references to it instead, but for this example, we needn’t worry too much about separating content from presentation.



     
     
    >>> More XML Articles          >>> More By Dan Wellman
     

       

    XML ARTICLES

    - Flex Array Collection Sort and Filtering
    - The Flex Tree Control
    - Flex List Controls
    - Working with Flex and Datagrids
    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek