on 10-21-2015 9:34 AM
Hello guys i have been following tutorial at SAPUI5 SDK - Demo Kit . I got stuck at Routing with parameter. That should be navigate to detail after i press list item. Debug tools F12 from chrome says
Uncaught Error: Invalid value "Invoices/0" for segment "{invoicePath}".
What should i do to get it right?
Best Regards
Hi Yoppie,
I have encountered same issue and following is the solution.
・controller Detail
_onObjectMatched: function (oEvent) {
this.getView().bindElement({
path: decodeURIComponent("/" + oEvent.getParameter("arguments").invoicePath),
model: "invoice"
});
}
・controller InvoiceList
oRouter.navTo("detail", {
invoicePath: encodeURIComponent(oItem.getBindingContext("invoice").getPath().substr(1))
});
Best regards,
Susumu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Susumu,
best answer so far. Little improvment: You dont have to cut off and readd the first slash. because decoding and encoding will work on every slash in the path:
・controller Detail
_onObjectMatched: function (oEvent) {
this.getView().bindElement({
path: decodeURIComponent(oEvent.getParameter("arguments").invoicePath),
model: "invoice"
});
}
・controller InvoiceList
oRouter.navTo("detail", {
invoicePath: encodeURIComponent(oItem.getBindingContext("invoice").getPath())
});
You cannot pass Forward slash '/' in your parameters. Since, it is reserved and will not be encoded.
Check the below link for more Info about special characters which are not allowed in parameters of .navTo
JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.core.routing.Router
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I resolved removing "/" in the invoicePath and adding again in Detail controller:
controller InvoiceList
oRouter.navTo("detail", {
invoicePath: oItem.getBindingContext("invoice").getPath().substr(1).replace(/\//,".")
});
-------------------------------------------
controller Detail
_onObjectMatched: function(oEvent) {
this.getView().bindElement({
path: "/" + oEvent.getParameter("arguments").invoicePath.replace(/\./,"/"),
model: "invoice"
});
},
Hi Yoppie,
Route:
{
pattern: "Product/{productId}",
name: "ProductDetails",
target: "productDetails"
}
Follow this pattern in component.js
For Navigation:
this._oRouter.navTo("ProductDetails", {
productId: encodeURIComponent(oEvent.getSource().getBindingContext().getProperty("Id"))
}, false);
Try this method
Regards,
Karthik A
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.