3 Reaction::Manual::Clipboard - snippets of Reaction docs
7 =head2 These should probably go in the glossary.
13 DBIx::Class::Schema, MyApp::Foo, MyApp::Bar, etc.
17 InterfaceModel::DBIC::Schema, InterfaceModel::Action,
18 MyApp::InterfaceModel::Foo classes.
22 Mediation and navigation.
26 Event handling encapsulation.
34 MyApp::View:: classes, renders viewports.
39 These should go in the tutorial?
42 =head1 SETTING UP A REACTION APPLICATION
44 Reaction applications are set up just like Catalyst:
52 Reaction provides a reflector component which automagically
53 maps a L<DBIx::Class::Schema> into a set of Interface Models which can be used
54 by Reaction to build the interface components. If you're not familiar with
55 L<DBIx::Class> or don't have a schema handy, now is a good time to go through
56 L<DBIx::Class::Manual::Intro> to get a schema set up.
58 It is important that your Result-objects implement the meta-protocol of Moose
59 One way to achive that is to do the following:
61 package MyApp::Schema::Result::Bar;
62 use base 'DBIx::Class';
65 has 'name' => (isa => 'Str', required => 1, rw => 1);
67 use namespace::clean -except => [ 'meta' ];
69 __PACKAGE__->load_components(qw(Core));
70 __PACKAGE__->table('bar');
71 __PACKAGE__->add_columns(
73 data_type => 'varchar',
78 __PACKAGE__->primary_key('name');
81 Once you have your schema set up like that, you can create the InferfaceModel:
83 package MyApp::InterfaceModel::DBIC;
85 use base 'Reaction::InterfaceModel::Object';
86 use Reaction::InterfaceModel::Reflector::DBIC;
88 my $reflector = Reaction::InterfaceModel::Reflector::DBIC->new;
90 $reflector->reflect_schema(
91 model_class => __PACKAGE__,
92 schema_class => 'MyApp::Schema',
93 sources => [qw/Foo Baz/],
98 Then you create a MyApp::Model that uses this InferfaceModel:
100 package Myapp::Model::IM;
104 extends 'Catalyst::Model::Reaction::InterfaceModel::DBIC';
110 =head3 Root controller
112 Your Reaction application must have a Root controller which inherits from
113 C<Reaction::UI::Controller::Root>.
115 package MyApp::Controller::Root;
119 use base qw/Reaction::UI::Controller::Root/;
123 window_title => 'My Reaction App',
127 sub base : Chained('/') PathPart('') CaptureArgs(0) {
128 # do some setup for every request
129 # also provides a chain root for other controllers to use
134 =head3 Individual controllers
136 For each Collection(table?) in your DB, you need to create a controller
138 package MyApp::Controller::Foo;
140 use base 'Reaction::UI::Controller::Collection::CRUD';
144 model_name => 'IM', # This corresponds to the name of the MyApp::Model you created earlier
145 collection_name => 'Foo', # Name of one of the sources in your InterfaceModel
147 base => { Chained => '/base', # chain to the base action in the root controller
158 One of the views in your application should look something like this:
160 package MyApp::View::TT;
164 extends 'Reaction::UI::View::TT';
177 =item * L<Reaction::Manual::Cookbook>
179 =item * L<Reaction::Manual::FAQ>
185 See L<Reaction::Class> for authors.
189 See L<Reaction::Class> for the license.