Class sap.ushell.services.CrossApplicationNavigationModule: sap/ushell/services/CrossApplicationNavigation



Since: 1.15.0.
Constructor Summary
new sap.ushell.services.CrossApplicationNavigation()The Unified Shell's CrossApplicationNavigation service, which allows to navigate to external targets or create links to external targets

This method MUST be called by the Unified Shell's container only, others MUST call sap.ushell.Container.getService("CrossApplicationNavigation").

Method Summary
backToPreviousApp()using the browser history, this invocation attempts to navigate back to the previous application This functionality simply performs a browser back today.
expandCompactHash(sHashFragment)if sHashFragment is a compacted hash (sap-intent-param is present), in a hash, this function replaces it into a long url with all parameters expanded
getDistinctSemanticObjects()Returns a list of semantic objects of the intents the current user can navigate to.
getLinks(vArgs?)Resolves the given semantic object (or action) and business parameters to a list of links available to the user
historyBack()performs window.history.back() if supported by the underlying platform.
hrefForAppSpecificHash(sAppHash)Returns a string which can be put into the DOM (e.g.
hrefForExternal(oArgs, oComponent?, bAsync)Returns a string which can be put into the DOM (e.g.
isInitialNavigation()Checks whether the FLP has performed the first navigation.
isIntentSupported(aIntents, oComponent?)Tells whether the given intent(s) are supported, taking into account the form factor of the current device.
isNavigationSupported(aIntents, oComponent?)Tells whether the given navigation intent(s) are supported for the given parameters, form factor etc "Supported" means that a valid navigation target is configured for the user for the given device.
toExternal(oArgs, oComponent?)Navigate to an specified external target (e.g.
getSemanticObjectLinks(sSemanticObject, mParameters?, bIgnoreFormFactor?, oComponent?, sAppStateKey?, bCompactIntents?)Resolves a given semantic object and business parameters to a list of links, taking into account the form factor of the current device.
Constructor Detail
new sap.ushell.services.CrossApplicationNavigation()
The Unified Shell's CrossApplicationNavigation service, which allows to navigate to external targets or create links to external targets

This method MUST be called by the Unified Shell's container only, others MUST call sap.ushell.Container.getService("CrossApplicationNavigation"). Constructs a new instance of the CrossApplicationNavigation service.

CrossApplicationNavigation currently provides platform independent functionality.

This interface is for usage by applications or shell renderers/containers.

Usage:

example: see demoapps/AppNavSample/MainXML.controller.js

var xnavservice = sap.ushell && sap.ushell.Container && sap.ushell.Container.getService;
&& sap.ushell.Container.getService("CrossApplicationNavigation");
var href = ( xnavservice && xnavservice.hrefForExternal({
target : { semanticObject : "Product", action : "display" },
params : { "ProductID" : "102343333" }
})) || "";

Parameter names and values are case sensitive.

Note that the usage of multi-valued parameters (specifying an array with more than one member as parameter value, e.g. params : { A : ["a1", "a2"] } ) is possible with this API but strongly discouraged. Especially the navigation target matching performed at the back-end is not supported for multi-value parameters. Furthermore, it is not guaranteed that additional parameter values specified in the back-end configuration are merged with parameter values passed in this method.

Note that the application parameter length (including SemanticObject/Action) shall not exceed 512 bytes when serialized as UTF-8

Note that when receiving the values as startup parameters (as part of the component data object) single values are represented as an array of size 1. Above example is returned as deepEqual(getComponentData().startupParameters , { "ProductID" : [ "102343333" ] } )

Make sure not to store security critical data within an URL URLs may appear in a server log, be persisted inside and outside the system.

Note: When constructing large URLs, the URLs may be shortened and persisted on a database server for prolonged time, the actual data is persisted under a key accessible to any User (guessing the key).

The same restrictions apply for the Application state

See:
sap.ushell.services.Container#getService
Method Detail
backToPreviousApp()
using the browser history, this invocation attempts to navigate back to the previous application This functionality simply performs a browser back today. Its behaviour is subject to change. It may not yield the expected result esp. on mobile devices where "back" is the previous inner app state iff these are put into the history!
expandCompactHash(sHashFragment): object
if sHashFragment is a compacted hash (sap-intent-param is present), in a hash, this function replaces it into a long url with all parameters expanded
Parameters:
{string}sHashFragment an (internal format) shell hash
Returns:
{object} promise the success handler of the resolve promise get an expanded shell hash as first argument
getDistinctSemanticObjects(): jQuery.Deferred.promise
Returns a list of semantic objects of the intents the current user can navigate to.
Since:
1.38.0
Returns:
{jQuery.Deferred.promise} A promise that resolves with an array of strings representing the semantic objects of the intents the current user can navigate to, or rejects with an error message. The returned array will not contain duplicates.

NOTE: the caller should not rely on the specific order the semantic objects appear in the returned array.

getLinks(vArgs?): jQuery.Deferred.promise
Resolves the given semantic object (or action) and business parameters to a list of links available to the user
Parameters:
{object|object[]}vArgs? An object containing nominal arguments for the method, having the following structure:
  {
     semanticObject: "Object", // optional, matches any semantic
                               // objects if undefined

     action: "action",         // optional, matches any actions if
                               // undefined

     params: {                 // optional business parameters
        A: "B",
        C: ["e", "j"]
     },
     withAtLeastOneUsedParam: true, // optional, defaults to false. If
                                    // true, only the links that use
                                    // at least one (non sap-) parameter
                                    // from 'params' will be returned.
     treatTechHintAsFilter : true, // optional, defaults to false
                                   // if true, only apps that match
                                   // exactly the supplied technology
                                   // (e.g. sap-ui-tech-hint=WDA) will be considered

     ui5Component: UI5Component, // mandatory, the UI5 component
                                 // invoking the service, shall be a root component!

     appStateKey: "abc123...",   // optional, application state key
                                 // to add to the generated links,
                                 // SAP internal usage only

     compactIntents: true        // optional, whether intents
                                 // should be returned in compact
                                 // format. Defaults to false.
     ignoreFormFactor: true,   // optional, defaults to false, deprecated, do not use, may have no effect in the future
  }
  

This method supports a mass invocation interface to obtain multiple results with a single call, as shown in the following example:

     oCrossApplicationService.getLinks([ // array, because multiple invocations are to be made
        [                           // arguments for the first invocation
          { semanticObject: "SO" }  // this method supports one parameter only in each call
        ],
        [                           // arguments for the second invocation
          { action: "someAction" }
        ]
        // ... and so on
    ]);
  

Calling this method with no arguments will produce the same result as if the method was called with an empty object.

Since:
1.38.0
Returns:
{jQuery.Deferred.promise} A promise that resolves with an array of links objects containing (at least) the following properties:

  {
     intent: "#AnObject-Action?A=B&C=e&C=j",
     text: "Perform action"
  }

NOTE: the intents returned are in internal format and cannot be directly put into a link tag.

Example: Let the string "C&A != H&M" be a parameter value.

Intent will be encoded as#AnObject-action?text=C%26A%20!%3D%20H%26M. Note that the intent is in internal format, before putting it into a link tag, you must invoke: externalHash = oCrossApplicationNavigationService.hrefForExternal({ target : { shellHash : oLink.intent} }, that.oComponent);

NOTE: in case the mass invocation interface is used (see vArgs parameter explanation above), the promise will resolve to an array of arrays of arrays. For example, if the mass interface specified two arguments, the promise would resolve as follows:

  [     // mass interface was used, so return multiple values
     [  // values returned from the first call (functions may return multiple values)

        // value returned from first getLinks call (as returned by single getLinks call)
        [
          {intent: "#SO-something1", text: "Perform navigation"},
          {intent: "#SO-something2", text: "Perform action"} ],
        ]
     ],
     [

        // value returned from second getLinks call (as returned by single getLinks call)
        [
          {intent: "#Object-someAction", text: "Some action1"}
        ]
     ]
     // ... and so on
  ]
  
historyBack()
performs window.history.back() if supported by the underlying platform. May be a noop if the url is the first url in the browser.
hrefForAppSpecificHash(sAppHash): string
Returns a string which can be put into the DOM (e.g. in a link tag) given an application specific hash suffix

Example: hrefForAppSpecificHash("View1/details/0/") returns #SemanticObject-action&/View1/details/0/ if the current application runs in the shell and was started using "SemanticObject-action" as shell navigation hash

Parameters:
{string}sAppHash the app specific router, obtained e.g. via router.getURL(...)
Since:
1.15.0
Returns:
{string} A string which can be put into the link tag, containing the current shell navigation target and the specified application specific hash suffix

Note that sAppHash shall not exceed 512 bytes when serialized as UTF-8

hrefForExternal(oArgs, oComponent?, bAsync): string
Returns a string which can be put into the DOM (e.g. in a link tag)
Parameters:
{object}oArgs object encoding a semantic object and action e.g.
 {
    target : { semanticObject : "AnObject", action: "action" },
    params : { A : "B" }
 }
 
or e.g.
 {
    target : {
       semanticObject : "AnObject",
       action: "action", context  : "AB7F3C"
    },
    params : {
       A : "B",
       c : "e"
    }
 }
 
or
 {
    target : { shellHash : "SO-36&jumper=postman" }
 }
 
{object}oComponent? the root component of the application
{bool}bAsync if set to true, a promise will be returned instead of the direct argument. The promise will only succeed after all compaction requests have been sent
Since:
1.15.0
Returns:
{string} the href for the specified parameters; always starting with a hash character; all parameters are URL-encoded (via encodeURIComponent)

A proper way for an application to generate a link to return to the home page of the Fiori launchpad is : hrefForExternal( { target : { shellHash : "#" }})

Do *not* use "#Shell-home" to navigate to a specific homepage!

Note that the application parameter length (including SemanticObject/Action) shall not exceed 512 bytes when serialized as UTF-8.

The function can be used to convert an shell hash internal format commonly encountered into the URL format to use in link tags:

externalHash = oCrossApplicationNavigationService.hrefForExternal({
    target: {
        shellHash: oLink.intent
    }
}, that.oComponent);
isInitialNavigation(): boolean
Checks whether the FLP has performed the first navigation. This method can be used to detect whether the current app was started directly, that is, without a previous navigation to another app, to the FLP home, or another target that adds an entry in the browser history.
Since:
1.36.0
Returns:
{boolean} Whether the initial navigation occurred.
isIntentSupported(aIntents, oComponent?): object
Tells whether the given intent(s) are supported, taking into account the form factor of the current device. "Supported" means that navigation to the intent is possible. Note that the intents are assumed to be in internal format and expanded.
Parameters:
{string[]}aIntents the intents (such as ["#AnObject-action?A=B&c=e"]) to be checked
{object}oComponent? the root component of the application
Since:
1.19.1
Returns:
{object} A jQuery.Deferred object's promise which is resolved with a map containing the intents from aIntents as keys. The map values are objects with a property supported of type boolean.
Example:
  {
    "#AnObject-action?A=B&c=e": { supported: false },
    "#AnotherObject-action2": { supported: true }
  }
Example usage: this.oCrossAppNav.isIntentSupported(["SalesOrder-approve?SOId=1234"]) .done(function(aResponses) { if (oResponse["SalesOrder-approve?SOId=1234"].supported===true){ // enable link } else { // disable link } }) .fail(function() { // disable link // request failed or other error }); * @deprecated switch to isNavigationSupported Note that this has a slightly different response format
isNavigationSupported(aIntents, oComponent?): object
Tells whether the given navigation intent(s) are supported for the given parameters, form factor etc "Supported" means that a valid navigation target is configured for the user for the given device.

This is effectively a test function for toExternal/ hrefForExternal. It is functionally equivalent to isIntentSupported but accepts the same interface as toExternal/ hrefForExternal.

Parameters:
{object[]}aIntents the intents (such as ["#AnObject-action?A=B&c=e"]) to be checked with object being instances the oArgs object of toExternal, hrefForExternal etc.

e.g. { target: { semanticObject: "AnObject", action: "action" }, params: { A: "B" } } or e.g. { target: { semanticObject: "AnObject", action: "action" }, params: { A: "B", c: "e" } } or { target: { shellHash: "SO-36&jumper=postman" }, }

{object}oComponent? the root component of the application
Since:
1.32
Returns:
{object} A jQuery.Deferred object's promise which is resolved with an array (!) of objects representing whether the intent is supported or not objects with a property supported of type boolean.
representing Example:

aIntents:

 [
   {  target : {
         semanticObject : "AnObject",
         action: "action"
      },
      params : { P1 : "B", P2 : [ "V2a", "V2b"]  }
   },
   {  target : {
         semanticObject : "SalesOrder",
         action: "display"
      },
      params : { P3 : "B", SalesOrderIds : [ "4711", "472"] }
   }
]

response: [Indices correspond]

[
  { supported: false },
  { supported: true }
]
Example usage: this.oCrossAppNav.isNavigationSupported([ ]) .done(function(aResponses) { if (oResponse[0].supported===true){ // enable link } else { // disable link } }) .fail(function() { // disable link // request failed or other fatal error });
toExternal(oArgs, oComponent?)
Navigate to an specified external target (e.g. different launchpad application) Invocation will trigger an hash change and subsequent invocation of the application.

If the navigation target opens in a new window the running application may be retained.

Parameters:
{Object}oArgs configuration object describing the target

e.g. { target : { semanticObject : "AnObject", action: "action" },
params : { A : "B" } }
constructs sth. like #AnObject-action?A=B&C=e&C=j; or e.g. { target : { semanticObject : "AnObject", action: "action", context : "AB7F3C" },
params : { A : "B", c : "e" } }
or { target : { shellHash : "SO-36&jumper=postman" }, }

and navigate to it via changing the hash

A proper way for an application to generate a link to return to the home page of the Fiori launchpad is: hrefForExternal( { target : { shellHash : "#" }})

Do *not* use "#Shell-home" or "Shell-home" to navigate to a specific homepage!

The actual navigation may occur deferred!

Note that the application parameter length (including SemanticObject/Action) shall not exceed 512 bytes when serialized as utf-8

{object}oComponent? an optional SAP UI5 Component,
Since:
1.15.0
getSemanticObjectLinks(sSemanticObject, mParameters?, bIgnoreFormFactor?, oComponent?, sAppStateKey?, bCompactIntents?): object
Resolves a given semantic object and business parameters to a list of links, taking into account the form factor of the current device.
Parameters:
{string}sSemanticObject the semantic object such as "AnObject"
{object}mParameters? the map of business parameters with values, for instance
  {
    A: "B",
    c: "e"
  }
  
{boolean}bIgnoreFormFactor? when set to true the form factor of the current device is ignored
{Object}oComponent? SAP UI5 Component invoking the service
{string}sAppStateKey? application state key to add to the generated links, SAP internal usage only
{boolean}bCompactIntents? whether the returned intents should be returned in compact format. Defaults to false.
Deprecated:
since version 1.38.0 use getLinks
Since:
1.19.0
Returns:
{object} A jQuery.Deferred object's promise which is resolved with an array of link objects containing (at least) the following properties:
{
  intent: "#AnObject-action?A=B&C=e",
  text: "Perform action"
}

NOTE: the intents returned are in internal format and cannot be directly put into a link tag.

Example: Let the string "C&A != H&M" be a parameter value. Intent will be encoded as#AnObject-action?text=C%26A%20!%3D%20H%26M. Note that the intent is in internal format, before putting it into a link tag, you must invoke: externalHash = oCrossApplicationNavigationService.hrefForExternal({ target : { shellHash : oLink.intent} }, that.oComponent);