Page Reference

Table of Contents


Introduction

Pages form the bulk of an app. A Page instance contains the following:


Page creation

Syntax

ctl.createPage(info)

Pages are created using the ctl.createPage() factory function.


Instance methods

close()

Syntax

close()

The Controller calls the close() method when the page is dismissed. The page can use it to remove event listeners or do other cleanup from open(). The default close() method does nothing.


component()

Syntax

component()

The Nav page or other navigation component calls the component() method to retrieve a Component subclass that will display this page's content in the View. The default component() returns a Component class whose Component render() method returns the results of calling the Page instance's render() method. Therefore, a page can supply a simpler render() method instead of implementing a full Component subclass.

Return value

A Template object, a string, a number, a DOM node, a Component object, or an array containing a mix of these types.


deactivate()

Syntax

deactivate()

The Controller calls the deactivate() method when a new popup page is opened on top of this page. It returns the state values required to restore this page's state when the pages on top are dismissed. The default deactivate() method returns null.

Return value

Any JavaScript type. This value is used as the state argument for reactivate(state) when the page is reactivated.


getSavedState()

Syntax

getSavedState(state)

The Controller calls each page's getSavedState() method when the application state is being saved to local device storage or in the cloud. The method adds the information required to restore the page's state variables to the state object.

The default getSavedState() method adds the information for the page's state variables marked for saving locally or globally. The value stored for each state variable's ID key is the result of calling the state variable's getSavedState() method.

Parameters


hasChanged()

Syntax

hasChanged()

The Controller calls the hasChanged() method to determine if the page Model computations need to be recomputed. It returns true if the page's inputs have changed since the last time they were interrogated. The default hasChanged() method maintains an array of SvMonitors for the state variables marked for saving locally or globally, and returns true is any of the SvMonitors hasChanged() methods returns true.

Return value


init()

Syntax

init()

The Controller calls the init() method after the application is fully loaded on startup and all application pages and their associated state variables are created. However, the state variable value may not be restored from the previous session. This allows the page to do any pre-setup before being opened.


open()

Syntax

open(arg)

The Controller calls the open() method when a page is opened. This allows the page to do any pre-setup before Model computation.

Parameters


reactivate()

Syntax

reactivate(state)

The Controller calls the reactivate() method when the popup pages above the page are dismissed, and the page is now the topmost page. The state argument is the value the deactivate() method returned previously for this page.

Parameters


render()

Syntax

render()

The default component() returns a Component class whose Component render() method returns the results of calling the Page instance's render() method. Therefore, a page can supply a simpler render() method instead of implementing a full Component subclass.

Return value

A Template object, a string, a number, a DOM node, a Component object, or an array containing a mix of these types that represents the contents of the page when opened.


renderHelp()

Syntax

renderHelp()

When initialized, the built-in Help page automatically collects the templates returned by calling the renderHelp() method. It then uses that information, along with the page's pageId and title, as a help topic.

Return value

A Template object, a string, a number, a DOM node, a Component object, or an array containing a mix of these types that represents the help information displayed when the page is selected as the help topic.


setSavedState()

Syntax

setSavedState(state)

The Controller calls each page's setSavedState() method when the application state is being restored from local device storage or from the cloud. The method uses the information in the state object to restore the page's state variables. The state object uses the state variable ID as a key for each state variable's information.

The default setSavedState() method restores the state of the page's state variables marked for saving locally or globally. The state is restored by calling the state variable's setSavedState() method passing the state object's value for the state variables.

Parameters


upgradeSavedState()

Syntax

upgradeSavedState(state, version)

The Controller calls each page's setSavedState() method after the application state to be restored has been retrieved from local device storage or from the cloud. The method updates the page's state variable information in the state object as required to upgrade the information of the information saved by an older application version to the current application version. The method interprets the version string and updates the relevant keys and values as required.

See also:

Parameters

Return value

Returns true if the upgrade was successful. Returns false if the information was corrupt or too old.


Instance properties

computeInfo

The computeInfo array from the info object passed to ctl.createPage().

Value

An array.


isOpen

True if the page is opened, whether activated or deactivated.

Value

A Boolean.


isActive

True if the page is opened and activated.

Value

A Boolean.


pageId

The page's ID.

Value

A string.


stateVarInfo

The stateVarInfo array from the info object passed to ctl.createPage().

Value

An array.


tipInfo

The tipInfo array from the info object passed to ctl.createPage().

Value

An array.


title

The page's title.

Value

An string.