在控制器中获取语义对象和语义动作
Get semantic object and semantic action in controller
我正在尝试获取已部署的 SAPUI5 应用程序的语义对象和语义操作。我尝试查看 ushell 服务 - URLParsing 和 LaunchPage,但它似乎 return 我的语义对象和操作。
有人试过吗?
你总是可以只使用
window.location.hash
您可以很容易地自行解析。如果你真的想要启动板代码,你通常可以在这里找到它:
sap.ushell.services.AppConfiguration.getCurrentApplication().sShellHash
我注意到当您查看嵌入式组件时并不总是设置它
一个简单的方法是:
var oHashObject = new sap.ui.core.routing.HashChanger();
oHashObject.getHash();
//this will return the semantic object and action alongwith the routing params
到目前为止这对我有用:
sap.ui.require([ // modules lazily instead of accessing them with global names.
"sap/ushell/library", // Consider adding `"sap.ushell": { lazy: true }` to dependencies in manifest.json
"sap/ui/core/routing/HashChanger",
], async (sapUshellLib, HashChanger) => {
const fullHash = new HashChanger().getHash(); // returns e.g. "masterDetail-display?sap-ui-theme=sap_fiori_3&/product/HT-1000"
const urlParsing = await sapUshellLib.Container.getServiceAsync("URLParsing");
urlParsing.parseShellHash(fullHash); /** returns e.g. {
action: "display",
appSpecificRoute: "&/product/HT-1000",
contextRaw: undefined,
params: { "sap-ui-theme": "sap_fiori_3" },
semanticObject: "masterDetail"
} **/
});
我正在尝试获取已部署的 SAPUI5 应用程序的语义对象和语义操作。我尝试查看 ushell 服务 - URLParsing 和 LaunchPage,但它似乎 return 我的语义对象和操作。
有人试过吗?
你总是可以只使用
window.location.hash
您可以很容易地自行解析。如果你真的想要启动板代码,你通常可以在这里找到它:
sap.ushell.services.AppConfiguration.getCurrentApplication().sShellHash
我注意到当您查看嵌入式组件时并不总是设置它
一个简单的方法是:
var oHashObject = new sap.ui.core.routing.HashChanger();
oHashObject.getHash();
//this will return the semantic object and action alongwith the routing params
到目前为止这对我有用:
sap.ui.require([ // modules lazily instead of accessing them with global names.
"sap/ushell/library", // Consider adding `"sap.ushell": { lazy: true }` to dependencies in manifest.json
"sap/ui/core/routing/HashChanger",
], async (sapUshellLib, HashChanger) => {
const fullHash = new HashChanger().getHash(); // returns e.g. "masterDetail-display?sap-ui-theme=sap_fiori_3&/product/HT-1000"
const urlParsing = await sapUshellLib.Container.getServiceAsync("URLParsing");
urlParsing.parseShellHash(fullHash); /** returns e.g. {
action: "display",
appSpecificRoute: "&/product/HT-1000",
contextRaw: undefined,
params: { "sap-ui-theme": "sap_fiori_3" },
semanticObject: "masterDetail"
} **/
});