Class sap.ui.generic.app.navigation.service.NavigationHandlerModule: sap/ui/generic/app/navigation/service/NavigationHandler
Creates a new NavigationHandler class by providing the required environment.
Note: This class requires that the UShell Navigation Service API CrossApplicationNavigation is available and initialized.
sClassName
and enriches it with the information contained in oClassInfo
.{object} | oController | UI5 controller that contains a router and a component; typically the main controller of your application, for example, a subclass of the sap.ca.scfld.md.controller.BaseFullscreenController if scaffolding is used |
{string} | sParamHandlingMode?, Default: SelVarWins | Mode to be used to handle conflicts when merging URL parameters and the SelectionVariant class, see sap.ui.generic.app.navigation.service.ParamHandlingMode |
- Exceptions:
- An instance of sap.ui.generic.app.navigation.service.NavError in case of input errors. Valid error codes are:
Error code Description NavigationHandler.INVALID_INPUT Indicates that the input parameter is invalid
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.base.Object.extend.
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
{object} | mSemanticAttributes | Object containing key/value pairs |
{string} | sSelectionVariant | The selection variant in string format as provided by the SmartFilterBar control |
{integer} | iSuppressionBehavior?, Default: sap.ui.generic.app.navigation.service.SuppressionBehavior.standard | Indicates whether semantic attributes with special values (see suppression behavior) must be suppressed before they are combined with the selection variant; several suppression behaviors can be combined with the bitwise OR operator (|) |
var mSemanticAttributes = { "Customer" : "C0001" };
var sSelectionVariant = oSmartFilterBar.getDataSuiteFormat();
var oNavigationHandler = new sap.ui.generic.app.navigation.service.NavigationHandler(oController);
var sNavigationSelectionVariant = oNavigationHandler.mixAttributesAndSelectionVariant(mSemanticAttributes, sSelectionVariant).toJSONString();
// Optionally, you can specify one or several suppression behaviors. Several suppression behaviors are combined with the bitwise OR operator, e.g.
// var iSuppressionBehavior = sap.ui.generic.app.navigation.service.SuppressionBehavior.raiseErrorOnNull | sap.ui.generic.app.navigation.service.SuppressionBehavior.raiseErrorOnUndefined;
// var sNavigationSelectionVariant = oNavigationHandler.mixAttributesAndSelectionVariant(mSemanticAttributes, sSelectionVariant, iSuppressionBehavior).toJSONString();
oNavigationHandler.navigate("SalesOrder", "create", sNavigationSelectionVariant);
{object} | Instance of sap.ui.generic.app.navigation.service.SelectionVariant |
{string} | sSemanticObject | Name of the semantic object of the target app | ||||||||||||
{string} | sActionName | Name of the action of the target app | ||||||||||||
{object|string} | vNavigationParameters? | Navigation parameters as an object with key/value pairs or as a stringified JSON object | ||||||||||||
{object} | oInnerAppData? | Object for storing current state of the app | ||||||||||||
{string} | oInnerAppData.selectionVariant? | Stringified JSON object as returned, for example, from getDataSuiteFormat() of the SmartFilterBar control | ||||||||||||
{string} | oInnerAppData.tableVariantId? | ID of the SmartTable variant | ||||||||||||
{object} | oInnerAppData.customData? | Object that can be used to store arbitrary data | ||||||||||||
{function} | fnOnError? | Callback that is called if an error occurs during navigation Parameters:
|
var oNavigationHandler = new sap.ui.generic.app.navigation.service.NavigationHandler(oController);
var sSemanticObject = "SalesOrder";
var sActionName = "create";
//simple parameters as Object
var vNavigationParameters = {
CompanyCode : "0001",
Customer : "C0001"
};
//or as selection variant
var oSelectionVariant = new sap.ui.generic.app.navigation.service.SelectionVariant();
oSelectionVariant.addSelectOption("CompanyCode", "I", "EQ", "0001");
oSelectionVariant.addSelectOption("Customer", "I", "EQ", "C0001");
vNavigationParameters = oSelectionVariant.toJSONString();
//or directly from SmartFilterBar
vNavigationParameters = oSmartFilterBar.getDataSuiteFormat();
//app state for back navigation
var oInnerAppData = {
selectionVariant : oSmartFilterBar.getDataSuiteFormat(),
tableVariantId : oSmartTable.getCurrentVariantId(),
customData : oMyCustomData
};
// callback function in case of errors
var fnOnError = function(oError){
var oi18n = oController.getView().getModel("i18n").getResourceBundle();
oError.setUIText({oi18n : oi18n, sTextKey : "OUTBOUND_NAV_ERROR"});
oError.showMessageBox();
};
oNavigationHandler.navigate(sSemanticObject, sActionName, vNavigationParameters, oInnerAppData, fnOnError);
var oNavigationHandler = new sap.ui.generic.app.navigation.service.NavigationHandler(oController);
var oParseNavigationPromise = oNavigationHandler.parseNavigation();
oParseNavigationPromise.done(function(oAppData, oStartupParameters, sNavType){
oSmartFilterBar.setDataSuiteFormat(oAppData.selectionVariant);
// oAppData.oSelectionVariant can be used to manipulate the selection variant
// oAppData.oDefaultedSelectionVariant contains the parameters which are set by user defaults
// oAppData.bNavSelVarHasDefaultsOnly indicates whether only defaulted parameters and no navigation parameters are present
});
oParseNavigationPromise.fail(function(oError, oURLParameters, sNavType){
// if e.g. the xapp state could not be loaded, nevertheless there may be URL parameters available
//some error handling
});
{object} | A Promise object to monitor when all the actions of the function have been executed. If the execution is successful, the extracted app state, the startup parameters, and the type of navigation are returned, see also the example above. The app state is an object that contains the following information:
The navigation type is an enumeration type of type sap.ui.generic.app.navigation.service.NavType (possible values are initial, URLParams, xAppState, and iAppState). Note: If the navigation type is sap.ui.generic.app.navigation.service.NavType.iAppState oAppData has two additional properties
oAppData.oDefaultedSelectionVariant is an empty selection variant and oAppData.bNavSelVarHasDefaultsOnly is false in this case.Note: If the navigation type is sap.ui.generic.app.navigation.service.NavType.initial oAppData is an empty object! If an error occurs, an error object of type sap.ui.generic.app.navigation.service.NavError, URL parameters (if available) and the type of navigation are returned. |
- If
mInnerAppData
is provided, this inner app state is saved for back navigation at a later time. - The table event parameters (semantic attributes) and the selection variant data are combined by calling the method mixAttributesAndSelectionVariant.
- The combined data is saved as the cross app state to be handed over to the target app, and the corresponding sap-xapp-state key is set in the URL.
- All single selections ("including equal") of the combined selection data are passed to the SmartLink popover as semantic attributes.
- The method
oTableEventParameters.open()
is called. Note that this does not really open the popover, but the SmartLink control proceeds with firing the eventnavigationTargetsObtained
.
{object} | oTableEventParameters | The parameters made available by the SmartTable control when the SmartLink control has been clicked, an instance of a PopOver object |
{string} | sSelectionVariant | Stringified JSON object as returned, for example, from getDataSuiteFormat() of the SmartFilterBar control |
{object} | mInnerAppData? | Object containing the current state of the app. If provided, opening the Popover is deferred until the inner app data is saved in a consistent way. |
{string} | mInnerAppData.selectionVariant? | Stringified JSON object as returned, for example, from getDataSuiteFormat() of the the SmartFilterBar control; if provided, the selection is merged into the semantic attributes |
{string} | mInnerAppData.tableVariantId? | ID of the SmartTable variant |
{object} | mInnerAppData.customData? | Object that can be used to store additional app-specific data |
//event handler for the smart link event "beforePopoverOpens"
onBeforePopoverOpens: function(oEvent) {
var oTableEventParameters = oEvent.getParameters();
var mInnerAppData = {
selectionVariant : oSmartFilterBar.getDataSuiteFormat(),
tableVariantId : oSmartTable.getCurrentVariantId(),
customData : oMyCustomData
};
var oSelectionVariant = new sap.ui.generic.app.navigation.service.SelectionVariant();
oSelectionVariant.addSelectOption("CompanyCode", "I", "EQ", "0001");
oSelectionVariant.addSelectOption("Customer", "I", "EQ", "C0001");
var sSelectionVariant= oSelectionVariant.toJSONString();
var oNavigationHandler = new sap.ui.generic.app.navigation.service.NavigationHandler(oController);
var oSmartLinkPromise = oNavigationHandler.processBeforeSmartLinkPopoverOpens(oTableEventParameters, sSelectionVariant, mInnerAppData);
oSmartLinkPromise.done(function(oTableEventParameters){
// here you can add coding that should run after all app states are saved and the semantic attributes are set
});
oSmartLinkPromise.fail(function(oError){
//some error handling
});
};
{object} | A Promise object to monitor when all actions of the function have been executed; if the execution is successful, the modified oTableEventParameters is returned; if an error occurs, an error object of type sap.ui.generic.app.navigation.service.NavError is returned |
{object} | mInnerAppData | Object containing the current state of the app |
{string} | mInnerAppData.selectionVariant | Stringified JSON object as returned, for example, from getDataSuiteFormat() of the SmartFilterBar control |
{string} | mInnerAppData.tableVariantId? | ID of the SmartTable variant |
{object} | mInnerAppData.customData? | Object that can be used to store additional app-specific data |
{boolean} | bImmediateHashReplace?, Default: true | If set to false, the inner app hash will not be replaced until storing is successful; do not set to false if you cannot react to the resolution of the Promise, for example, when calling the beforeLinkPressed event |
var oNavigationHandler = new sap.ui.generic.app.navigation.service.NavigationHandler(oController);
var mInnerAppData = {
selectionVariant : oSmartFilterBar.getDataSuiteFormat(),
tableVariantId : oSmartTable.getCurrentVariantId(),
customData : oMyCustomData
};
var oStoreInnerAppStatePromise = oNavigationHandler.storeInnerAppState(mInnerAppData);
oStoreInnerAppStatePromise.done(function(sAppStateKey){
//your inner app state is saved now, sAppStateKey was added to URL
//perform actions that must run after save
});
oStoreInnerAppStatePromise.fail(function(oError){
//some error handling
});
{object} | A Promise object to monitor when all the actions of the function have been executed; if the execution is successful, the app state key is returned; if an error occurs, an object of type sap.ui.generic.app.navigation.service.NavError is returned |