Skip to Content

Routing with Parameter SAP Web IDE

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

temp.png (165.8 kB)
temp.png (37.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 15, 2015 at 01:59 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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())

      });

  • Oct 21, 2015 at 08:56 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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