Hi all,
I have been running automatic test scripts on one of my large Servoy systems under Servoy 3.5.6 (Mac OS X), Mac OS X 10.5.2, Java 1.5 on PowerPC.
I’m using PostgreSQL with database identities throughout. This has worked fine until Servoy 3.5.6.
Something has changed in the event firing order or behaviour, so I’m now having scripts accessing the pk too early, before it is available…
If I run
controller.newRecord();
controller.saveData();
on a visible layout, and I have on_record_select script…
And the on_record_select script tries to access to pk, I get
org.mozilla.javascript.EvaluatorException: Invalid JavaScript value of type com.servoy.j2db.dataprocessing.ValueFactory$DbIdentValue
This did not happen prior to 3.5.6.
I can get around it by adding
if(isNaN(parseInt(pk))) return;
At the top of my on_record_select script…
What is going on?
what do you do with the PK?
Do you test for it? if(pk) ?
in an onrecordselect the record that you just created is not saved to the database.
So if you do newRecord() then in newRecord the selection is changed and your script runs before you do saveData().
Currently calling saveData() in the onRecordSelection script also doesnt help. Because a record is not really in edit mode yet, only after the selection is done. You can trigger a edit by setting a value in the record (in the on selection script) and then call saveData()
But the big question is what do you do with the pk in the onRecordSelection script?
jcompagner:
what do you do with the PK?
I use the on_record_select to load some related data using SQL – something which I can’t use a normal relationship for, such as loading phone numbers belonging to both a person and the current company of a person into a single tab-panel.
Now, I can see why I can’t access the pk before the record is saved, but I’m also curious as to why this is suddenly a problem in 3.5.6. Something must have changed. Before it was enough to save on the next line of the script creating the record.
I have an automatic test suite which tests the solution, 400+ checks. It ran without reporting errors under 3.5.5.
The problem was that the pk that you where testing was really NULL but that was wrong, that was a bug in 3.5.5.
PK’s should never be null in servoy whatever pk sequence you use… It should always be filled in…
But i guess what you want is test if it is null? so test if it is a new record?
This cant be done by testing the PK
In the next release we will introduce a new method on databasemanager:
hasNewRecords(record/foundset)
so that you can test for a single record if it is new or if the foundset has new records.
Hi Johan,
that may do the trick.
Another idea:
In Hypercard there used to be this command for freezing the screen, so you can do things without any screen updates or events happening. This would also speed up code execution.
controller.freeze();
controller.newRecord();
controller.saveData();
controller.unFreeze();
In this case on_record_select, on_show would fire after the record is saved…
there are no UI updates when events are fired in servoy.
But there are other events fired what ever you do. (onload/onshow/onselecction) and those need to be done at that time
Because else when do we run them?
After your script? But then the state of the selection can be long changed again. All events are exactly done at the time they have to fire and the data is in the state the expect it to be. Else it will become a big mess.
Ok, we don’t want a mess.
I need to move or change my code.
This is really Model code, but Servoy does not have a clear concept of a model, there are some table events (which are great)…
I normally work around it by having a form called
table_name + ‘_processing’ on a separate found_set…