# new App()
The App-Class handles the rendering and computing of the pages that we can define in JAMES.
Methods
# (async) deserialize(obj) → {Promise.<void>}
Serializing function for the window.history api
Parameters:
Name | Type | Description |
---|---|---|
obj |
* | the data object to deserialize |
Returns:
- Type
- Promise.<void>
# (async) deserializeCurrentPage() → {Promise.<void>}
Deserializes all data of the current page
Returns:
- Type
- Promise.<void>
# getCurrentPage() → {object}
Returns the dataset of the currently active page object
Returns:
the dataset of the currently active page object
- Type
- object
Example
j.app.getCurrentPage();
# (async) goToPage(ident, replaceState)
Opens the page with the given identifier
IMPORTANT: USE App#next INSTEAD!
Parameters:
Name | Type | Description |
---|---|---|
ident |
string | the identifier of the target page |
replaceState |
boolean | defines wether to replace the current or push a new state to the window.history api |
- Deprecated:
- Yes
- See:
# hasPage(page_id) → {boolean}
Checks, if a page exists in the current Application context
Parameters:
Name | Type | Description |
---|---|---|
page_id |
string | the page identifier (alias) |
Returns:
if false, the page either doesn't exist or wasn't assigned in the Profile-Pages-Mapping
- Type
- boolean
Example
if(j.app.hasPage("main_menu")) { ... }
# (async) initialize() → {false|void}
Function to fetch the manifest and start the application
Returns:
false on error
- Type
- false | void
# (async) next(page_id, data, link_map_event) → {Promise.<void>}
The main jump-function to go to another page
Parameters:
Name | Type | Description |
---|---|---|
page_id |
stirng | the page to go to |
data |
object | undefined | data object that gets assigned to be available on the next page |
link_map_event |
string | a string for the link map to check if it shall override the target page with a custom jump point |
Returns:
- Type
- Promise.<void>
Examples
Example 1 - Simple page change
j.app.next("main_menu");
Example 2 - With data
j.app.next("some_page",{customField: "Hallo test!"});
// Switches to the "some_page"-page and in the html rendering {$customField} will resolve to "Hallo test!"
Example 3 - With custom jump-mappings
j.app.next("main_menu", {}, "language_chosen");
// Normally the next() would go to the "main_menu"-page.
// But assuming, in the Application profile a mapping like 'language_chosen: "awesome_page"' exists
// it will now override the default behaviour and go to the "awesome_page"-page instead.
# (async) onBeforeNext() → {Promise.<boolean>}
This runs before navigating to another page
Returns:
resolves to false, if cancelled by one of the before event scripts
- Type
- Promise.<boolean>
# (async) onBeforeRender() → {Promise.<boolean>}
This runs before the current page gets rendered. This is used to prepare some relevant data for rendering or to check some precautions and cancel the rendering and navigate elsewhere
Returns:
resolves to false, if cancelled by one of the before event scripts
- Type
- Promise.<boolean>
# (async) render() → {Promise.<void>}
Renders the current page (gets templates, js-files and stuff and renders them)
Returns:
- Type
- Promise.<void>
# (async) renderBaseSite() → {Promise.<void>}
This function is used to trigger the rendering of the base template
Returns:
- Type
- Promise.<void>
# (async) serializeCurrentPage() → {Promise.<void>}
Serializes al data of the current page
Returns:
- Type
- Promise.<void>
# (async) setLanguage(ident, noReload, noRerender) → {Promise.<void>}
Set the language of the application
Parameters:
Name | Type | Description |
---|---|---|
ident |
string | the language key to set |
noReload |
boolean | if false, the current page gets re-comuputed |
noRerender |
boolean | if false, the current page is being rerendered including the base-template |
Returns:
- Type
- Promise.<void>
Example
j.app.setLanguage("de"); // sets the language of the app to german
# (async) updatePage() → {Promise.<void>}
Re-Compute and rerender the current page
Returns:
- Type
- Promise.<void>