NetTalk Central

Author Topic: Field priming  (Read 6940 times)

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Field priming
« on: October 01, 2019, 12:27:39 PM »
Hi,

I have this procedure UpdateA, where A stands for table A.tps.
In the Clarion-part of the program priming the GUID for A is primed.
I also use the javascript priming for A:guid because I want the app to be a PWA sometime.

In this procedure, I also, ocasionally, write a record into table B.tps.
B:guid is primed (clarion-style) in the embed-code where I write a record into B.tps.

How and where must I do the Javascript priming of B:guid ? Or do I not need this?

Kind regards,

René Simons
Rene Simons
NT14.14

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: Field priming
« Reply #1 on: October 02, 2019, 02:07:12 AM »
The Javascript priming is intended for "disconnected" situations where the data resides on a device such as a phone or tablet or even a desktop browser.  Nevertheless, the server, or Clarion side, would not be primiming it in that situation therefore the Javascript priming.

I think there is some confusion as to what a PWA is.  A PWA is simple an app that meets certain critiria.  It has to have a service worker.  Is has to have a manifest.json file.  And so on.  It can be a connected app or not.  It can be a single page app or not. 

Having said all that, I don't think it hurts anything to use the Javascript priming along with the traditional Clarion.  In fact, I will "go out on a limb" and say that Bruce would probably encourage it as it is good to familiarize yourself with it.  It's powerful stuff (Javascript).  That's what I like about NetTalk.  So many options. 

Take care,

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Field priming
« Reply #2 on: October 02, 2019, 02:33:58 AM »
Hi Don,
(And thanks again for responding so quickly.)

Correct me if I'm wrong.

Because the validation in the PWA has to be done in javascript, the app will also find out if the record for table B is missing or present.
 
Therefore, the create of the B-record must be done at the user's phone, using a javascript function
After that, the sync will take care of creating the record on the host I guess.

For what it's worth: Because of the way the database paths on the server will be set up, the total amount of data on the user's phone will be very small.

Cheers,
Rene



Rene Simons
NT14.14

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: Field priming
« Reply #3 on: October 02, 2019, 04:53:16 AM »
Hi Don,
(And thanks again for responding so quickly.)

I try.  :)

Quote
..in the PWA has to be done in javascript

If the PWA is disconnected..yes.

Quote

Therefore, the create of the B-record must be done at the user's phone, using a javascript function

If I'm following what you're doing...yes.

Quote
After that, the sync will take care of creating the record on the host I guess.

Yes.  The underlying NetTalk Javascript will take care of the heavy lifting.

Quote
..the total amount of data on the user's phone will be very small.

This is good.  You don't have a lot of room to work with.

It sounds like you're on the right track in my humble opinion.

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Field priming
« Reply #4 on: October 03, 2019, 12:15:13 AM »
Hi Don,

Great to hear.

One more thing:
I would like to add the validation part in the save-button (of an update form) handling.
There are several embed points where there's room for javascript.
Which one do you recommend?

Cheers,
Rene Simons
Rene Simons
NT14.14

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Field priming
« Reply #5 on: October 09, 2019, 02:32:14 AM »
Hi Rene,

Ultimately any Clarion Embed code you write will need to be written in JavaScript as well if you intend the app to work in a disconnected mode. So the "extra work" you are doing in Clarion you will also have to do in JavaScript. what that JavaScript code looks like, and where you will "embed" it depends a lot on your specific case, and I'd need an example app to comment further on that.

cheers
Bruce

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Field priming
« Reply #6 on: October 09, 2019, 03:51:48 AM »
Hi Bruce,

I know there is no magic wand that converts clarion code into javascript.
That's why I keep the amount of embed code as small as possible.
Apps are there to help you perform a (small) task not to do your book keeping.

I have found some javascript embeds in the code. They are associated with the entry fields in the forms and refer to
onfocus, onblur and onchange.

My validation question is about these:
  • Are these the "best" points to do javascript validation? (e.g. Entry is required, Entry is not valid etc.)
  • Is it best to write javascript functions in my custom.js and call them from these embed-pints here?
  • Is the javascript entered in the template to be enclosed in between quotes?
  • Is the javascript code executed only when the app has succesfully passed through mBuid?

Cheers,
René



Rene Simons
NT14.14

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Field priming
« Reply #7 on: October 09, 2019, 10:04:45 PM »
Hi Rene,

>>     Are these the "best" points to do JavaScript validation? (e.g. Entry is required, Entry is not valid etc.)

if we're talking about form field validation, then yes, OnChange is likely the best embed point.

>>     Is it best to write JavaScript functions in my custom.js and call them from these embed-pints here?

yes.

>>     Is the JavaScript entered in the template to be enclosed in between quotes?

This is not consistent (yet). The short answer is "yes" - but if this causes a compile error please let me know. there are some places I think that don't require quotes (yet) and that needs to be fixed.

>>     Is the JavaScript code executed only when the app has successfully passed through mBuid?

no. the JavaScript is embedded onto the page. Some embeds are only for when the app is generated in disconnected mode. Some embeds are always in play. It depends on the context of the embed. (onchange for a form field is always in play, a browse filter only applies when in disconnected mode.) Typically you can tell the difference by the template prompt. Filter (clarion) and Filter (JavaScript) for example suggests that the JavaScript is only in disconnected mode.

cheers
Bruce