Namespace LABKEY.ActionURL
ActionURL static class to supply the current context path, container and action. Additionally, builds a URL from a controller and an action.
Additional Documentation:
Defined in: ActionURL.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
LABKEY.ActionURL.buildURL(controller, action, containerPath, parameters)
Builds a URL from a controller and an action.
|
<static> |
LABKEY.ActionURL.getAction()
Gets the current action
|
<static> |
LABKEY.ActionURL.getBaseURL(noContextPath)
Get the current base URL, which includes context path by default
for example: http://labkey.org/labkey/
|
<static> |
LABKEY.ActionURL.getContainer()
Gets the current (unencoded) container path.
|
<static> |
LABKEY.ActionURL.getContainerName()
Gets the current container's name.
|
<static> |
LABKEY.ActionURL.getContextPath()
Gets the current context path.
|
<static> |
LABKEY.ActionURL.getController()
Get the current controller name
|
<static> |
LABKEY.ActionURL.getParameter(parameterName)
Gets a URL parameter by name.
|
<static> |
LABKEY.ActionURL.getParameterArray(parameterName)
Gets a URL parameter by name.
|
<static> |
LABKEY.ActionURL.getParameters(url)
Returns an object mapping URL parameter names to parameter values.
|
<static> |
LABKEY.ActionURL.queryString(parameters)
Turn the parameter object into a query string (e.g.
|
Method Detail
<static>
{String}
LABKEY.ActionURL.buildURL(controller, action, containerPath, parameters)
Builds a URL from a controller and an action. Uses the current container and context path.
Examples: 1. Build the URL for the 'plotChartAPI' action in the 'reports' controller within the current container: var url = LABKEY.ActionURL.buildURL("reports", "plotChartApi"); 2. Build the URL for the 'getWebPart' action in the 'reports' controller within the current container: var url = LABKEY.ActionURL.buildURL("project", "getWebPart"); 3. Build the URL for the 'updateRows' action in the 'query' controller within the container "My Project/My Folder": var url = LABKEY.ActionURL.buildURL("query", "updateRows", "My Project/My Folder"); 4. Navigate the browser to the study controller's begin action in the current container: window.location = LABKEY.ActionURL.buildURL("study", "begin"); 5. Navigate the browser to the study controller's begin action in the folder "/myproject/mystudyfolder": window.location = LABKEY.ActionURL.buildURL("study", "begin", "/myproject/mystudyfolder"); 6. Navigate to the list controller's insert action, passing a returnUrl parameter that points back to the current page: window.location = LABKEY.ActionURL.buildURL("list", "insert", LABKEY.ActionURL.getContainer(), {listId: 50, returnUrl: window.location});
- Parameters:
- {String} controller
- The controller to use in building the URL
- {String} action
- The action to use in building the URL
- {String} containerPath Optional
- The container path to use (defaults to the current container)
- {Object} parameters Optional
- An object with properties corresponding to GET parameters to append to the URL. Parameters will be encoded automatically. Parameter values that are arrays will be appended as multiple parameters with the same name. (Defaults to no parameters)
- Returns:
- {String} URL constructed from the current container and context path, plus the specified controller and action.
<static>
{String}
LABKEY.ActionURL.getAction()
Gets the current action
- Returns:
- {String} Current action.
<static>
{String}
LABKEY.ActionURL.getBaseURL(noContextPath)
Get the current base URL, which includes context path by default
for example: http://labkey.org/labkey/
- Parameters:
- {boolean} noContextPath Optional
- Set true to omit the context path. Defaults to false.
- Returns:
- {String} Current base URL.
<static>
{String}
LABKEY.ActionURL.getContainer()
Gets the current (unencoded) container path.
- Returns:
- {String} Current container path.
<static>
{String}
LABKEY.ActionURL.getContainerName()
Gets the current container's name. For example, if you are in the
/Project/SubFolder/MyFolder container, this method would return 'MyFolder'
while getContainer() would return the entire path.
- Returns:
- {String} Current container name.
<static>
{String}
LABKEY.ActionURL.getContextPath()
Gets the current context path. The default context path for LabKey Server is '/labkey'.
- Returns:
- {String} Current context path.
<static>
{String}
LABKEY.ActionURL.getController()
Get the current controller name
- Returns:
- {String} Current controller.
<static>
{String}
LABKEY.ActionURL.getParameter(parameterName)
Gets a URL parameter by name. Note that if the given parameter name is present more than once
in the query string, the returned value will be the first occurance of that parameter name. To get all
instances of the parameter, use getParameterArray().
- Parameters:
- {String} parameterName
- The name of the URL parameter.
- Returns:
- {String} The value of the named parameter, or undefined of the parameter is not present.
<static>
LABKEY.ActionURL.getParameterArray(parameterName)
Gets a URL parameter by name. This method will always return an array of values, one for
each instance of the parameter name in the query string. If the parameter name appears only once
this method will return a one-element array.
- Parameters:
- {String} parameterName
- The name of the URL parameter.
<static>
{Object}
LABKEY.ActionURL.getParameters(url)
Returns an object mapping URL parameter names to parameter values. If a given parameter
appears more than once on the query string, the value in the map will be an array instead
of a single value. Use LABKEY.Utils.isArray() to determine if the value is an array or not, or use
getParameter() or getParameterArray() to retrieve a specific parameter name as a single value
or array respectively.
- Parameters:
- {String} url Optional
- The URL to parse. If not specified, the browser's current location will be used.
- Returns:
- {Object} Map of parameter names to values.
<static>
LABKEY.ActionURL.queryString(parameters)
Turn the parameter object into a query string (e.g. {x:'fred'} -> "x=fred").
The returned query string is not prepended by a question mark ('?').
- Parameters:
- {Object} parameters Optional
- An object with properties corresponding to GET parameters to append to the URL. Parameters will be encoded automatically. Parameter values that are arrays will be appended as multiple parameters with the same name. (Defaults to no parameters.)