Commit | Line | Data |
89b70ba7 |
1 | package Reaction::UI::Controller::Root; |
7adfd53f |
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 | |
89b70ba7 |
36 | Reaction::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 | |
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 | |
57 | Using this module as a base component for your L<Catalyst> Root |
58 | Controller provides automatic creation of a L<Reaction::UI::Window> |
59 | object containing an empty L<Reaction::UI::FocusStack> for your UI |
60 | elements. The stack is also resolved and rendered for you in the |
61 | C<end> action. |
62 | |
63 | =head1 METHODS |
64 | |
65 | =head2 view_name |
66 | |
67 | =over |
68 | |
69 | =item Arguments: $viewname? |
70 | |
71 | =back |
72 | |
c2bd9d41 |
73 | Set or retrieve the classname of the view used to render the UI. Can |
74 | also 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 |
84 | Set or retrieve the content type of the page created. Can also be set |
85 | by 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 |
95 | Set or retrieve the title of the page created. Can also be set by a |
96 | call to config or in a config file. No default. |
7adfd53f |
97 | |
98 | =head1 AUTHORS |
99 | |
100 | See L<Reaction::Class> for authors. |
101 | |
102 | =head1 LICENSE |
103 | |
104 | See L<Reaction::Class> for the license. |
105 | |
106 | =cut |