Page 2 of 2

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

Posted: Tue Jan 22, 2013 3:58 pm
by Maryna Brodina

Hello! Please take a look at the screenshot

Image


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

Posted: Tue Jan 22, 2013 4:05 pm
by Joseph Yeung

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.


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

Posted: Tue Jan 22, 2013 4:14 pm
by Maryna Brodina

Yes


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

Posted: Tue Jan 22, 2013 4:36 pm
by Joseph Yeung

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


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

Posted: Tue Jan 22, 2013 5:24 pm
by Joseph Yeung

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?


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

Posted: Tue Jan 22, 2013 5:53 pm
by Maryna Brodina

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


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

Posted: Tue Jan 22, 2013 6:25 pm
by Joseph Yeung

Great! Your last comment is noted.


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

Posted: Tue Jan 22, 2013 6:27 pm
by Joseph Yeung

Great! Your last comment is noted. Thx!