Fix typos in doc
[catagits/Reaction.git] / lib / Reaction / UI / Controller / Root.pm
CommitLineData
89b70ba7 1package Reaction::UI::Controller::Root;
7adfd53f 2
3use base qw/Reaction::UI::Controller/;
4use Reaction::Class;
5use Reaction::UI::Window;
6
7__PACKAGE__->config(
8 view_name => 'XHTML',
9 content_type => 'text/html',
10);
11
12has 'view_name' => (isa => 'Str', is => 'rw');
13has 'content_type' => (isa => 'Str', is => 'rw');
14has 'window_title' => (isa => 'Str', is => 'rw');
15
16sub begin :Private {
17 my ($self, $ctx) = @_;
18 my $window :Stashed = Reaction::UI::Window->new(
19 ctx => $ctx,
20 view_name => $self->view_name,
21 content_type => $self->content_type,
22 title => $self->window_title,
23 );
24 my $focus_stack :Stashed = $window->focus_stack;
25}
26
27sub end :Private {
28 my $window :Stashed;
29 $window->flush;
30}
31
321;
33
34=head1 NAME
35
68f88d4e 36Reaction::UI::Controller::Root - Base component for the Root Controller
7adfd53f 37
38=head1 SYNOPSIS
39
40 package MyApp::Controller::Root;
68f88d4e 41 use base 'Reaction::UI::Controller::Root';
7adfd53f 42
c2bd9d41 43 __PACKAGE__->config(
44 view_name => 'Site',
45 window_title => 'Reaction Test App',
46 namespace => ''
47 );
48
7adfd53f 49 # Create UI elements:
50 $c->stash->{focus_stack}->push_viewport('Reaction::UI::ViewPort');
51
52 # Access the window title in a template:
53 [% window.title %]
54
55=head1 DESCRIPTION
56
57Using this module as a base component for your L<Catalyst> Root
58Controller provides automatic creation of a L<Reaction::UI::Window>
59object containing an empty L<Reaction::UI::FocusStack> for your UI
60elements. The stack is also resolved and rendered for you in the
61C<end> action.
62
63=head1 METHODS
64
65=head2 view_name
66
67=over
68
69=item Arguments: $viewname?
70
71=back
72
c2bd9d41 73Set or retrieve the classname of the view used to render the UI. Can
74also be set by a call to config. Defaults to 'XHTML'.
7adfd53f 75
76=head2 content_type
77
78=over
79
80=item Arguments: $contenttype?
81
82=back
83
c2bd9d41 84Set or retrieve the content type of the page created. Can also be set
85by a call to config or in a config file. Defaults to 'text/html'.
7adfd53f 86
87=head2 window_title
88
89=over
90
91=item Arguments: $windowtitle?
92
93=back
94
c2bd9d41 95Set or retrieve the title of the page created. Can also be set by a
96call to config or in a config file. No default.
7adfd53f 97
98=head1 AUTHORS
99
100See L<Reaction::Class> for authors.
101
102=head1 LICENSE
103
104See L<Reaction::Class> for the license.
105
106=cut