#1 2015-01-29 16:09:58

DidiL
Member
Registered: 2015-01-06
Posts: 10

Posting data from HTML client

Hi,
Can someone provide me a sample case for adding a record from a web page?

 <form method="PUT" action="http://localhost:8080/root/SampleRecord/">  ???
   <input type="text" name="Name"/>
   <input type="submit" value="Insert"/>
 </form>

Thanks in advance

Offline

#2 2015-01-29 16:58:10

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

Re: Posting data from HTML client

You can not use directly a form field to make a REST request!
Or the text should be written in JSON... not obvious.

For a web site using mORMot, take a look at sample 30, and documentation about MVC/web http://synopse.info/files/html/Synopse% … E_TITL_108
https://github.com/synopse/mORMot/tree/ … C%20Server

Offline

#3 2015-01-29 19:07:04

DidiL
Member
Registered: 2015-01-06
Posts: 10

Re: Posting data from HTML client

Seems sample 30 uses interfaces based services, which are not available under Lazarus, or may be  I failed in converting the project?

Even if I'm not a javascript developer, I don't mind if I have to use a few javascript to format/encode JSON.
What I want is a clear understanding of the format required for parameters tranmission.
For CRUD requests, and/or for method based services.

Offline

#4 2015-01-30 07:02:09

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

Re: Posting data from HTML client

For Lazarus, you need to follow the instructions available in the doc, so that you generate the RTTI for interfaces.
See http://synopse.info/files/html/Synopse% … l#TITL_125

For JavaScript use, take a look at samples "18 - AJAX ExtJS Grid" and "19 - AJAX ExtJS FishFacts".
Another option is SMS in "29 - SmartMobileStudio Client".

The format is clearly stated in the doc.
http://synopse.info/files/html/Synopse% … #TITLE_223
http://synopse.info/files/html/Synopse% … ml#TITL_49
http://synopse.info/files/html/Synopse% … #TITLE_370

To see it live, the easiest is to put a breakpoint on the server executable in TSQLRestServer.URI().
You have the whole expected content in the Ctxt parameter.

Offline

#5 2015-01-30 12:42:14

DidiL
Member
Registered: 2015-01-06
Posts: 10

Re: Posting data from HTML client

Thank you ab,
I got it about Lazarus, and I was already ok for the method's Request format.

Although I would definitely go the SmartMobile way, I was looking for a CRUD javascript sample for my understanding.
I saw through the code "TSQLRestServerURIContext.ExecuteORMWrite" that it is definitely possible.

Offline

Board footer

Powered by FluxBB