Home arrow XML arrow Page 3 - An Introduction to XUL Part 4

Creating the Wizard - XML

Learn about XUL, a subset of XML used to describe user interfaces, that helps you to make rich user interfaces with nothing more complicated than a text editor. In the fourth part of this series you will learn about dialog boxes and wizards.

TABLE OF CONTENTS:
  1. An Introduction to XUL Part 4
  2. Using the RDF/XML Syntax
  3. Creating the Wizard
  4. Adding to the installed-chrome.txt file
By: Dan Wellman
Rating: starstarstarstarstar / 7
June 13, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

XML ARTICLES

- Google Docs and Xpath Data Functions
- 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...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: