Page 1 of 1

REST Documentation Question

PostPosted: Thu Jan 24, 2013 11:45 pm
by jgarfield
Looking over the documentation I noticed something odd.

In both the ws_update and ws_create code there is a foundset.loadAllRecords(); at the end of the code.

Code: Select all
function ws_create(data,version,pk)
{
   var rec = foundset.getRecord(foundset.newRecord());

   rec.name_first = data.name_first;
   rec.name_last = data.name_last;
   rec.email = data.email;
   rec.phone_cell = data.phone_cell;
   rec.company_id = data.company_id;
   databaseManager.saveData(rec);

   foundset.loadAllRecords();
}


The doing that important or necessary? Or is it just in there by mistake?

Re: REST Documentation Question

PostPosted: Fri Jan 25, 2013 12:46 am
by ptalbot
Hey James!
if you ask me, the real mistake is to use the rest plugin instead of Velocity ;)

Re: REST Documentation Question

PostPosted: Fri Jan 25, 2013 3:54 am
by jcarlos
ptalbot wrote:Hey James!
if you ask me, the real mistake is to use the rest plugin instead of Velocity ;)


+1 :-)

Re: REST Documentation Question

PostPosted: Fri Jan 25, 2013 4:59 pm
by jgarfield
ptalbot wrote:Hey James!
if you ask me, the real mistake is to use the rest plugin instead of Velocity ;)


Well, I'm really just working on using Servoy Mobile as it is, so I don't really have a lot to do with how the REST portion of it is implemented.

That being said, if you have a strategy for deploying Mobile Apps with a combination of Servoy, Velocity, and jQuery Mobile (or some other UI framework) I would love to read up on it.

Re: REST Documentation Question

PostPosted: Fri Jan 25, 2013 7:19 pm
by ptalbot
Ah ah ah! I was picking on you! :)
For mobile, there's no big strategy involved... just use whatever UI framework you like and are familiar with, then use Velocity/Servoy to build the kind of JSON required by that framework to serve data.

Re: REST Documentation Question

PostPosted: Tue Jan 29, 2013 11:12 am
by rgansevles
jgarfield wrote:Looking over the documentation I noticed something odd.

In both the ws_update and ws_create code there is a foundset.loadAllRecords(); at the end of the code.

Code: Select all
function ws_create(data,version,pk)
{
   var rec = foundset.getRecord(foundset.newRecord());

   rec.name_first = data.name_first;
   rec.name_last = data.name_last;
   rec.email = data.email;
   rec.phone_cell = data.phone_cell;
   rec.company_id = data.company_id;
   databaseManager.saveData(rec);

   foundset.loadAllRecords();
}


The doing that important or necessary? Or is it just in there by mistake?


The loadAllRecords call is not really needed here.
You do have to keep in mind that the rest_ws plugin uses a pool of headless clients to serve the requests.
REST defines statelessness, so each request may not depend another one.
Make sure that something like the forms foundset state left over from previous request does not affect the next request.

Rob