phrame web development platform
download  | documentation  | resources  | credits 


 


3. Building View Components

3.1 Overview

This chapter focuses on the task of building the View components of the application, which will primarily be created using available presentation technologies. In particular, Phrame provides support for building applications, as well as for interacting with input forms.

3.2 Automatic Form Validation

Phrame offers an additional facility to validate the input fields it has received. To utilize this feature, override the following method in your ActionForm class:


<?php
class ValidatingForm extends ActionForm
{
    function 
validate()
    {
        if (!
$this->get('value')) {
            
trigger_error('Enter some value');
        }
    }
}
?>
The validate() method is called by the controller after the form properties have been populated, but before the corresponding action class's perform() method is invoked. The validate() method has the following options:
  • Perform the appropriate validations and find no problems -- proceed to call the perform() method of the appropriate Action class.
  • Perform the appropriate validations and find problems -- trigger errors. The controller will store these and forward control back to the input form (identified by the input property for this ActionMapping).
As mentioned earlier, this feature is entirely optional. The default implementation of the validate() method does nothing, and the controller will assume that any required validation is done by the action class.

One common approach is to perform simple, prima facia validations using the ActionForm validate() method (or client-side javascript), and then handle the "business logic" validation from the Action.

Next: Building Controller Components


 

software development Software Development
Copyright © 2002 Texas Tech University
All rights reserved.
Last modified: November 19 2002 16:47:22

SourceForge Logo