NAME

Reaction::UI::Window - Container for rendering the UI elements in

SYNOPSIS

my $window = Reaction::UI::Window->new(
  ctx => $ctx,
  view_name => $view_name,
  content_type => $content_type,
  title => $window_title,
);

# More commonly, as Reaction::UI::Controller::Root creates one for you:
my $window = $ctx->stash->{window};

# Resolve current events and render the view of the UI
#  elements of this Window:
# This is called by the end action of Reaction::UI::Controller::Root
$window->flush();

# Resolve current events:
$window->flush_events();

# Render the top ViewPort in the FocusStack of this Window:
$window->flush_view();

# Render a particular ViewPort:
$window->render_viewport($viewport);

# Or in a template:
[% window.render_viewport(self.inner) %]

# Add a ViewPort to the UI:
$window->focus_stack->push_viewport('Reaction::UI::ViewPort');

DESCRIPTION

A Window object is created and stored in the stash by Reaction::UI::Controller::Root, it is used to contain all the elements (ViewPorts) that make up the UI. The Window is rendered in the end action of the Root Controller to make up the page.

To add ViewPorts to the stack, read the Reaction::UI::FocusStack and Reaction::UI::ViewPort documentation.

Several Window attributes are set by "begin" in Reaction::UI::Controller::Root when a new Window is created, these are as follows:

ctx

The current Catalyst context object is set.

view_name

The view_name is set from the Reaction::UI::Controller::Root attributes.

content_type

The content_type is set from the Reaction::UI::Controller::Root attributes.

title

The title is set from the Reaction::UI::Controller::Root window_title attribute.

METHODS

ctx

Arguments: $ctx?

Retrieve/set the current Catalyst context object.

view_name

Arguments: %viewname?

Retrieve/set the name of the Catalyst::View component used to render this Window. If this has not been set, rendering the Window will fail.

content_type

Arguments: $contenttype?

Retrieve the content_type for the page. If this has not been set, rendering the Window will fail.

title

Arguments: $title?
[% window.title %]

Retrieve/set the title of this page, if not set, it will default to "Untitled window".

view

Arguments: none

Retrieve the Catalyst::View instance, this can be set, or will be instantiated using the view_name class.

focus_stack

Arguments: none
$window->focus_stack->push_viewport('Reaction::UI::ViewPort');

Retrieve the stack of ViewPorts that contains all the UI elements for this Window. Use "push_viewport" in Reaction::UI::FocusStack on this to create more elements. An empty FocusStack is created by the Controller::Root when the Window is created.

render_viewport

Arguments: $viewport
$window->render_viewport($viewport);

[% window.render_viewport(self.inner) %]

Calls render on the view object used by this Window. The following arguments are given:

ctx

The Catalyst context object.

self

The ViewPort object to be rendered.

window

The Window object.

type

The string that describes the layout from "layout" in Reaction::UI::ViewPort.

flush

Arguments: none

Synchronize the current events with all the Reaction::UI::ViewPort objects in the UI, then render the root ViewPort. This is called for you by "end" in Reaction::UI::Controller::Root.

flush_events

Arguments: none

Resolves all the current events, first the query parameters then the body parameters, with all the Reaction::UI::ViewPort objects in the UI. This calls "apply_events" in Reaction::UI::FocusStack. This method is called by flush.

flush_view

Arguments: none

Renders the page into the Catalyst::Response body, unless the response status is already set to 3xx, or the body has already been filled. This calls render_viewport with the root Reaction::UI::ViewPort from the focus_stack. This method is called by flush.

AUTHORS

See Reaction::Class for authors.

LICENSE

See Reaction::Class for the license.