oops, missing comma
[catagits/Reaction.git] / lib / Reaction / UI / Controller / Root.pm
1 package Reaction::UI::Controller::Root;
2
3 use base qw/Reaction::UI::Controller/;
4 use Reaction::Class;
5 use Reaction::UI::Window;
6
7 __PACKAGE__->config(
8   view_name => 'XHTML',
9   content_type => 'text/html',
10 );
11
12 has 'view_name' => (isa => 'Str', is => 'rw');
13 has 'content_type' => (isa => 'Str', is => 'rw');
14 has 'window_title' => (isa => 'Str', is => 'rw');
15
16 sub 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
27 sub end :Private {
28   my $window :Stashed;
29   $window->flush;
30 }
31
32 1;
33
34 =head1 NAME
35
36 Reaction::UI::Root - Base component for the Root Controller
37
38 =head1 SYNOPSIS
39
40   package MyApp::Controller::Root;
41   use base 'Reaction::UI::COntroller::Root';
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
51 Using this module as a base component for your L<Catalyst> Root
52 Controller provides automatic creation of a L<Reaction::UI::Window>
53 object containing an empty L<Reaction::UI::FocusStack> for your UI
54 elements. The stack is also resolved and rendered for you in the
55 C<end> action.
56
57 =head1 METHODS
58
59 =head2 view_name
60
61 =over
62
63 =item Arguments: $viewname?
64
65 =back
66
67 Set 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
77 Set 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
87 Set or retrieve the title of the page created.
88
89 =head1 AUTHORS
90
91 See L<Reaction::Class> for authors.
92
93 =head1 LICENSE
94
95 See L<Reaction::Class> for the license.
96
97 =cut