Sunday, December 14, 2008

The Delphi Wizard Framework - Navigation

In a previous entry, I discussed some of the design decisions that allowed me to reach the current solution. One more decision which greatly impacted the design of the framework... I wanted to make sure that it could be data driven.

One of the projects that I was working on at the time was an editor for an XML datafile. For simplicity sake, the file had a structure something like the following:

<name>Steven King</name>
<name>Stanley Kubrick</name>

The goal of the program was to create an editor that could handle each child element. I created two forms, one named tBookWizardForm and another named tMovieWizardForm. Invoking these pages from the first page of the wizard looked something like the following:

procedure EditChild(ChildNode:IXmlNode);
NodeAware : IXmlNodeAware;
if Supports(fWizMgr.CurForm,IXmlNodeAware,NodeAware) then

Note in this example: The call to NavigateToPage automatically inserts the current page into the "to be deleted" list so there is no need to perform any manual cleanup.

The interface IXmlNodeAware actually exists in another unit which is shared by both wizard forms, it looks like the following:

IXmlNodeAware = interface
Procedure SetXmlNode(Node:IXmlNode);

This would automatically perform the dispatch to the proper wizard form, if it ran into a node which it did not understand, it would generate an exception which would be handled and displayed by the wizard manager (displays a dialog that states that the requested form was not registered).

In my next post, I will cover SetAllowDeletion, and why one would need to use it.

1 comment:

Unknown said...


I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Delphi development