NAME
CGI::Panel::MainPanel - Main panel superclass for CGI::Panel-based applications
SYNOPSIS
See synopsis of CGI::Panel for example of use
DESCRIPTION
CGI::Panel::MainPanel inherits from CGI::Panel and provides extra functionality useful for the main panel of an application. It uses Apache::Session to handle session information. An application built using the CGI::Panel framework should typically have one main panel, which inherits from CGI::Panel::MainPanel, and a hierarchy of other panels which inherit from CGI::Panel.
USAGE
BUGS
SUPPORT
AUTHOR
Robert J. Symes
CPAN ID: RSYMES
rob@robsymes.com
COPYRIGHT
Copyright (c) 2002 Robert J. Symes. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
SEE ALSO
perl(1).
PUBLIC METHODS
Each public function/method is described here. These are how you should interact with this module.
obtain
Obtains the master panel object
This will either restore the current master panel session or create a new one
Use:
my $shop = obtain Shop;
cycle
Performs a complete cycle of the application
Takes all the actions that are required for a complete cycle of the application, including processing events and form data and displaying the updated screen. Also manages persistence for the panel hierarchy.
Use:
$shop->cycle();
get_session_id
Gets a special 'id' value that is specific to this particular session
Use:
my $id = $self->get_session_id;
save
Saves an object to persistent storage indexed by session id
Use:
$self->save;
main_panel
See documentation of main_panel function in CGI::Panel. Since we are the main panel this just returns self.
get_panel_by_id
Look up the panel in our list and return it. Note that this is different to the 'panel' routine in CGI::Panel, which gets a sub-panel of the current panel by name. All the panels in a an application will be registered with the main panel which stores them in a special hash with an automatically generated key. This routine gets any panel in the application based on the key supplied.
Use:
my $panel_id = $main_panel->get_panel_by_id(3);
OTHER METHODS
The following methods are used behind the scenes, usually from the 'cycle' method above. They will generally be sufficient as they are but can be overridden if necessary for greater flexibility.
register_panel
Accept a panel object and 'register' it - ie store a reference to it in a special list. Return the id (hash key) to the caller.
Use:
my $id = $main_panel->register($panel);
screen_main
Display main screen for the master panel. This is called automatically by the 'cycle' routine. Other screen methods can be defined if necessary, however judicious use of panels should avoid the need for this.
handle_event
Handle a button event by passing the event information to the appropriate event routine of the correct panel. Currently this is always the panel that generates the event.
handle_link_event
Handle a link event by passing the event information to the appropriate event routine of the correct panel. Currently this is always the panel that generates the event.
interpret_messages
Read the request information using the CGI module and present this data in a more structured way. In particular this detects events and decodes the information associated with them.