update dependency versions
[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
89b70ba7 36Reaction::UI::Root - Base component for the Root Controller
7adfd53f 37
38=head1 SYNOPSIS
39
40 package MyApp::Controller::Root;
89b70ba7 41 use base 'Reaction::UI::COntroller::Root';
7adfd53f 42
43 # Create UI elements:
44 $c->stash->{focus_stack}->push_viewport('Reaction::UI::ViewPort');
45
46 # Access the window title in a template:
47 [% window.title %]
48
49=head1 DESCRIPTION
50
51Using this module as a base component for your L<Catalyst> Root
52Controller provides automatic creation of a L<Reaction::UI::Window>
53object containing an empty L<Reaction::UI::FocusStack> for your UI
54elements. The stack is also resolved and rendered for you in the
55C<end> action.
56
57=head1 METHODS
58
59=head2 view_name
60
61=over
62
63=item Arguments: $viewname?
64
65=back
66
67Set or retrieve the classname of the view used to render the UI.
68
69=head2 content_type
70
71=over
72
73=item Arguments: $contenttype?
74
75=back
76
77Set or retrieve the content type of the page created.
78
79=head2 window_title
80
81=over
82
83=item Arguments: $windowtitle?
84
85=back
86
87Set or retrieve the title of the page created.
88
89=head1 AUTHORS
90
91See L<Reaction::Class> for authors.
92
93=head1 LICENSE
94
95See L<Reaction::Class> for the license.
96
97=cut