NG Users and Events?

Forum to discuss the new web client version of Servoy.

NG Users and Events?

Postby john1598360627 » Wed Nov 17, 2021 2:52 am

PROBLEM
I'm not sure how to describe this problem.

So, after setting up the NG stuff such that you put the URL in a browser to access it client side. That person is now a 'user' right? And when multiple people are accessing the NG, those are all technically different users with their own clientside NG.

Alright, now lets say 1 user does something on a page such that a Form event is triggered for them, something via Datachange. And what if this event is important for that form, perhaps related to an error status.

QUESTION
This begs the question of, do other users receive form events? Form events being called on one users clientside.

And then, how do you send a local NG client's form event to all other users, if possible? Specifically the events related to a users actions, like datachange of a record and such.

THEORY
Do I have to set something up so form events are sent to other users? Is 'users' the right word? Basically people using the same instance of NG from their own browser, making database changes to a record that shoots off a form event... How do I sent that event to everyone else that is browsing the same form instance? Is there something I'm missing that needs to be setup, either client side or server side? Or does NG not work like that to begin with.
john1598360627
 
Posts: 169
Joined: Tue Aug 25, 2020 3:03 pm

Re: NG Users and Events?

Postby sean » Wed Nov 17, 2021 3:40 am

Hi John,

The Servoy platform has a nice feature called Data Broadcasting, which will update the data cache across all client sessions. This means that 2 clients looking at the same record will always see the same point-of-truth. You don't have to do anything to enable this.

More docs here:
https://wiki.servoy.com/display/DOCS/Databroadcasting

Per your specific question: No, UI events are not shared between clients. What happens on a client screen (apart from data broadcasts, is limited to that session)

However, there is another nice feature which can be used to send broadcast payloads between clients.
https://wiki.servoy.com/display/DOCS/clientmanager

Shown here in a nice webinar!
https://www.youtube.com/watch?v=XUVbwpfufgc

Hope this helps.

Best,
Sean
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: NG Users and Events?

Postby john1598360627 » Wed Nov 17, 2021 11:57 pm

sean wrote:Hi John,

The Servoy platform has a nice feature called Data Broadcasting, which will update the data cache across all client sessions. This means that 2 clients looking at the same record will always see the same point-of-truth. You don't have to do anything to enable this.

More docs here:
https://wiki.servoy.com/display/DOCS/Databroadcasting

Per your specific question: No, UI events are not shared between clients. What happens on a client screen (apart from data broadcasts, is limited to that session)

However, there is another nice feature which can be used to send broadcast payloads between clients.
https://wiki.servoy.com/display/DOCS/clientmanager

Shown here in a nice webinar!
https://www.youtube.com/watch?v=XUVbwpfufgc

Hope this helps.

Best,
Sean



Hmmm yes the data is definitely being broadcasted instantly. The problem is the form events then.


So let's say User-1 changes something on a form & User-2 is also viewing the same form. User-1 gets the Form Events from that datachange, this triggers elements on the form to change. In this case, it's related to an error that must be fixed before they leave the page so navigation is disabled. However, since User-2 didn't get the Form Event so they can still navigate around even though there was an error.


I'm curious if ya have any ideas on how to make sure both User-1 and User-2 get the form change from the datachange.

An idea I have is by adding more checks to the data for other form events, so that the form would eventually update.

Another would be locking a page out from others viewing it if it's "in use", not sure if that's possible though. I'll have to watch the webinar to see if this is mentioned.
john1598360627
 
Posts: 169
Joined: Tue Aug 25, 2020 3:03 pm

Re: NG Users and Events?

Postby sean » Thu Nov 18, 2021 3:44 pm

I don't understand. Why would you want user 2's experience to be tied to something user 1 is doing?! ...unless they actually commit the changed data in the DB.
In the case of the validation, if the data is not saved yet, then user 2 should not be bothered with something user 1 is doing. Each has their own stateful session.
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: NG Users and Events?

Postby swingman » Fri Nov 19, 2021 11:07 am

If I understand right, you want something like this (this example is a bit artificial):

