Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to use a localStorage.getItem in Request Parameters of Rest Service?

Hello! Please take a look at the screenshot

Image

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How to use a localStorage.getItem in Request Parameters of Rest Service?

OK! Get it!

I'm still using the old editor ( have been using it since the current project began, and never got chance to switch to the new one).

So, I create a new REST service and use javascript:

serviceInstance.execute({});

to invoke service on some event, right?

That's quite smart. I like Tiggzi.

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How to use a localStorage.getItem in Request Parameters of Rest Service?

Thank you, Marina.

But then if I only would like to fill a certain field (database collection's column) programmatically, and the other two column's stay with the mapping,
how can it be done?

Image

Help me on this, please. Or just give me some pointer to the answer.

Thx

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How to use a localStorage.getItem in Request Parameters of Rest Service?

Anyway, thus far I have got a working around, i.e.

(1) I extract all those localStorage items that I want to save in the database,
(2) put them in one newly created item,
(3) then map this localStorage to the {data} parameter of the REST service that I invoke on click event.

Any comments?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to use a localStorage.getItem in Request Parameters of Rest Service?

To set all data from localStorage into the object you can use the next code:

codevar i, len, values = {}, keyName;
for (i = 0, len = localStorage&#46;length; i < len; i++){
keyName = localStorage&#46;key(i);
values[keyName] = localStorage&#46;getItem(keyName);
}/code

Then if you need to fill a certain field with that data (in JSON format for example) you cam map variable to the parameter and add the next code to mapping:

codevar i, len, values = {}, keyName;
for (i = 0, len = localStorage&#46;length; i < len; i++){
keyName = localStorage&#46;key(i);
values[keyName] = localStorage&#46;getItem(keyName);
}
return JSON.stringify(values);/code

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How to use a localStorage.getItem in Request Parameters of Rest Service?

Great! Your last comment is noted.

Joseph Yeung
Posts: 0
Joined: Tue Aug 14, 2012 7:48 am

How to use a localStorage.getItem in Request Parameters of Rest Service?

Great! Your last comment is noted. Thx!

Return to “Issues”