Skip to main content

JavaScript API

The runtime publishes everything on one global, window.JuneauViews. Each script adds its own members to that object and none replaces another's, so the load order below is a contract rather than a preference.

Asset load order​

The views toolkit pack (ToolkitPackRegistry) emits these scripts in this order. A <@page toolkit="views"> page gets them automatically; a hand-built page must reproduce the order.

#Script (constant on ViewsMixin)Adds
1juneau-renders.js (RENDERS_JS_PATH)registerRenderer, resolveRenderer, the built-in renderers.
2juneau-icons.js (ICONS_JS_PATH)icons.
3juneau-search.js (SEARCH_JS_PATH)search, the column search-expression engine.
4juneau-pagestate.js (PAGESTATE_JS_PATH)pageState.
5juneau-urlstate.js (URLSTATE_JS_PATH)urlState, shareable-URL state and the View Settings Copy link button.
6juneau-ribbon.js (RIBBON_JS_PATH)ribbon.
7juneau-views.js (VIEWS_JS_PATH)The core: init and the table runtime.
8juneau-config.js (CONFIG_JS_PATH)config, persistence, persistenceProviders, setPersistenceProvider; the View Settings dialog.
9juneau-regions.js (REGIONS_JS_PATH)regions. Must come after juneau-views.js.
10juneau-helpers.js (HELPERS_JS_PATH)helpers, including the field grid.

Stylesheets are juneau-views.css and juneau-config.css. jQuery, DataTables and juneau-datatables.js are not part of the views pack; a datatables card loads them before it (see Card Asset Dependencies).

A page with the calendar widget lists toolkit="views,calendar" so juneau-views.js still loads before juneau-calendar.js. The scripts are classpath resources under org/apache/juneau/views/.

Namespaces​

MemberWhat it is
JuneauViews.registerRenderer(id, def) / resolveRenderer(id)The cell-renderer registry. See Renderers.
JuneauViews.iconsregisterIcon, resolveIcon, loadSymbolSprite, pack, sprites, stems, nameToStem. See Icons.
JuneauViews.pageStateA small keyed store: get, set, remove, table(...), page(...) scopes, useStore(impl), resetStore().
JuneauViews.urlStateencode, decode, readFromSearch, buildSearch, buildShareUrl, copy, resolveOpenState.
JuneauViews.regionsregister, resolve, mount, initRegion, activateRegion, teardownRegion, ready, defaultPopulate. See Regions.
JuneauViews.configView Settings support, including config.dtIndex.
JuneauViews.ribbonThe ribbon filter functions the view runtime calls.
JuneauViews.searchThe search-expression parser and matcher.
JuneauViews.helpersShared builders, including the field grid.
JuneauViews.initSlot mounting (mountTableSlot); what the console shell calls for a datatables card.
JuneauViews.devSet true to turn on development-mode warnings.

pageState​

pageState is backed by localStorage when available and a no-op store otherwise. Use pageState.page(ns) for page-level keys and pageState.table(id) for per-table keys. useStore({getItem, setItem, removeItem}) installs an alternate store, for example a server-backed one.

const prefs = JuneauViews.pageState.page("petstore");
prefs.set("lastTab", "orders");
prefs.get("lastTab");

Events and mounting​

A console page hands a datatables card to JuneauViews.regions.mount on DOMContentLoaded, so views scripts may load after the shell. See Admin-Console Chrome for the window.JuneauConsole API and the juneau:console-mounted event.