Bernie
Posts: 0
Joined: Fri Jul 27, 2012 2:06 pm

generic service array mapping

I created a generic service based of a JSON.stringified array stored in a localstorage variable.

Here is the javascript code of my generic service:

Appery.getOffline = Appery.createClass(null, {

init: function(requestOptions) {
this.__requestOptions = $.extend({}, requestOptions);
},

process: function(settings) {
if (this.requestOptions.echo) {
settings.success(this.requestOptions.echo);
} else {
//console.log('Default implementation is used. Please define your own.');

// load JSON data from local storage

var cdata = localStorage.getItem("offline1");

//This is how the content of the local storage looks like
//[{"column1":"1","column2":"10","column3":"100"},{"column1":"2","column2":"20","column3":"200"}]

// pass the JSON to the service, for output mapping
settings.success(JSON.parse(cdata));

}
settings.complete('success');
}

});

Unfortunately the mapping into a list element won't work.
Any ideas on what could solve the problem would be great.
Thank you in advance

Image

Bernie
Posts: 0
Joined: Fri Jul 27, 2012 2:06 pm

generic service array mapping

This is how it works:

Appery.getOffline = Appery.createClass(null, {

init: function(requestOptions) {
this.__requestOptions = $.extend({}, requestOptions);
},

process: function(settings) {
if (this.requestOptions.echo) {
settings.success(this.requestOptions.echo);
} else {

Code: Select all

 // load JSON data from local storage 
 var cdata = localStorage.getItem("offline1"); 
 //This is how the content of the local storage looks like 
 //[{"column1":"1","column2":"10","column3":"100"},{"column1":"2","column2":"20","column3":"200"}] 

 var cdata2 = JSON.parse(cdata); 

 // pass the JSON to the service, for output mapping 
 settings.success(cdata2); 

}
settings.complete('success');
}

}); Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

generic service array mapping

Hello,

Thank you for the update! Glad it works now!

Return to “Issues”