Is there anyway to store an array as the object itself in the backend database so it survives an application restart? It works for media fields during runtime, but when I restart the information is lost.
Thanks,
Scott
Is there anyway to store an array as the object itself in the backend database so it survives an application restart? It works for media fields during runtime, but when I restart the information is lost.
Thanks,
Scott
I remembered from one of Bob’s seminars that Servoy allows inline java. So after much Googleness, I figured it out.
This will allow the saving of arrays to a media field that stay after a restart of the client or developer. The reason I use it is so the user can save personal sets of records to go back to later, but will work for any array.
In theory this should work for any serializable object in java. I can’t get it to work with a dataset and the foundset object doesn’t seem to be serializable. If anyone that actually knows java (I don’t know anything about it) can give some hints, please let me know.
I don’t know if this is the right forum category for this, but here’s the code:
var vFoundsetArray = databaseManager.getFoundSetDataProviderAsArray(foundset, 'id');
// to save saved set
var tempFile = plugins.file.createTempFile('savedSet','.data');
var f_out = java.io.FileOutputStream (tempFile);
var obj_out = java.io.ObjectOutputStream (f_out);
obj_out.writeObject (vFoundsetArray);
media_field = plugins.file.readFile(tempFile);
// to restore saved set
var tempFile = plugins.file.createTempFile('savedSet','.data');
var success = plugins.file.writeFile(tempFile, media_field);
var f_in = java.io.FileInputStream(tempFile);
var obj_in = java.io.ObjectInputStream(f_in);
var obj = obj_in.readObject();
var vRestoredSetArray = new Array();
vRestoredSetArray = obj;
vRestoredDS = databaseManager.convertToDataSet(vRestoreSetArray);
controller.loadRecords(vRestoredDS);