The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

CatalystX::Usul::Action - A generic action class

Version

0.6.$Revision: 1165 $

Synopsis

   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') {
   }

Description

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

Subroutines/Methods

execute

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

Diagnostics

Errors are logged to $controller->log_error

Configuration and Environment

Expects $c->stash->{buttons} to be a hash that contains display text for errors, prompts and tips

Dependencies

Catalyst::Action

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Copyright (c) 2011 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