IOrbViewController Interface

Orb Views are a sub-framework of the Orb framework, which is designed to streamline the development of an application that can be defined as a series of views (also known as pages, screens, displays, and similar in other frameworks).

Views are controlled through a view controller, which is an instance of a class that implements the IOrbViewController interface.

The IOrbViewController interface specifies the following methods.

To use views, in the:

  1. execute or render method of a route, create or retrieve an existing view controller.

  2. render method of the route, return the result of the view method when passed the instance of the view controller.

Routes that respond to views must be added using the addView method. For details, see "IOrbRoute Interface" and "Routing Engine", elsewhere in this document.

In your HTML templates, specify the data-orb-navigate data attribute on elements that make a request to a URL when the user interacts with them (the data attribute parameter specifies the URL to which the request is made); for example:

<div data-orb-navigate="login">Login!</div>

When this element is clicked or tapped on the web page, a request is made to the /login route. As this is a navigation request, Orb responds with the result of calling the partial and content methods on the view controller. If the /login route was directly requested by the web browser, Orb would respond with the result of the full method.

It is expected that the route class that responds to the /login request sets up an instance of the view controller class appropriately and call the view method.