Apache2::ASP::FormHandler - Base class for form handlers
package mysite::contact::form; use strict; use warnings 'all'; use base 'Apache2::ASP::FormHandler'; use vars __PACKAGE__->VARS; sub run { my ($s, $context) = @_; if( my $errors = $s->validate( $context ) ) { $Session->{validation_errors} = $errors; $Session->{__lastArgs} = $Form; return $Response->Redirect( $ENV{HTTP_REFERER} ); } # Do stuff: # Finally: return $Response->Redirect( "/some/other/place.asp" ); } sub validate { my ($s, $context) = @_; my $errors = { }; # Did they fill out the form? foreach my $field (qw/ name email message /) { $errors->{$field} = "Required" unless $Form->{$field}; } return $errors if keys(%$errors); } 1;# return true:
Apache2::ASP::FormHandler is an empty subclass of Apache2::ASP::HTTPHandler and adds nothing of its own.
Apache2::ASP::FormHandler
It provides a starting point for all other form handlers.
All form handlers should inherit from Apache2::ASP::FormHandler or one of its subclasses.
Although the author is a Big Fan of MVC, he does not like to be constantly beat over the head with the MVC two-by-four.
The style of MVC available here is very much like that found in ASP.Net's MVC, though somehow it predates the ASP.Net version by more than 2 years.
It's possible that some bugs have found their way into this release.
Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP to submit bug reports.
Please visit the Apache2::ASP homepage at http://www.devstack.com/ to see examples of Apache2::ASP in action.
John Drago mailto:jdrago_999@yahoo.com
Copyright 2007 John Drago, All rights reserved.
This software is free software. It may be used and distributed under the same terms as Perl itself.
To install Apache2::ASP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache2::ASP
CPAN shell
perl -MCPAN -e shell install Apache2::ASP
For more information on module installation, please visit the detailed CPAN module installation guide.