#1 2015-08-17 14:38:38

lele9
Member
Registered: 2011-10-28
Posts: 170

dynamic array and javascript (ajax) client

hi ab,
i have a dynamic array property in a TSQLRecord definition and i would read (just read!) it from a javascript (ajax) client.
now i get a base64 encoded string that its hard to read (there are a good way to do?!).
i read from documentation that i can save a dynamic array as Json instead BLOB, but i don't understand what is the correct and fast way to do.
can you help me to undestand?
thanks,
Emanuele

Offline

#2 2015-08-17 18:19:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,570
Website

Re: dynamic array and javascript (ajax) client

For storing an array with direct remote REST/ORM access, I guess the easiest is not to use a dynamic array, but a variant published field, storing a TDocVariant instance.

In this TDocVariant instance, you could store any array, ready to be transmitted as JSON to the AJAX client.

Online

#3 2015-08-18 07:06:48

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: dynamic array and javascript (ajax) client

thanks ab,
i will use TDocVariant in next time, but now i'm writing an ajax client for an application that is in production, so change the model is too difficult.
there are solution to pass a dynamic array as json to an ajax client or to read a dynamic array from the client?
thanks a lot.

Offline

#4 2015-08-18 09:17:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,570
Website

Re: dynamic array and javascript (ajax) client

Not from the ORM REST URI, I'm afraid.

You may use a method-based service or an interface-based service to make the conversion, and return proper JSON.

Online

#5 2015-08-18 09:23:34

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: dynamic array and javascript (ajax) client

ok, i had write an interface-based service and all work fine.

just another question:
my ajax client need just to read, but if i use a "Guest" user i get forbidden when call the service. It's possible to have just read permission and able to call interface-based service?

Offline

#6 2015-08-18 10:49:32

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,570
Website

Re: dynamic array and javascript (ajax) client

You can set the ByPassAuthentication property to true when you register the service on the server side.

Online

#7 2015-08-18 10:59:14

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: dynamic array and javascript (ajax) client

but setting the ByPassAuthentication property to true anyone can call the service, instead i would that just logged in user (with just read permission) can do.
it's possible?

Offline

#8 2015-08-18 11:43:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,570
Website

Re: dynamic array and javascript (ajax) client

Allow the service execution for the logged in user group.
See http://synopse.info/files/html/Synopse% … ml#TITL_77

Online

Board footer

Powered by FluxBB