Class: UrlPathParamAdapter

Oracle® JavaScript Extension Toolkit (JET)
16.1.0

F92237-01

Since:
  • 11.0.0
Module:
  • ojurlpathparamadapter

QuickNav

Description

Class to synchronize CoreRouter state with the browser URL using path segments.

A URL adapter that uses path segments to synchronize router state (/path1/path2/path3). This adapter is similar to UrlPathAdapter except that it doesn't embed parameters into the same URL path segment. Instead, parameters follow the route path, and are separated by the path delimiter (forward slash).

/path/param1/param2

This adapter has the same requirement upon the server to support URL-rewriting. See UrlPathAdapter for more details on this.

Alternatives to UrlPathParamAdapter are UrlPathAdapter and UrlParamAdapter.


Usage

Signature:

class UrlPathParamAdapter<P extends {[key: string]: any} = {[key: string]: any}>

Generic Parameters
ParameterDescription
PParameters object for the router state
Typescript Import Format
//This class is exported directly as module. To import it
import UrlPathParamAdapter= require("ojs/ojurlpathparamadapter");

For additional information visit:


Constructor

new UrlPathParamAdapter(baseUrl)

Parameters:
Name Type Argument Description
baseUrl string <optional>
The base URL from which the application is served. This value may be any string value (even blank). If not specified at all (undefined), then the adapter will use document.location.pathname as its base.

Methods

getRoutesForUrl(routePathParams, url) : {Array.<CoreRouter.CoreRouterState<P>>}

Build all routes for the given URL. The URL is expected to start with the baseUrl set for this adapter, because it will be subtracted out before routes are built.
Parameters:
Name Type Argument Description
routePathParams {offset: number, pathParams: Array.<string>} <optional>
An object containing the offset within the URL segments and the path parameters for the state.
url string <optional>
Optional URL to use. If not specified, document.location.pathname is used.
Returns:

An array of states starting from the path for the given router.

Type
Array.<CoreRouter.CoreRouterState<P>>

getUrlForRoutes(states) : {string}

Build the URL path for the given routes.
Parameters:
Name Type Description
states Array.<CoreRouter.CoreRouterState<P>> The set of states from which the URL will be built.
Returns:

The full URL representative of the given routes

Type
string