Class: UrlPathAdapter

Oracle® JavaScript Extension Toolkit (JET)
17.1.0

G12196-01

Since:
  • 8.0.0
Module:
  • ojurlpathadapter

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;param=123/path2;param=456/path3;param=789). This adapter is the default for CoreRouter, and should be used when the web server serving up UI content has the ability to internally proxy requests from one pseudo path to another.

For instance, if the root of your application is http://localhost/, then router states will be added onto this root using path segments, such as http://localhost/path1;param=123/path2;param=456. This path may be bookmarked, and during restoration (or browser reload), the server will be asked to serve up the content from that directory. Since these are presumably virtual directories (they may or may not actually exist on the server), two things must happen for the UI to load correctly:

  • The web server must recognize that "/path1/path2" are virtual paths and serve up the content from the root (/) instead.
  • baseUrl must be set to the correct root; in this case--"http://localhost/"

Note that this adapter uses matrix parameters in the URL. This mechanism allows an arbitrary number of parameters to be passed to the state without have to pre-define them in the route configuration.

Alternatives to UrlPathAdapter are UrlParamAdapter and UrlPathParamAdapter.


Usage

Signature:

class UrlPathAdapter<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 UrlPathAdapter= require("ojs/ojurlpathadapter");

For additional information visit:


Constructor

new UrlPathAdapter(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.Route.<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 object <optional>
url string <optional>
Optional URL to use. If not specified, document.location.pathname is used.
Returns:

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

Type
Array.<CoreRouter.Route.<P>>

getUrlForRoutes(routes) : {string}

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

The full URL representative of the given routes

Type
string