package CGI::Prototype::Hidden; our $_mirror = __PACKAGE__->reflect; use base CGI::Prototype; use strict; =head1 NAME CGI::Prototype::Hidden - Create a CGI application by subclassing - hidden field =head1 SYNOPSIS # in My/App.pm --- package My::App; use base qw(CGI::Prototype::Hidden); # in /some/cgi-bin/program use lib qw(/location); use My::App; My::App->activate; =head1 DESCRIPTION L extends L by providing a hidden field mechanism for state, and a dispatching algorithm based on that hidden field. In particular, =over 4 =item 1 Dispatching to a particular paged based on the "state" of the application is performed according to param field. =item 2 The name of the state is appended to an application-wide package prefix to determine an appropriate class to handle the request. =item 3 The package for the class is autoloaded if needed. =item 4 The template for the class replaces C<.pm> with C<.tt> (configurable), found in the same C<@INC> path, and is therefore likely to be in the same directory. =item 5 A "wrapper" template is automatically provided. =back Thus, a simple 10-page CGI application will require 23 files: 10 classes, 10 corresponding templates, a wrapper template, a master application class, and a CGI script that loads the master application class and activates it. The default class is C, but this can be overridden. The default state is C, but this too can be overridden. The default hidden param name for the state is C<_state>, and if you think this can be overridden, you are correct. See the trend here? A sample app is the best way to show all of this, of course. We don't have one yet... that's on the TODO list. However, the functions have all been exercised in the tests for this module, including an artificial application, so check that out for at least an example of the interfaces. =head2 CONFIGURATION SLOTS These methods or values are the ones you'll most likely change in your application, although you can leave them all alone and it'll still be a valid framework to create your entire application. =over 4 =item config_state_param The name of the hidden field which will contain the state, defaulting to C<_state>. In any form you create, or any constructed URL, you must be sure to include this param as part of the form so that the right response can be matched up for the submitted data. For example:
[% self.CGI.hidden(self.config_state_param) %] First name:[% self.CGI.textfield("first_name") %]
Last name: [% self.CGI.textfield("last_name") %]
=cut sub config_state_param { "_state" } =item config_class_prefix The class prefix placed ahead of the state name, default C. For example, the controller class for the C state will be . You should change this if you are using L to something that won't conflict with other usages of the same server space. For CGI scripts, the default is an easy classname to remember. Note that the template also use this name as their prefix, so that your controller and template files end up in the same directory. =cut sub config_class_prefix { "My::App" } =item config_default_page The initial page if the state is missing, default C. =cut sub config_default_page { "welcome" } =item config_wrapper The name of the WRAPPER template, default C. If you change C, you'll want to change this as well so that C ends up in the right directory. (I debated doing that for you so you could just say C<"WRAPPER.TT">, but that'd make more complicated versions of this callback be even more and more complicated.) The wrapper template is called with C