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:
In reply to Re^2: Review: CGI::Prototype
by Joost
in thread Review: CGI::Prototype
by dragonchild
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |