NAME
Apache::PageKit::Model - Base Model Class
DESCRIPTION
This class provides a base class for the Modules implementing the backend business logic for your web site.
This module also contains a wrapper to HTML::FormValidator. It validates the form data from the Apache::Request object contained in the Apache::PageKit object.
SYNOPSIS
my $model = Apache::PageKit::Model->new($apr);
my $ok = $model->pkit_validate_input($input_profile);
if($ok){
# get validated, filtered form data
$fdat = map { $_ => $model->input_param($_) } $model->input_param;
} else {
# not valid, check to see error fields
if($model->is_error_field('name'));
$model->pkit_message('You filled your name incorrecty.');
}
METHODS
The following methods are available to the user as Apache::PageKit::Model API.
- input_param
-
Gets requested parameter from the request object
$apr
.my $value = $model->input_param($key);
If called without any parameters, gets all available input parameters:
my @keys = $model->input_param;
Can also be used to set parameter that Model gets as input. For example you can set the userID when the user gets authenticated:
$model->input_param(pkit_user => $userID);
- output_param
-
This is similar to the HTML::Template method. It is used to set <MODEL_*> template variables.
$model->output_param(USERNAME => "John Doe");
Sets the parameter USERNAME to "John Doe". That is
<MODEL_VAR NAME="USERNAME">
will be replaced with "John Doe".It can also be used to set multiple parameters at once:
$model->output_param(firstname => $firstname, lastname => $lastname);
- content_param
-
Similar to
output_param
but sets content variables associated with the <CONTENT_VAR> and <CONTENT_LOOP> tags. - pkit_message
-
Displays a special message to the user. The message can displayed using the
<PKIT_LOOP NAME="MESSAGE"> </PKIT_LOOP>
code.You can add a message from the Model code:
$model->pkit_message("Your listing has been deleted.");
To add an error message (typically highlighted in red), use
$model->pkit_message("You did not fill out the required fields.", is_error => 1);
- pkit_set_page_id
-
Sets the page_id. This is usually used "redirect" to different template.
$model->pkit_set_page_id($page_id);
- pkit_get_page_id
-
Used internally by PageKit (if nowhere else) to retreive the Page ID set by
pkit_set_page_id
.my $page_id = $model->pkit_get_page_id;
SEE ALSO
Apache::PageKit, HTML::FormValidator
AUTHOR
T.J. Mather (tjmather@anidea.com)
COPYRIGHT
Copyright (c) 2000, AnIdea Corporation. All rights Reserved. PageKit is a trademark of AnIdea Corporation.
LICENSE
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Ricoh Source Code Public License for more details.
You can redistribute this module and/or modify it only under the terms of the Ricoh Source Code Public License.
You should have received a copy of the Ricoh Source Code Public License along with this program; if not, obtain one at http://www.pagekit.org/license