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

NAME

RPC::ExtDirect::API - Remoting API generator for Ext.Direct

SYNOPSIS

 use RPC::ExtDirect::API         namespace    => 'myApp',
                                 router_path  => '/router',
                                 poll_path    => '/events',
                                 remoting_var => 'Ext.app.REMOTING_API',
                                 polling_var  => 'Ext.app.POLLING_API',
                                 auto_connect => 0,
                                 no_polling   => 0,
                                 before       => \&global_before_hook,
                                 after        => \&global_after_hook,
                                 ;

DESCRIPTION

This module provides Ext.Direct API code generation.

In order for Ext.Direct client code to know about what Actions (classes) and Methods are available on the server side, these should be defined in a chunk of JavaScript code that gets requested from the client at startup time. It is usually included in the index.html after main ExtJS code:

  <script type="text/javascript" src="extjs/ext-debug.js"></script>
  <script type="text/javascript" src="/extdirect_api"></script>
  <script type="text/javascript" src="myapp.js"></script>

RPC::ExtDirect::API provides a way to configure Ext.Direct definition variable(s) to accomodate specific application needs. To do so, pass configuration options to the module when you 'use' it, like shown above.

The following configuration options are supported:

 namespace      - Declares the namespace your Actions will
                  live in. To call the Methods on client side,
                  you will have to qualify them with namespace:
                  namespace.Action.Method, e.g.: myApp.Foo.Bar
 
 router_path    - URI for Ext.Direct Router calls. For CGI
                  implementation, this should be the name of
                  CGI script that provides API; for more
                  sophisticated environments it is an anchor
                  for specified PATH_INFO.
 
 poll_path      - URI for Ext.Direct Event provider calls.
                  Client side will poll this URI periodically,
                  hence the name.
 
 remoting_var   - By default, Ext.Direct Configuration for
                  remoting (forward) Methods is stored in
                  Ext.app.REMOTING_API variable. If for any
                  reason you would like to change that, do this
                  by setting remoting_var.
                  Note that in production environment you would
                  probably want to use a compiled version of
                  JavaScript application that consist of one
                  big JavaScript file. In this case, it is
                  recommended to include API declaration as the
                  first script in your index.html and change
                  remoting API variable name to something like
                  EXT_DIRECT_API. Default variable name depends
                  on Ext.app namespace being available by the
                  time Ext.Direct API is downloaded, which is
                  often not the case.
 
 polling_var    - By default, Ext.Direct does not provide a
                  standard name for Event providers to be
                  advertised in. For similarity, POLLING_API
                  name is used to declare Event provider so
                  it can be used on client side without
                  having to hardcode any URIs explicitly.
                  POLLING_API configuration will only be
                  advertised to client side if there are any
                  Event provider Methods declared.
                  Note that the same caveat applies here as
                  with remoting_var.
 
 no_polling     - Explicitly declare that no Event providers
                  are supported by server side. This results
                  in POLLING_API configuration being suppressed
                  even if there are any Methods with declared
                  pollHandler ExtDirect attribute.
 
 auto_connect   - Generate the code that adds Remoting and
                  Polling providers on the client side without
                  having to do this manually.

 before         - Global "before" hook.
 
 instead        - Global "instead" hook.
 
 after          - Global "after" hook.
 
 For more information on hooks and their usage, see L<RPC::ExtDirect>.

SUBROUTINES/METHODS

There are no methods intended for external use in this module.

AUTHOR

Alexander Tokarev <tokarev@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2011-2012 Alexander Tokarev.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.