Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

malte (1708)

malte
  (email not shown publicly)
http://joose-js.blogspot.com/

Working on Joose JavaScript meta system (Blog) [blogspot.com] and blok [appspot.com], a web based application for collaborative ui prototyping.

Journal of malte (1708)

Wednesday April 02, 2003
05:03 AM

Views

[ #11398 ]

A view is a subclass of ENGINE::MVC::View that reimplements the paint() method. It has a model and a controller. A very simple view might look like this:

package Customer::Project::HelloWorld::View;
use strict;
use base "ENGINE::MVC::View";

sub paint {
    my($self) = @_;

    my $model = $self->model;

    print $model->header,"\n";

    print "<h1>Hello World</h1>";

}

Other views might open file handles and print to those or send eMails. It might also want to ask the controller to instantiate another view. That is totally up to the application.

If you are doing anything serious, you probably want to use templates to discribe your views. In that case you might only need a single view for your whole site that inherits from ENGINE::MVC::View::Template (For Template Toolkit, other template systems can easily be integrated). It might look like this:

package Customer::Project::View;
use strict;
use base "ENGINE::MVC::View::Template";

sub paint {
    my($self) = @_;

    print $self->model->header(),"\n";
    $self->SUPER::paint()
}

sub include_path { "/some/path" }

So much for views, models are next.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.