i have a couple of html-templates, which i would like to fill in with their appropriat backend functions. e.g. i have a "search" template, where one can enter search terms and submit a query. Then there is the major part of the page, which should be used to display stuff, mostly the search results. i would like to have those two be filled in and be run in seperate functions. I think frames would make that possible, but frames are evil and i would like to avoid those.
It absolutely makes sense to me to have separate functions to fill in different parts of the template.
is it possible and recommended to hop from one mode to the next with $self->newrunmode, filling in one bit at a time?
But why to you want these (backend) functions to be runmodes as well ?Why not have functions like "fill_in_seach_box" and "fill_in_search_results" that take a template as a parameter (and probably more parameters, depending on what they need to do) and set the appropriate parameters in the template.
You would call these functions from your runmode functions.
Pseudocode:
sub runmode_search {
my ($self) = @_;
my $tmpl = get_template_from_somewhere;
fill_in_search_box($tmpl)
fill_in_search_results($tmpl)
return $tmpl->output;
}
sub fill_in_search_box{
my ($self, $tmpl) = @_;
$tmpl->param( SOME_PARAMETER => 1234);
}
sub fill_in_search_results{
my ($self, $tmpl) = @_;
my $data = get_search_data_from_somewhere;
$tmpl->param( SOME_RESULT => $data);
}
Try to keep the runmode methods as slim as possible and move all the
"business logic" (such as gathering search results) into other methods
or even other packages.
That way you have a maintainable CGI::App module that acts as a
controller for a collection of "business logic" functions that you can
also use in different contexts (such as from the command line for quick
checks, or in other applications)
Just my two yen,
Thilo
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.