Skip to Content

Need help with local storage and indexeddb

I am following the blog "Going offline with SAP UI5" but I am getting the following error

Uncaught DOMException: Failed to execute 'add' on 'IDBObjectStore': The object store uses out-of-line keys and has no key generator and the key parameter was not provided.

I am new to Javascript. I believe it is because onSumbit.function(data) passes in "data" but I don't know how or where to define "data". I have included the sections of view.js and controller.js that I think are needed to help me with my issue.

MyView.view.js

createContent : function(oController) {

var oNameLabel = new sap.ui.commons.Label({text: "Your name :"});

var oNameInput = new sap.ui.commons.TextField("inputName");

var oCommentsLabel = new sap.ui.commons.Label({text: "Your comments :"});

var oCommentsInput = new sap.ui.commons.TextField("inputComments");

var oButton = new sap.ui.commons.Button({

text: "Submit",

press: function(){

oController.onSubmit.apply(oController, {

inputName: oNameInput.getValue(),

inputComments: oCommentsInput.getValue()

});

}

});

var oLayout = new sap.ui.commons.layout.VerticalLayout({

content: [oNameLabel, oNameInput, oCommentsLabel, oCommentsInput, oButton] });

return oLayout; }

myView.controller.js

onSubmit: function(data) {

if(this.checkHostReachable()) {

$.ajax({

type: 'POST',

url: "<webservice url>",

data: data

});

} else {

this.writeToIDB(data);

},

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 09, 2016 at 11:54 PM

    I figured out the issue. The blog "Going offline with SAP UI5 has an error in the "var oButton". It was missing the square brackets [].

    var oButton = new sap.ui.commons.Button({

    text: "Submit",

    press: function(){

    oController.onSubmit.apply(oController, [{

    inputName: oNameInput.getValue(),

    inputComments: oCommentsInput.getValue()

    }]);

    Add comment
    10|10000 characters needed characters exceeded