Class: UrlPathAdapter

Oracle® JavaScript Extension Toolkit (JET)
9.0.0

F24343-01

Signature:

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

QuickNav

UrlPathAdapter

Version:
  • 9.0.0
Since:
  • 8.0.0
Module:
  • ojurlpathadapter

Module usage

See JET Module Loading for an overview of module usage within JET.

Typescript Import Format
//This class is exported directly as module. To import it
import UrlPathAdapter= require("ojs/ojurlpathadapter");

Generic Parameters
ParameterDescription
PParameters object for the router state

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.

Description

UrlPathAdapter class

A URL adapter that uses path segments to synchronize router state (/path1/path2/path3). 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/path. 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/"

An alternative to UrlPathAdapter is UrlParamAdapter.

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(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
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