| CatalystX-Usul documentation | view source | Contained in the CatalystX-Usul distribution. |
CatalystX::Usul::Action - A generic action class
0.3.$Revision: 576 $
use base qw(CatalystX::Usul::Controller);
sub some_method : Chained('/') PathPart('') Args(0) HasActions {
my ($self, $c) = @_;
$c->model( q(some_model) )->add_buttons( $c, qw(Save Delete) );
return;
}
sub delete_action : ActionFor('some_method.delete') {
}
sub save_action : ActionFor('some_method.save') {
}
The _parse_HasActions_attr method in the base controller class causes
Catalyst to chain this execute method when a form is posted to an end
point the sets the HasActions attribute
Actions should define one or more ActionFor attributes whose argument takes the form; method name dot lower case button name, where the button name was also passed to add_buttons
The verb is obtained from the request object via the stash. Verbs can be set the _method parameter which is removed to prevent this from executing more than once. If we're using it, check to see if the form token is valid and remove it from the form. Recover the button to subroutine map for this action by introspection and forward to that method. Log an error if one occurred and add it's text to the result block. In the event that an error occurred, set the override attribute in the stash which causes the HTML view to call Catalyst::Plugin::FillInForm to preserve the form's state
Errors are logged to $controller->log_error
Expects $c->stash->{buttons} to be a hash that
contains display text for errors, prompts and tips
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <Support at RoxSoft.co.uk>
Copyright (c) 2008 Peter Flanigan. All rights reserved
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
| CatalystX-Usul documentation | view source | Contained in the CatalystX-Usul distribution. |