Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 12 total
Thread EWB and mORMot using ewbmormot.wbs
Sun, Nov 11 2018 12:06 AMPermanent Link

Robert Horbury-Smith

This is a request for advice from all you EWB / mORMot users out there (I hope you're out there).

I'm building a system for a client that needs a VCL Admin front end, and a customer facing web browser screen (EWB), hitting the same web hosted Mormot Server.

Delphi VCL stuff is working on both Client and Server.

To get up and running quickly, I thought I'd use Sample1.wbp from Erick Engelke's EWB/Morrmot books. This sample uses Mormot Server example 18, fills a grid in EWB, and has some Dataset editing contols. It uses a wrapper (Ercik's ewbmormot.wbs) to populate the dataset from the Delphi/Mormot REST Server.

It's not working for me.

All I've done is :

1. Refactor the Server source and EWB's Sample1a.wbs to include/refer to my SQLite table (changed Table Fields to match the new db).
2. Changed the Database Name on the Server.
3. Changed the Table definitions (schema)  on Server and in EWB (TSQLTableName = class(TSQLRecord)).
4. Changed the Tablename Binding on the Client to reflect the new Table Name ( "Mormot.InitServer( 'http://127.0.0.1:8080/root/Customer' (was SampleRecord),  self);".
5. Redefined the EWB TDataset columns, renamed TEdits and changed their Dataset bindings to match the new schema.

For those familiar with the sample ...

Tried to do some debugging - added a TMultiLineEdit to the main form.

In procedure TForm1.OnPopulate( s : string ) - added the first line

 MultiLineEdit1.Lines.Add('Value for s is : ' + s);
 DataSet1.Open;
 DataSet1.LoadRows( s );

The rersult is this :

Value for s is : {"rows":[]}.

Only 10 records in the Database - nothing returned (returns quite a few records in the origional example).

Any suggestions would be deeply appreciated. Ashamed to say I've been working on this for many days (all kinds of tests) and getting nowhere.

Thanks

Robert
Sun, Nov 11 2018 5:34 AMPermanent Link

Matthew Jones

Given you are getting a “good” response (if empty), focus on the database
side. Add some logging there. What comes in, what happens, what is
returned.
Sun, Nov 11 2018 3:26 PMPermanent Link

Robert Horbury-Smith

Thanks Mattew. Tested the database with the VCL REST Client - all the CRUD operations are fine (same Database and same Server). Problem is only with the EWB front end - still looking.

Robert

Matthew Jones wrote:

Given you are getting a “good” response (if empty), focus on the database
side. Add some logging there. What comes in, what happens, what is
returned.
Sun, Nov 11 2018 7:26 PMPermanent Link

Robert Horbury-Smith

Matthew - quick update.

There's another example in Erick's book - Sample2.wbp.

It performs simple CRUD operations for a single record.

It works as expected with my version of the RestServer and DB - so all is good with the back end presumably (also my Delphi client populates a VCL grid just fine using the same server instance).

So, problem seems to be somewhere in my EWB example.

Still digging.

Cheers

Robert
Mon, Nov 12 2018 4:11 AMPermanent Link

Matthew Jones

Robert Horbury-Smith wrote:

> Tested the database with the VCL REST Client

That's good then, because the next step is to compare those against the EWB calls in the Chrome Network debugger. What is the difference?

--

Matthew Jones
Tue, Nov 13 2018 4:55 AMPermanent Link

Robert Horbury-Smith

Matthew, took a look at the Chrome debugger, but mORMot has the ability to generate logs at the Server end, so I thought I'd first refactor the servers to log requests and responses and compare the difference.

Now the plot thickens.

I need two pairs of programs. 1'st pair = original Server "biolife" example (with logging) + the original EWB sample project. Second pair is the modified (for my Bookings dataset) Server and EWB Project.

Now I had 12 or more EWB sample1.wbp test versions that I'd been playing with, and I needed to choose the best of those for the second pair. Being too lazy to open each one in EWB, I ran the sample1.html in the output folder. It opened the browser, displayed the screen, AND POPULATED THE GRID. No errors. Beautiful

Now I was templed to run downstairs and open a bottle of champaign, but before I did, I opened the project in EWB,and on running got a error code 400 : bad request (trigered in a TMormotConnection.ToEwbRows function - I'lllook further later).

What this does indicate though is that the mormot server is fine (ran with one off the html/js iterations (wish I knew which one).

I'll now play with comparing log files and see what comes up.

Robert


"Matthew Jones" wrote:

en, because the next step is to compare those against the EWB calls in the Chrome Network debugger. What is the difference?

--

Matthew Jones
Tue, Nov 13 2018 7:30 AMPermanent Link

Matthew Jones

Robert Horbury-Smith wrote:

>  I opened the project in EWB,and on running got a error code 400 : bad request

Do you have CORS permissions set so the service can direct you to a different location? Sounds like some sort of permissions or getting to the correct port problem to me.

--

Matthew Jones
Tue, Nov 13 2018 6:30 PMPermanent Link

Robert Horbury-Smith

"Matthew Jones" wrote:

Do you have CORS permissions set so the service can direct you to a different location? Sounds like some sort of permissions or getting to the correct port problem to me.

--

The server uses the HttpApiRegisteringURI option as works fine withh VCL Clients, but I'll look further later.

For now, I'm running out of time - I seem to be able to populate the grid row by row in code, and this may be enough to allow me to deliver a working solution.

When I have time, I'll figure this out and report back (in case it helps someone else in the furure).

Next challenge will be to get OnetoMany joins working with this server on the EWB side.

For now, huge thanks for all your help Matthew - appreciate it.

Robert
Mon, Nov 19 2018 3:32 PMPermanent Link

erickengelke

Robert Horbury-Smith wrote:

"Matthew Jones" wrote:

>For now, I'm running out of time - I seem to be able to populate the grid row by row in code, and this may be enough >to allow me to deliver a working solution.

>When I have time, I'll figure this out and report back (in case it helps someone else in the furure).

Hi, I've been vacationing, or remodelling my basement, whichever you believe.  Sorry I haven't been following.

I plan to update my ewbmormot code online shortly, based on the experience of several production systems using it.

The challenge is that systems I build are necessarily large and complex.  For exaple, supporting external authentication such as CAS, OpenID Connect, or SAML instead of a local password hash file.  And now I support CSRF and CSS prevention which adds more complexity.  Many people need those features if they are doing enterprise development, but they are overkill for exporting your daughter's CD collection to her friends.

So I'm having to make changes to support the simpler case too.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Mon, Nov 19 2018 6:48 PMPermanent Link

Robert Horbury-Smith

HUGE thanks for doing this Erick.

Just on the size and complexity of the wrappers, would it make sense to split them? (one for CRUD operations and another one for security and authentication).

Cheers

Robert

erickengelke wrote:

>...

>When I have time, I'll figure this out and report back (in case it helps someone else in the furure).

Hi, I've been vacationing, or remodelling my basement, whichever you believe.  Sorry I haven't been following.

I plan to update my ewbmormot code online shortly, based on the experience of several production systems using it.

The challenge is that systems I build are necessarily large and complex.  For exaple, supporting external authentication such as CAS, OpenID Connect, or SAML instead of a local password hash file.  And now I support CSRF and CSS prevention which adds more complexity.  Many people need those features if they are doing enterprise development, but they are overkill for exporting your daughter's CD collection to her friends.

So I'm having to make changes to support the simpler case too.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Page 1 of 2Next Page
Jump to Page:  1 2
Image