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 |
|---|---|---|
| 1 | juneau-renders.js (RENDERS_JS_PATH) | registerRenderer, resolveRenderer, the built-in renderers. |
| 2 | juneau-icons.js (ICONS_JS_PATH) | icons. |
| 3 | juneau-search.js (SEARCH_JS_PATH) | search, the column search-expression engine. |
| 4 | juneau-pagestate.js (PAGESTATE_JS_PATH) | pageState. |
| 5 | juneau-urlstate.js (URLSTATE_JS_PATH) | urlState, shareable-URL state and the View Settings Copy link button. |
| 6 | juneau-ribbon.js (RIBBON_JS_PATH) | ribbon. |
| 7 | juneau-views.js (VIEWS_JS_PATH) | The core: init and the table runtime. |
| 8 | juneau-config.js (CONFIG_JS_PATH) | config, persistence, persistenceProviders, setPersistenceProvider; the View Settings dialog. |
| 9 | juneau-regions.js (REGIONS_JS_PATH) | regions. Must come after juneau-views.js. |
| 10 | juneau-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
| Member | What it is |
|---|---|
JuneauViews.registerRenderer(id, def) / resolveRenderer(id) | The cell-renderer registry. See Renderers. |
JuneauViews.icons | registerIcon, resolveIcon, loadSymbolSprite, pack, sprites, stems, nameToStem. See Icons. |
JuneauViews.pageState | A small keyed store: get, set, remove, table(...), page(...) scopes, useStore(impl), resetStore(). |
JuneauViews.urlState | encode, decode, readFromSearch, buildSearch, buildShareUrl, copy, resolveOpenState. |
JuneauViews.regions | register, resolve, mount, initRegion, activateRegion, teardownRegion, ready, defaultPopulate. See Regions. |
JuneauViews.config | View Settings support, including config.dtIndex. |
JuneauViews.ribbon | The ribbon filter functions the view runtime calls. |
JuneauViews.search | The search-expression parser and matcher. |
JuneauViews.helpers | Shared builders, including the field grid. |
JuneauViews.init | Slot mounting (mountTableSlot); what the console shell calls for a datatables card. |
JuneauViews.dev | Set 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.