NAME

ClearPress::view - MVC view superclass

VERSION

$LastChangedRevision: 161 $

SYNOPSIS

my $oView = ClearPress::view::<subclass>->new({util => $oUtil});
$oView->model($oModel);

print $oView->decor()?
  $oDecorator->header()
  :
  q(Content-type: ).$oView->content_type()."\n\n";

print $oView->render();

print $oView->decor()?$oDecorator->footer():q();

DESCRIPTION

View superclass for the ClearPress framework

SUBROUTINES/METHODS

new - constructor

my $oView = ClearPress::view::<subclass>->new({util => $oUtil, ...});

init - additional post-constructor hook

determine_aspect - URI processing

sets the aspect based on the HTTP Accept: header

- useful for API access setting Accept: text/xml

template_name - the name of the template to load, based on view class and method_name()

my $sTemplateName = $oView->template_name();

method_name - the name of the method to invoke on the model, based on action and aspect

my $sMethodName = $oView->method_name();

add_warning

$oView->add_warning($sWarningMessage);

authorised - Verify authorisation for this view

This should usually take into account $self->action() which suggests
read or write access.

my $bIsAuthorised = $oView->authorised();

render - generates and returns content for this view

my $sViewOutput = $oView->render();

list - stub for entity list actions

create - A default model creation/save method

$oView->create();

Populates $oSelf->model() with its expected parameters from the CGI
block, then calls $oModel->create();

add - stub for single-entity-creation actions

edit - stub for single-entity editing

read - stub for single-entity-view actions

update - stub for entity update actions

delete - stub for entity delete actions

tt - a configured Template (TT2) object

my $tt = $oView->tt();

util - get/set accessor for utility object

$oView->util($oUtil);
my $oUtil = $oView->util();

model - get/set accessor for data model object

$oView->model($oModel);
my $oModel = $oView->model();

action - get/set accessor for the action being performed on this view

$oView->action($sAction);
my $sAction = $oView->action();

aspect - get/set accessor for the aspect being performed on this view

$oView->aspect($sAction);
my $sAction = $oView->aspect();

content_type - get/set accessor for content mime-type (Content-Type HTTP header)

$oView->content_type($sContentType);
my $sContentType = $oView->content_type();

decor - get/set accessor for page decoration toggle

$oView->decor($bDecorToggle);
my $bDecorToggle = $oView->decor();

entity_name - get/set accessor for the entity_name

Usually set by the controller, after processing the request. Used for
remapping requests to classes (specifically things of the form
application::(model|view)::something::somethingelse .

 $oView->entity_name($sEntityName);
 my $sEntityName = $oView->entity_name();

actions - templated output for available actions

my $sActionOutput = $oView->actions();

list_xml - default passthrough to list() for xml service

read_xml - default passthrough to read() for xml service

create_xml - default passthrough to create() for xml service

update_xml - default passthrough to update() for xml service

delete_xml - default passthrough to delete() for xml service

list_json - default passthrough to list() for json service

read_json - default passthrough to read() for json service

determine_aspect - calculate requested aspect of view

Based on HTTP headers, environment variables and URL components.

init - post-constructor initialisation hook for subclasses

process_template - process a template with standard parameters

Process template.tt2 with standard parameters, output to stdout.

$oView->process_template('template.tt2');


Process template.tt2 with standard parameters plus extras, output to
stdout.

$oView->process_template('template.tt2', {extra=>'params'});


Process template.tt2 with standard plus extra parameters and output
into $to_scalar.

$oView->process_template('template.tt2', {extra=>'params'}, $to_scalar);

output_buffer - queue a string for output

$oView->output_buffer("my string");
$oView->output_buffer(@aStrings);

output_end - flag no more output and flush buffer

$oView->output_end();

output_finished - flag whether to output any more data

$oView->output_finished(1);
$oViwe->output_finished(0);

output_flush - flush output buffer to STDOUT

$oView->output_flush();

output_reset - clear data pending output

$oView->output_reset();

DIAGNOSTICS

CONFIGURATION AND ENVIRONMENT

DEPENDENCIES

Template ClearPress::util Carp English

INCOMPATIBILITIES

BUGS AND LIMITATIONS

AUTHOR

Roger Pettett, <rpettett@cpan.org>

LICENSE AND COPYRIGHT

Copyright (C) 2007 Roger Pettett

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.