Class: HashUrl

jrt.HashUrl(id, paramsopt, nullable)

Hash URL object, with parser and formatter methods.

An app can request a page, open a dialog or execute an action directly from HTML using a hash URL, that is, a URL fragment identifier that contains the target's id followed by optional parameters, for example:

  #TargetPage?param1=value1&param2=value2

Hash URLs can be used in the following HTML elements:

  • As the href attribute of a link element, that is, an A or AREA element.

  • As the action attribute of a FORM element. Note that if the action attribute is not specified, then the form will not be submitted unless a submit button with a formaction is used. This can be used to prevent the automatic submission that occurs when a control is activated with the Enter key.

  • As the formaction attribute of a BUTTON of type "submit", which will override its form's action.

  • As the formaction attribute of a BUTTON of type "button". This is called a "link button", since it works similarly to a link. The difference is that, if the button belongs to a form, the form values are added to the button's target URL, including the button's name/value (if the button doesn't belong to a form, only the button's name/value are added to the target URL). Note that link buttons only support hash URLs, so a formaction attribute with an external (regular) URLs will be ignored.

An empty URL, or a URL consisting of parameters only, is also considered a hash URL. This URL will generate a request to the current view (instead of reloading the app).

The #back URL implements a built-in action that makes the app go back. Following this URL has the same effect as calling jrt.App#navigateBack.

Constructor

new HashUrl(id, paramsopt, nullable)

Creates a hash URL object.

Parameters:
Name Type Attributes Description
id string

The target id.

params Object.<!jrt.FormValue> <optional>
<nullable>

Optional parameters object.

Members

id :string

The URL's target id.

Type:
  • string

(non-null) params :Object.<!jrt.FormValue>

The URL parameters

Type:

Methods

(static) parse(hash) → (nullable) {jrt.HashUrl}

Factory method that extracts the target id and params from the specified hash URL. Returns null if the hash parameter is not a valid hash URL.

Parameters:
Name Type Description
hash string
Returns:
Type
jrt.HashUrl

format() → {string}

Converts this object to a hash URL. This is a hash composed of the target id followed by the query string. If the target id is empty, the resulting URL will only contain the query string. If the query string is also empty, the result is an empty URL. Note that the returned hash is not URL-encoded.

Returns:
Type
string