The WizardController makes it possible to write event-driven wizards.
Furthermore it eases the creation of dialog elements. You can integrate the
WizardController by means of the useWizardController
procedure
which is part of the wizardLib.tcl
file. For details about how
the WizardController works, please look into the
wizardController.tcl
file.
The following example is a simple wizard for editing the title of a file. For handling events, the WizardController calls procedures whose names it composes of the page name and the user's action (identified by the name of the button clicked). For clarity, the components of these procedure names are colored.
if {[app get appName] ne "CM"} { return } namespace eval ::enterTitle { useWizardController proc initRender {paramList args} { variable objId set objId $args return } proc handleInitPage {buttonName} { variable objId if {![obj withId $objId get isEdited]} { return [renderErrorPage "The file does not have a draft version." "Error"] } if {[whoami] ne [obj withId $objId editedContent get editor]} { return [renderErrorPage "You are not the editor of the file." "Error"] } return [renderEnterTitlePage] } proc handleCancelAction {pageName} { return "" } proc renderEnterTitlePage {} { set content [::layout::textField contentTitle Titel "New title"] return [renderPage -title "Set title" -buttons [list ok cancel]\ "enterTitle" $content] } proc handleEnterTitleOkPageAction {} { variable objId obj withId $objId editedContent set title [getParam contentTitle] addNpsRefresh $objId return [renderSuccessPage] } proc renderSuccessPage {} { set content "<p>The title has been set.</p>" return [renderPage -title "Thank you very much!" -buttons [list ok] "success" $content] } proc handleSuccessOkPageAction {} { return "" } # Output any page of this wizard proc renderPage {args} { variable objId return [eval [list npsPage -affectedNodes [list $objId]] $args] } }