Justin Hunter > Reaction > Reaction::UI::ViewPort

Download:
Reaction-0.002005.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
Stalled  1
View/Report Bugs
Source  

NAME ^

Reaction::UI::ViewPort - Page layout building block

SYNOPSIS ^

  # Create a new ViewPort:
  # $stack isa Reaction::UI::FocusStack object
  my $vp = $stack->push_viewport('Reaction::UI::ViewPort', layout => 'xhtml');

  # Fetch ViewPort higher up the stack (further out)
  my $outer = $vp->outer();

  # Fetch ViewPort lower down (further in)
  my $inner = $vp->inner();

  # Create a named tangent stack for this ViewPort
  my $substack = $vp->create_tangent('name');

  # Retrieve a tangent stack for this ViewPort
  my $substack = $vp->forcus_tangent('name');

  # Get the names of all the tangent stacks for this ViewPort
  my @names = $vp->focus_tangents();

  # Fetch all the tangent stacks for this ViewPort
  # This is called by apply_events
  my $stacks = $vp->child_event_sinks();


  ### The following methods are all called automatically when using
  ### Reaction::UI::Controller(s)
  # Resolve current events with this ViewPort
  $vp->apply_events($ctx, $param_hash);

  # Apply current events to all tangent stacks
  # This is called by apply_events
  $vp->apply_child_events($ctx, $params_hash);

  # Apply current events to this ViewPort
  # This is called by apply_events
  $vp->apply_our_events($ctx, $params_hash);

DESCRIPTION ^

A ViewPort describes part of a page, it can be a field, a form or an entire page. ViewPorts are created on a Reaction::UI::FocusStack, usually belonging to a controller or another ViewPort. Each ViewPort knows it's own position in the stack it is in, as well as the stack containing it.

Each ViewPort has a specific location in the heirarchy of viewports making up a page. The hierarchy is determined as follows: The first ViewPort in a stack is labeled 0, the second is 1 and so on. If a ViewPort is in a named tangent, it's location will contain the name of the tangent in it's location.

For example, the first ViewPort in the 'left' tangent of the main ViewPort has location 0.left.0.

Several ViewPort attributes are set by "push_viewport" in Reaction::UI::FocusStack when new ViewPorts are created, these are as follows:

Automatic:
outer

The outer attribute is set to the previous ViewPort in the stack when creating a ViewPort, if the ViewPort is the first in the stack, it will be undef.

inner

The inner attribute is set to the next ViewPort down in the stack when it is created, if this is the last ViewPort in the stack, it will be undef.

focus_stack

The focus_stack attribute is set to the Reaction::UI::FocusStack object that created the ViewPort.

ctx

The ctx attribute will be passed automatically when using "push_viewport" in Reaction::UI::Controller to create a ViewPort in the base stack of a controller. When creating tangent stacks, you may have to pass it in yourself.

Optional:
location
layout

The layout attribute can either be specifically passed when calling push_viewport, or it will be determined using the last part of the ViewPorts classname.

layout_args

This read-only hashref attribute will pass all it's keys as variables to the layout at render time. They should be accessible from both the layout templates and the widget, if applicable, through the %_ hash.

    $controller->push_viewport(VPName, layout => 'foo', layout_args => { bar => 'bar'});
    $_{bar} #in widget
    [% bar %] in template
column_order

This is generally used by more specialised ViewPorts such as the ListView or Action. It can be either a space separated list of column names, or an arrayref of column names.

METHODS ^

outer

Arguments: none

Fetch the ViewPort outside this one in the page hierarchy.

inner

Arguments: none

Fetch the ViewPort inside this one in the page hierarchy.

create_tangent

Arguments: $tangent_name

Create a new named Reaction::UI::FocusStack inside this ViewPort. The created FocusStack is returned.

focus_tangent

Arguments: $tangent_name

Fetch a named FocusStack from this ViewPort.

focus_tangents

Arguments: none

Returns a list of names of all the known tangents in this ViewPort.

focus_stack

Return the Reaction::UI::FocusStack object that this ViewPort is in.

apply_events

Arguments: $ctx, $params_hashref

This method is called by the FocusStack object to resolve all events for the ViewPort.

apply_child_events

Arguments: $ctx, $params_hashref

Resolve the given events for all the tangents of this ViewPort. Called by apply_events.

apply_our_events

Arguments: $ctx, $events

Resolve the given events that match the location of this ViewPort. Called by apply_events.

handle_events

Arguments: $events

Actually call the event handlers for this ViewPort. Called by apply_our_events. By default this will do nothing, subclass ViewPort and implement accept_events.

accept_events

Arguments: none

Implement this method in a subclass and return a list of events that your ViewPort is accepting.

event_id_for

Arguments: $name

Create an id for the given event name and this ViewPort. Generally returns the location and the name, joined with a colon.

sort_by_spec

Arguments: $spec, $items

Sorts the given list of items such that the ones that also appear in the spec are at the beginning. This is called by Reaction::UI::ViewPort::Action and Reaction::UI::ViewPort::ListView, and gets passed column_order as the spec argument.

AUTHORS ^

See Reaction::Class for authors.

LICENSE ^

See Reaction::Class for the license.

syntax highlighting: