Class URLUtils
URL utility class. Methods in this class generate URLs used in Commerce Cloud Digital.
Site related information in the generated URLs is determined from the current HTTP request.
Methods belong to two groups: generating absolute and relative URLs. Absolute URL methods are further subdivided into those creating URLs with specified protocol and those using protocol information from the request. Corresponding to the protocol, the host name from the HTTP/HTTPS host preference is used. If preference is not set, the host name from the current request is included in resulting absolute URL.
URLs do not include a session ID anymore. The appendSID argument therefore does not have any effect.
When creating a pipeline URL with one of the methods url(), http(), https() or abs() by default the generated URL is a Commerce Cloud Digital URL ("/on/demandware.store/..."). If search friendly URLs are enabled (old or new) the methods generate search friendly URLs. Search friendly URLs are only generated for certain pipeline names. Here a list of these pipeline names:
- Product-Show with a 'pid' parameter [productID] - search friendly URL for a product
- Product-ShowInCategory with the 'cgid' parameter [categoryID] and 'pid' parameter [productID] - search friendly URL for a product shown in a specific category
- Search-Show with a 'cgid' parameter [categoryID] - search friendly URL for a category
- Search-Show with a 'pid' parameter [productID] - search friendly URL for a product
- Search-ShowContent with a 'fdid' parameter [folderID] - search friendly URL for a folder (ONLY works with new storefront URLs)
- Page-Show with a 'cid' parameter [contentID] - search friendly URL for a content page
Parameter transform:
Some methods allow the specification of image transformation parameters. Image transformation is only performed if the Dynamic Imaging Service (DIS) is available for the Commerce Cloud Digital instance. Otherwise a standard static content URL is returned. The to-be-transformed image needs to be hosted on Digital.
Image transformation parameters are specified as JavaScript object literal. They are translated into URL parameters. See Create Image Transformation URLs.
| Type of transformation | Parameters | Description |
|---|---|---|
| Scale an image | scaleWidthscaleHeightscaleMode | The scaleWidth and scaleHeight parameters are both integers; setting one of these parameters triggers a scaling operation. If both are provided, the one that scales the image less is used to calculate the scale factor. The image is then automatically cropped accord to the second dimension, with a centered position of the cropped area. If the parameter would scale the image larger, only this operation is applied, if the image remains within acceptable pixel dimensions. Note: The |
| Overlay an image | imageXimageYimageURI | The imageX and imageY parameters are both integers. Valid values for these parameters are 0 or greater. Supported formats are The If the overlaid image extends over the primary image's boundaries, the overlaid image is cropped so that it fits directly over the primary image. |
| Crop an image | cropXcropYcropWidthcropHeight | The cropX, cropY, cropWidth, cropHeight parameters are integers. All four parameters must be specified to trigger a cropping operation. Valid values for the Valid values for the |
| Format an image | format | The format parameter specifies the target format of the image. Supported formats are png, jpg, jp2, and gif. If no target format is specified, no format conversion is performed. The source image file is references with attribute In the generated URL the file extension of the target format is used in the URL path. This is to make sure the image is loaded from an URL with a matching file extension. The source format is provided as URL parameter. |
| Adjust image compression quality | quality | The quality parameter specifies a quality setting for jpg and jp2 images, and specifies the compression level for png images. For For If the |
| Adjust Metadata stripping | strip | The strip parameter specifies if metadata like EXIF and color profiles is stripped from the image during transformation. Valid values for the |
| Change background color | bgcolor(color) or bgcolor(color+alpha) | The bgcolor parameter specifies the background color for images that support transparency as well as JPEG images when being converted from a format that supports transparency. Optionally, alpha setting for PNG images are also supported. FF0000 = Red FF000077 = Red with 50% transparency Alpha values are optional. When the alpha value is omitted, the resulting color is opaque. Alpha values are only valid when the image output format is PNG. |
Example:
The following code
var url = URLUtils.imageURL('/somepath/image.png', {scaleWidth: 100, format: 'jpg'});
will produce an image transformation URL like
http://<image server host name>/.../on/demandware.static/.../somepath/image.jpg?sw=100&sfrm=png.
| Constant | Description |
|---|---|
| CONTEXT_CATALOG: String = "ContextCatalog" | ID for a catalog context. |
| CONTEXT_LIBRARY: String = "ContextLibrary" | ID for a library context. |
| CONTEXT_SITE: String = "ContextSite" | ID for a site context (= assigned cartridges). |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| Return an absolute URL with protocol and host from current request. | |
| Return an absolute URL with protocol and host from current request. | |
| static abs(URLAction, URLParameter...) | Return an absolute URL with protocol and host from the current request. |
| static abs(String, String...) | Return an absolute URL with protocol and host from current request. |
| static absImage(String, Object) | Similar to absStatic( String ) this method returns a static URL for a resource in the current site. |
| static absImage(String, String, String, Object) | Similar to absStatic( String, String, String ) this method returns a static URL for a resource in the current site. |
| static absStatic(String) | The method returns a static URL for a resource in the current site. |
| static absStatic(String, String, String) | Returns the absolute URL to the static location of the specified context. |
| Return an absolute web root URL with protocol and host same as the current request. | |
| static continueURL() | Return a URL, which can be used in combination with an Interaction Continue Node, to continue the user interface flow. |
| static home() | Generates a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the protocol of the incoming request. |
| Return an absolute URL with HTTP protocol. | |
| Return an absolute URL with HTTP protocol. | |
| static http(URLAction, URLParameter...) | Return an absolute URL with HTTP protocol. |
| static http(String, String...) | Return an absolute URL with HTTP protocol. |
| static httpContinue() | Return a URL, which can be used in combination with an Interaction Continue Node, to continue the user interface flow. |
| static httpHome() | Generates a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the HTTP protocol. |
| static httpImage(String, Object) | Similar to httpStatic( String ) this method returns a static URL for a resource in the current site. |
| static httpImage(String, String, Object) | Similar to httpStatic( String ) this method returns a static URL for a resource in the current site. |
| static httpImage(String, String, String, Object) | Similar to httpStatic( String, String, String ) this method returns a static URL for a resource in the current site. |
| static httpImage(String, String, String, String, Object) | Similar to httpStatic( String, String, String ) this method returns a static URL for a resource in the current site. |
| static httpStatic(String) | The method returns a static URL for a resource in the current site. |
| static httpStatic(String, String) | The method returns a static URL for a resource in the current site. |
| static httpStatic(String, String, String) | Returns the absolute URL to the static location of the specified context. |
| static httpStatic(String, String, String, String) | Returns the absolute URL to the static location of the specified context. |
| Return an absolute web root URL with HTTP protocol and host information from current request. | |
| Return an absolute URL with HTTPS protocol. | |
| Return an absolute URL with HTTPS protocol. | |
| static https(URLAction, URLParameter...) | Return an absolute URL with HTTPS protocol. |
| static https(String, String...) | Return an absolute URL with HTTPS protocol. |
| static httpsContinue() | Return a URL, which can be used in combination with an Interaction Continue Node, to continue the user interface flow. |
| static httpsHome() | Generates a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the HTTPS protocol. |
| static httpsImage(String, Object) | Similar to httpsStatic( String ) this method returns a static URL for a resource in the current site. |
| static httpsImage(String, String, Object) | Similar to httpsStatic( String ) this method returns a static URL for a resource in the current site. |
| static httpsImage(String, String, String, Object) | Similar to httpsStatic( String, String, String ) this method returns a static URL for a resource in the current site. |
| static httpsImage(String, String, String, String, Object) | Similar to httpsStatic( String, String, String ) this method returns a static URL for a resource in the current site. |
| static httpsStatic(String) | The method returns a static URL for a resource in the current site. |
| static httpsStatic(String, String) | The method returns a static URL for a resource in the current site. |
| static httpsStatic(String, String, String) | Returns the absolute URL to the static location of the specified context. |
| static httpsStatic(String, String, String, String) | Returns the absolute URL to the static location of the specified context. |
| Return an absolute web root URL with HTTPS protocol and host and domain information from the current request. | |
| static imageURL(String, Object) | Similar to staticURL( String ) this method returns a static URL for a resource in the current site. |
| static imageURL(String, String, String, Object) | Similar to staticURL( String, String, String ) this method returns a static URL for a resource in the current site. |
| static sessionRedirect(String, URL) | This method is used to create a URL that redirects to a location in the current site with another host name. |
| static sessionRedirectHttpOnly(String, URL) | This method is used to create a URL that redirects to a location in the current site with another host name. |
| static staticURL(String) | The method returns a static URL for a resource in the current site. |
| static staticURL(String, String, String) | Returns the relative URL to the static location of the specified context. |
| Return a relative URL. | |
| Return a relative URL. | |
| static url(URLAction, URLParameter...) | Return a relative URL. |
| static url(String, String...) | Return a relative URL. |
| Return a relative web root URL. |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- CONTEXT_CATALOG: String = "ContextCatalog"
ID for a catalog context. See staticURL() method.
- CONTEXT_LIBRARY: String = "ContextLibrary"
ID for a library context. See staticURL() method.
- CONTEXT_SITE: String = "ContextSite"
ID for a site context (= assigned cartridges). See staticURL() method.
static abs(appendSID: Boolean, action: URLAction, params: URLParameter...): URLReturn an absolute URL with protocol and host from current request.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding abs() method without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID.
- action - URL action
- params - URL parameters
Returns:
- an absolute URL with protocol and host from current request.
Deprecated:
Use abs(URLAction, URLParameter...) instead.
static abs(appendSID: Boolean, action: String, namesAndParams: String...): URLReturn an absolute URL with protocol and host from current request.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding method abs() without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID.
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs, e.g.: 'pid', 'value1', 'cgid', value2'.
Returns:
- an absolute URL with protocol and host from current request.
Deprecated:
Use abs(String, String...) instead.
- static abs(action: URLAction, params: URLParameter...): URL
Return an absolute URL with protocol and host from the current request.
Parameters:
- action - URL action
- params - URL parameters
Returns:
- an absolute URL with protocol and host from the current request.
- static abs(action: String, namesAndParams: String...): URL
Return an absolute URL with protocol and host from current request.
Parameters:
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs, for example: 'pid', 'value1', 'cgid', value2'.
Returns:
- an absolute URL with protocol and host from current request.
- static absImage(relPath: String, transform: Object): URL
Similar to absStatic( String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
Parameters:
- relPath - the relative path of the file
- transform - Object with transformation parameters (see class header)
Returns:
- the URL for the specified image resource
- static absImage(context: String, contextID: String, relPath: String, transform: Object): URL
Similar to absStatic( String, String, String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
- transform - Object with transformation parameters (see class header)
Returns:
- URL for the specified location
- static absStatic(relPath: String): URL
The method returns a static URL for a resource in the current site. Site resources are actually located in the cartridges associated with the site. This resources are typically logos, button images, CSS files and JavaScript files. The method will transform the given relative path to include cache related information, which enables better cache control.
The created URL is an absolute URL with same protocol as the current incoming request.
Note: This method replaces the original mechanisms of using the webroot() method to construct a URL. The new method is better integrated into the overall cache management.
Parameters:
- relPath - the relative path of the file
Returns:
- the URL for the specified location
- static absStatic(context: String, contextID: String, relPath: String): URL
Returns the absolute URL to the static location of the specified context. The context can be either a specific catalog (URLUtils.CONTEXT_CATALOG), a content library (URLUtils.CONTEXT_LIBRARY) or a site (URLUtils.CONTEXT_SITE). Respectively either a URL to images in a catalog, a library or a site are created.
The contextID parameter is optional and only used for context CONTEXT_CATALOG, where is specifies the ID of a specific catalog. If defined, the static URL for the specified catalog is returned. If not defined, the static URL for the current site catalog is returned (or null if no site catalog is defined).
For context CONTEXT_SITE and context CONTEXT_LIBRARY, the contextID parameter is ignored and the static URL for the current site / site library is returned.
Parameter relPath can be defined to specify the relative path within the context-specific path.
The method returns an absolute URL with the same protocol as the current request.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
Returns:
- URL for the specified location
static absWebRoot(): URLReturn an absolute web root URL with protocol and host same as the current request.
Note: The use of this method is deprecated. The method absStatic() should be used instead. It provides better cache integration.
Returns:
- an absolute web root URL with protocol, host from current request.
Deprecated:
Use absStatic(String) or absStatic(String, String, String) instead.
- static continueURL(): URL
Return a URL, which can be used in combination with an Interaction Continue Node, to continue the user interface flow.
Returns:
- an absolute URL with protocol and host from current context request.
- static home(): URL
Generates a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the protocol of the incoming request.
Returns:
- a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the protocol of the incoming request. Uses the default locale of the site making the request.
static http(appendSID: Boolean, action: URLAction, params: URLParameter...): URLReturn an absolute URL with HTTP protocol. If an HTTP host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding http() method without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID.
- action - URL action
- params - URL parameters
Returns:
- an absolute URL with HTTP protocol.
Deprecated:
Use http(URLAction, URLParameter...) instead.
static http(appendSID: Boolean, action: String, namesAndParams: String...): URLReturn an absolute URL with HTTP protocol. If an HTTP host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding http() method without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID.
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs, e.g.: 'pid', 'value1', 'cgid', value2'.
Returns:
- an absolute URL with HTTP protocol.
Deprecated:
Use http(String, String...) instead.
- static http(action: URLAction, params: URLParameter...): URL
Return an absolute URL with HTTP protocol. If an HTTP host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Parameters:
- action - URL action
- params - URL parameters
Returns:
- an absolute URL with HTTP protocol.
- static http(action: String, namesAndParams: String...): URL
Return an absolute URL with HTTP protocol. If an HTTP host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Parameters:
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs, e.g.: 'pid', 'value1', 'cgid', value2'.
Returns:
- an absolute URL with HTTP protocol.
- static httpContinue(): URL
Return a URL, which can be used in combination with an Interaction Continue Node, to continue the user interface flow. For security reasons the httpContinue() function returns a HTTPS continue URL if the interaction flow has started with a HTTPS request. Otherwise a HTTP continue URL is returned. If an HTTP/HTTPS host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Returns:
- an absolute URL with HTTP protocol.
- static httpHome(): URL
Generates a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the HTTP protocol.
Returns:
- a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the HTTP protocol.
- static httpImage(relPath: String, transform: Object): URL
Similar to httpStatic( String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
Parameters:
- relPath - the relative path of the file
- transform - Object with transformation parameters (see class header)
Returns:
- the URL for the specified location
- static httpImage(host: String, relPath: String, transform: Object): URL
Similar to httpStatic( String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
Parameters:
- host - Optional host name, used to set the host explicitly.
- relPath - the relative path of the file
- transform - Object with transformation parameters
Returns:
- the URL for the specified location
- static httpImage(context: String, contextID: String, relPath: String, transform: Object): URL
Similar to httpStatic( String, String, String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
- transform - Object with transformation parameters (see class header)
Returns:
- URL for the specified location
- static httpImage(host: String, context: String, contextID: String, relPath: String, transform: Object): URL
Similar to httpStatic( String, String, String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
Parameters:
- host - Optional host name, used to set the host explicitly.
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
- transform - Object with transformation parameters
Returns:
- URL for the specified location
- static httpStatic(relPath: String): URL
The method returns a static URL for a resource in the current site. Site resources are actually located in the cartridges associated with the site. This resources are typically logos, button images, CSS files and JavaScript files. The method will transform the given relative path to include cache related information, which enables better cache control.
The created URL is an absolute URL with HTTP protocol.
Note: This method replaces the original mechanisms of using the webroot() method to construct a URL. The new method is better integrated into the overall cache management.
Parameters:
- relPath - the relative path of the file
Returns:
- the URL for the specified location
- static httpStatic(host: String, relPath: String): URL
The method returns a static URL for a resource in the current site. Site resources are actually located in the cartridges associated with the site. This resources are typically logos, button images, CSS files and JavaScript files. The method will transform the given relative path to include cache related information, which enables better cache control.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
The created URL is an absolute URL with HTTP protocol.
Note: This method replaces the original mechanisms of using the webroot() method to construct a URL. The new method is better integrated into the overall cache management.
Parameters:
- host - Optional host name, used to set the host explicitly.
- relPath - the relative path of the file
Returns:
- the URL for the specified location
- static httpStatic(context: String, contextID: String, relPath: String): URL
Returns the absolute URL to the static location of the specified context. The context can be either a specific catalog (URLUtils.CONTEXT_CATALOG), a content library (URLUtils.CONTEXT_LIBRARY) or a site (URLUtils.CONTEXT_SITE). Respectively either a URL to images in a catalog, a library or a site are created.
The contextID parameter is optional and only used for context CONTEXT_CATALOG, where is specifies the ID of a specific catalog. If defined, the static URL for the specified catalog is returned. If not defined, the static URL for the current site catalog is returned (or null if no site catalog is defined).
For context CONTEXT_SITE and context CONTEXT_LIBRARY, the contextID parameter is ignored and the static URL for the current site / site library is returned.
Parameter relPath can be defined to specify the relative path within the context-specific path.
The method returns an absolute URL with HTTP protocol.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
Returns:
- URL for the specified location
- static httpStatic(host: String, context: String, contextID: String, relPath: String): URL
Returns the absolute URL to the static location of the specified context. The context can be either a specific catalog (URLUtils.CONTEXT_CATALOG), a content library (URLUtils.CONTEXT_LIBRARY) or a site (URLUtils.CONTEXT_SITE). Respectively either a URL to images in a catalog, a library or a site are created.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
The contextID parameter is optional and only used for context CONTEXT_CATALOG, where is specifies the ID of a specific catalog. If defined, the static URL for the specified catalog is returned. If not defined, the static URL for the current site catalog is returned (or null if no site catalog is defined).
For context CONTEXT_SITE and context CONTEXT_LIBRARY, the contextID parameter is ignored and the static URL for the current site / site library is returned.
Parameter relPath can be defined to specify the relative path within the context-specific path.
The method returns an absolute URL with HTTP protocol.
Parameters:
- host - Optional host name, used to set the host explicitly.
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
Returns:
- URL for the specified location
static httpWebRoot(): URLReturn an absolute web root URL with HTTP protocol and host information from current request. If an HTTP host is configured in the preferences the returned URL will include that host.
Note: The use of this method is deprecated. The method httpStatic() should be used instead. It provides better cache integration.
Returns:
- an absolute web root URL with HTTP protocol and host information from the current request.
Deprecated:
Use the httpStatic(String) or httpStatic(String, String, String) methods instead.
static https(appendSID: Boolean, action: URLAction, params: URLParameter...): URLReturn an absolute URL with HTTPS protocol. If an HTTPS host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding https() method without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID.
- action - URL action
- params - URL parameters
Returns:
- an absolute URL with HTTPS protocol.
Deprecated:
Use the https(URLAction, URLParameter...) method instead.
static https(appendSID: Boolean, action: String, namesAndParams: String...): URLReturn an absolute URL with HTTPS protocol. If an HTTPS host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding https() method without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs, e.g.: 'pid', 'value1', 'cgid', value2'.
Returns:
- an absolute URL with HTTPS protocol.
Deprecated:
Use the https(String, String...) method instead.
- static https(action: URLAction, params: URLParameter...): URL
Return an absolute URL with HTTPS protocol. If an HTTPS host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Parameters:
- action - URL action
- params - URL parameters
Returns:
- an absolute URL with HTTPS protocol.
- static https(action: String, namesAndParams: String...): URL
Return an absolute URL with HTTPS protocol. If an HTTPS host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Parameters:
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs, e.g.: 'pid', 'value1', 'cgid', value2'.
Returns:
- an absolute URL with HTTPS protocol.
- static httpsContinue(): URL
Return a URL, which can be used in combination with an Interaction Continue Node, to continue the user interface flow. An absolute URL with HTTPS protocol is returned. If an HTTPS host is configured in the preferences the returned URL will include that host, otherwise, the host from current request is used.
Returns:
- an absolute URL with HTTPS protocol.
- static httpsHome(): URL
Generates a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the HTTPS protocol.
Returns:
- a hostname-only url if an alias is set, or an url to the Home-Show pipeline in the default format using the HTTPS protocol..
- static httpsImage(relPath: String, transform: Object): URL
Similar to httpsStatic( String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
Parameters:
- relPath - the relative path of the file
- transform - Object with transformation parameters (see class header)
Returns:
- the URL for the specified location
- static httpsImage(host: String, relPath: String, transform: Object): URL
Similar to httpsStatic( String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
Parameters:
- host - Optional host name, used to set the host explicitly.
- relPath - the relative path of the file
- transform - Object with transformation parameters
Returns:
- the URL for the specified location
- static httpsImage(context: String, contextID: String, relPath: String, transform: Object): URL
Similar to httpsStatic( String, String, String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
- transform - Object with transformation parameters (see class header)
Returns:
- URL for the specified location
- static httpsImage(host: String, context: String, contextID: String, relPath: String, transform: Object): URL
Similar to httpsStatic( String, String, String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
Parameters:
- host - Optional host name, used to set the host explicitly.
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
- transform - Object with transformation parameters
Returns:
- URL for the specified location
- static httpsStatic(relPath: String): URL
The method returns a static URL for a resource in the current site. Site resources are actually located in the cartridges associated with the site. This resources are typically logos, button images, CSS files and JavaScript files. The method will transform the given relative path to include cache related information, which enables better cache control.
The created URL is an absolute URL with HTTPS protocol.
Note: This method replaces the original mechanisms of using the webroot() method to construct a URL. The new method is better integrated into the overall cache management.
Parameters:
- relPath - the relative path of the file
Returns:
- the URL for the specified location
- static httpsStatic(host: String, relPath: String): URL
The method returns a static URL for a resource in the current site. Site resources are actually located in the cartridges associated with the site. This resources are typically logos, button images, CSS files and JavaScript files. The method will transform the given relative path to include cache related information, which enables better cache control.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
The created URL is an absolute URL with HTTPS protocol.
Note: This method replaces the original mechanisms of using the webroot() method to construct a URL. The new method is better integrated into the overall cache management.
Parameters:
- host - Optional host name, used to set the host explicitly.
- relPath - the relative path of the file
Returns:
- the URL for the specified location
- static httpsStatic(context: String, contextID: String, relPath: String): URL
Returns the absolute URL to the static location of the specified context. The context can be either a specific catalog (URLUtils.CONTEXT_CATALOG), a content library (URLUtils.CONTEXT_LIBRARY) or a site (URLUtils.CONTEXT_SITE). Respectively either a URL to images in a catalog, a library or a site are created.
The contextID parameter is optional and only used for context CONTEXT_CATALOG, where is specifies the ID of a specific catalog. If defined, the static URL for the specified catalog is returned. If not defined, the static URL for the current site catalog is returned (or null if no site catalog is defined).
For context CONTEXT_SITE and context CONTEXT_LIBRARY, the contextID parameter is ignored and the static URL for the current site / site library is returned.
Parameter relPath can be defined to specify the relative path within the context-specific path.
The method returns an absolute URL with HTTPS protocol.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
Returns:
- URL for the specified location
- static httpsStatic(host: String, context: String, contextID: String, relPath: String): URL
Returns the absolute URL to the static location of the specified context. The context can be either a specific catalog (URLUtils.CONTEXT_CATALOG), a content library (URLUtils.CONTEXT_LIBRARY) or a site (URLUtils.CONTEXT_SITE). Respectively either a URL to images in a catalog, a library or a site are created.
The host parameter is optional. If provided, then this host name will be used in precedence to the host name provided by the current request. The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown.
The contextID parameter is optional and only used for context CONTEXT_CATALOG, where is specifies the ID of a specific catalog. If defined, the static URL for the specified catalog is returned. If not defined, the static URL for the current site catalog is returned (or null if no site catalog is defined).
For context CONTEXT_SITE and context CONTEXT_LIBRARY, the contextID parameter is ignored and the static URL for the current site / site library is returned.
Parameter relPath can be defined to specify the relative path within the context-specific path.
The method returns an absolute URL with HTTPS protocol.
Parameters:
- host - Optional host name, used to set the host explicitly.
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
Returns:
- URL for the specified location
static httpsWebRoot(): URLReturn an absolute web root URL with HTTPS protocol and host and domain information from the current request. If an HTTP host is configured in the preferences the returned URL will include that host.
Note: The use of this method is deprecated. The method httpsStatic() should be used instead. It provides better cache integration.
Returns:
- an absolute web root URL with HTTPS protocol and host information from the current request.
Deprecated:
Use the httpsStatic(String) or httpsStatic(String, String, String) method instead.
- static imageURL(relPath: String, transform: Object): URL
Similar to staticURL( String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
The URL returned is always an absolute URL.
Parameters:
- relPath - the relative path of the file
- transform - Object with transformation parameters (see class header)
Returns:
- the URL for the specified location
- static imageURL(context: String, contextID: String, relPath: String, transform: Object): URL
Similar to staticURL( String, String, String ) this method returns a static URL for a resource in the current site. The method assumes, that the URL refers to an image an supports an additional parameter with optional image transformation parameters. The image transformation parameters must be specified as JavaScript object literal.
The URL returned is always an absolute URL.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id
- relPath - Relative path within the catalog or library
- transform - Object with transformation parameters (see class header)
Returns:
- URL for the specified location
- static sessionRedirect(host: String, url: URL): URL
This method is used to create a URL that redirects to a location in the current site with another host name. When the URL is submitted, the system copies all system cookies, such that user, session and basket information are shared across different hosts.
The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown when submitting the redirect URL.
If the specified host is the same as the current host, the method will return a "normal" URL because no redirect is required.
Parameters:
- host - Target host with or without a site-path
- url - Target URL on current site (relative or absolute), pass null to redirect to new host only
Returns:
- an absolute secure URL to the redirect mechanism
- static sessionRedirectHttpOnly(host: String, url: URL): URL
This method is used to create a URL that redirects to a location in the current site with another host name. When the URL is submitted, the system copies all system cookies, such that user, session and basket information are shared across different hosts.
The specified host name must be defined in the alias settings for the site, otherwise an exception will be thrown when submitting the redirect URL.
If the specified host is the same as the current host, the method will return a "normal" URL because no redirect is required.
Note: since this method generates a non-secure (HTTP) link, no HTTPS Cookies are copied, which might lead to sessions being incorrectly being detected as hijacked. It is strongly recommended to use sessionRedirect(String, URL) where possible.
Parameters:
- host - Target host with or without a site-path
- url - Target URL on current site (relative or absolute), pass null to redirect to new host only
Returns:
- an absolute URL to the redirect mechanism
- static staticURL(relPath: String): URL
The method returns a static URL for a resource in the current site. Site resources are actually located in the cartridges associated with the site. This resources are typically logos, button images, CSS files and JavaScript files. The method will transform the given relative path to include cache related information, which enables better cache control.
The created URL is a relative URL.
Note: This method replaces the original mechanisms of using the webroot() method to construct a URL. The new method is better integrated into the overall cache management.
Parameters:
- relPath - the relative path of the file
Returns:
- the URL for the specified location
- static staticURL(context: String, contextID: String, relPath: String): URL
Returns the relative URL to the static location of the specified context. The context can be either a specific catalog (URLUtils.CONTEXT_CATALOG), a content library (URLUtils.CONTEXT_LIBRARY) or a site (URLUtils.CONTEXT_SITE). Respectively either a URL to images in a catalog, a library or a site are created.
The contextID parameter is optional and can be used with context either CONTEXT_CATALOG or CONTEXT_LIBRARY, where it specifies the ID of a specific catalog or a shared library respectively. If defined, the static URL for the specified catalog/shared library is returned. If not defined, the static URL for the current site catalog/site library is returned (or null if no site catalog/site library is defined).
For context CONTEXT_SITE, the contextID parameter is ignored and the static URL for the current site is returned.
Parameter relPath can be defined to specify the relative path within the context-specific path.
The method returns an relative URL with the same protocol as the current request.
Parameters:
- context - Either CONTEXT_CATALOG, CONTEXT_LIBRARY or CONTEXT_SITE
- contextID - Optional context id, currently only used to specify a catalog id or a shared library id
- relPath - Relative path within the catalog or library or site
Returns:
- URL for the specified location
static url(appendSID: Boolean, action: URLAction, params: URLParameter...): URLReturn a relative URL.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding url() method without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID.
- action - URL action
- params - URL parameters
Returns:
- a relative URL.
Deprecated:
Use url(URLAction, URLParameter...) instead.
static url(appendSID: Boolean, action: String, namesAndParams: String...): URLReturn a relative URL.
Note: The use of this method is deprecated, because session URL rewriting is no longer supported. Use the corresponding url() method without the appendSID parameter instead.
Parameters:
- appendSID - when true the resulting URL will include session ID.
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs, e.g.: 'pid', 'value1', 'cgid', value2'.
Returns:
- a relative URL.
Deprecated:
Use url(String, String...) instead.
- static url(action: URLAction, params: URLParameter...): URL
Return a relative URL.
Parameters:
- action - URL action
- params - URL parameters
Returns:
- a relative URL.
- static url(action: String, namesAndParams: String...): URL
Return a relative URL.
Parameters:
- action - the pipeline, which should be invoked, e.g.: 'Pipeline-StartNode'
- namesAndParams - several strings with name=value pairs , e.g.: 'pid', 'value1', 'cgid', value2'.
Returns:
- a relative URL.
static webRoot(): URLReturn a relative web root URL. A web root URL is used to access all static media context for the site. The actual media file can be referenced by appending a relative path.
Note: The use of this method is deprecated. The method staticURL() should be used instead. It provides better cache integration.
Returns:
- a relative web root URL.
Deprecated:
Use the staticURL(String) or the staticURL(String, String, String) method instead.