in reply to Re: Review: CGI::Prototype
in thread Review: CGI::Prototype
Our app will have to figure out which button was hit and handle the data and output as needed. In C::A, there is really only one place you can put this logic: cgiapp_prerun(). If you have many runmodes that need this sort of functionalilty, your cgiapp_prerun() can start getting rather large.
Why would you not have the runmode method handle this?
I tend to use the runmode more as a vague indidactor of the expected action anyway - it determines the kind of checks that need to be done on the input, then decides which action to perform, and then refers to an output routine. Example:
sub make_report { my $self = shift; if (my $missing = $self->missing_fields()) { # back to submitted form, with missing fields highlighted return $self->make_form($missing); } # make confirmation screen. $self->template( 'confirm.tmpl' => $self->form_values, ); }
This decides the output based on wether or not all data has been filled in correctly, but it isn't really very different if you check for a button instead.
update: after reading this thread again, it seems most some people find it hard to wrap their head around the following:
runmode != page != template
A runmode is just a hint from the calling form about what the input data is about, and what the application should to with it. It does not describe what template should be shown.
In Section
Meditations