User 1 ( a manager) edits form, user 2 (a sales person) is looking at the same record, let's say a Customer's account.
The Customer owes money and has reached the credit limit so there is a message on both users' screens that the customer cannot get more credit, so the sales person has asked the manager to override.
User 1 changes the credit limit or adds a payment to the user's account so the message disappears on User 1's screen.

At this point the customer has more credit but the sales person does still see the message.
To get the message to also instantly disappear from the sales person's screen you need to put it in a database field and display that field on your form. The field can include styling.

In your database table on Servoy you hook up a method to your onUpdateEvent that updates the message if the credit limit changes or payment is added.
This way Servoy will broadcast the change for you.

Hope this helps,
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: NG Users and Events?

Postby john1598360627 » Sat Nov 20, 2021 2:33 am

swingman wrote:If I understand right, you want something like this (this example is a bit artificial):

User 1 ( a manager) edits form, user 2 (a sales person) is looking at the same record, let's say a Customer's account.
The Customer owes money and has reached the credit limit so there is a message on both users' screens that the customer cannot get more credit, so the sales person has asked the manager to override.
User 1 changes the credit limit or adds a payment to the user's account so the message disappears on User 1's screen.

At this point the customer has more credit but the sales person does still see the message.
To get the message to also instantly disappear from the sales person's screen you need to put it in a database field and display that field on your form. The field can include styling.

In your database table on Servoy you hook up a method to your onUpdateEvent that updates the message if the credit limit changes or payment is added.
This way Servoy will broadcast the change for you.

Hope this helps,

Hmmm, so if I'm understanding right, setting up a Database event (not Form) will mean that I can update the message from when the database itself changes.

Which database entity event would be this though?

* onRecordUpdate
* afterRecordUpdate
john1598360627
 
Posts: 169
Joined: Tue Aug 25, 2020 3:03 pm

Re: NG Users and Events?

Postby swingman » Sat Nov 20, 2021 12:41 pm

Hi John,

I would use onRecordUpdate in the scenario above, because I want to modify a column in the customers table based on other values in the customers table.
If you trigger the change in customers from payments when adding a new payment, you can use either of the two events. Maybe try afterRecordInsert in this case.
Let's assume your onRecordUpdate in Customers checks the money owed to calculate the message. In the afterRecordInsert you can trigger an update on the customers table any simply updating the modified_timestamp on the related customer and saving. This triggers the onRecordUpdate in customers...

something like:

if(utils.hasRecords(my_payment.your_relation_from_payments_to_customer) {
var customer = my_payment.your_relation_from_payments_to_customer.getRecord(1);
customer.modified_timestamp = new Date();
databaseManager.saveData(customer);
}

It all depends what you are doing -- you want to avoid too many other updates cascading out the initial change, so one may work better than the other.
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: NG Users and Events?

Postby john1598360627 » Tue Nov 23, 2021 8:32 pm

swingman wrote:Hi John,

I would use onRecordUpdate in the scenario above, because I want to modify a column in the customers table based on other values in the customers table.
If you trigger the change in customers from payments when adding a new payment, you can use either of the two events. Maybe try afterRecordInsert in this case.
Let's assume your onRecordUpdate in Customers checks the money owed to calculate the message. In the afterRecordInsert you can trigger an update on the customers table any simply updating the modified_timestamp on the related customer and saving. This triggers the onRecordUpdate in customers...

something like:

if(utils.hasRecords(my_payment.your_relation_from_payments_to_customer) {
var customer = my_payment.your_relation_from_payments_to_customer.getRecord(1);
customer.modified_timestamp = new Date();
databaseManager.saveData(customer);
}

It all depends what you are doing -- you want to avoid too many other updates cascading out the initial change, so one may work better than the other.

I see. I just watch to check when a number value is modified in my case. So I think afterRecordUpdate should work for me.


Thank you for explaining this! I'll reply again if I can't figure out how to set it up.
john1598360627
 
Posts: 169
Joined: Tue Aug 25, 2020 3:03 pm


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 10 guests