There are a few @Functions for working with URLs available in the Extension library. They can come in handy if you need to work with URLs related to any element in your database.
Availability
These functions are part of the extension library. They’re available if you’ve installed the Extension Library, or if you have Upgrade Pack 1 for 8.5.3. They’re also part of the extension library features built directly into Notes9.
@FunctionsEx
The functions are available on the Reference tab in the SSJS Script Editor. Under Libraries
, select @FunctionsEx
to see the additional functions.
The following URL functions are available:
- @EncodeUrl() – Encodes spaces and symbols in the URL
- @FullUrl() – Displays the full path to a resource in the database (relative to the server)
- @AbsoluteUrl() – Displays the absolute path to a resource in the database*
- @IsAbsoluteUrl() – Boolean value for whether a given URL is absolute
Examples
Here are some examples of how they can be used in an application:
Code | Result |
---|---|
@FullUrl(view.getPageName()) | /BlogTesting.nsf/ExtLibURLFormulas.xsp |
@AbsoluteUrl(view.getPageName()) | http://127.0.0.2/ExtLibURLFormulas.xsp |
@EncodeUrl(context.getUrl().toString()); Where the url is: http://127.0.0.2/BlogTesting.nsf/ExtLibURLFormulas.xsp?my_Parameter=spaces and $ymbol$ |
http://127.0.0.2/BlogTesting.nsf/ExtLibURLFormulas.xsp?my_Parameter=spaces+and+%24ymbol%24 |
@IsAbsoluteUrl(view.getPageName()) | false |
@IsAbsoluteUrl(context.getUrl().toString()) | true |
*@AbsoluteUrl
I generally use context.getUrl()
and work with that to parse and build URLs, so I haven’t run into this before, but the output of @AbsoluteUrl() wasn’t what I expected. At first glance, it appeared to give the full url to the specified design element, but it actually just gives the protocol, server, and design element name that was supplied.
It looks like I can get the real absolute url to the design element by combining @FullUrl() with @AbsoluteUrl()
Code | Result |
---|---|
@AbsoluteURL(@FullUrl(view.getPageName())) | http://127.0.0.2/BlogTesting.nsf/ExtLibURLFormulas.xsp |
