Title: Does BDL provide a means of raising events? Post by: Matthew F. on September 27, 2016, 04:11:48 pm I've written some back-end code in BDL for exporting/importing records to/from CSV files. This program will be run in both the desktop and web front ends, but may also be modified later to run as a scheduled job.
While the import/export code is executing in an interactive program, I'd like to update the UI to show progress, list non-fatal errors that have occurred so far, etc. Ideally I'd like to avoid having my back-end code interact directly with the UI by means of DISPLAY BY NAME instructions, etc. Does BDL provide any means of raising events that I can handle in the UI? Title: Re: Does BDL provide a means of raising events? Post by: David H. on September 28, 2016, 11:02:13 am Good question! This is something we also want to look at in the near future, separating processes away from the front end, where some mechanism will be required to inform the front end of the back end progress/errors etc. Have you had a look at the MessageServer class yet? (see http://4js.com/online_documentation/fjs-fgl-2.50.00-manual-html/#c_fgl_ClassMessageServer.html (http://4js.com/online_documentation/fjs-fgl-2.50.00-manual-html/#c_fgl_ClassMessageServer.html)) Another potential option I guess is Web services, where the client would presumably need to request for some kind of status update from the back end every so often.
Title: Re: Does BDL provide a means of raising events? Post by: Sebastien F. on September 28, 2016, 11:19:09 am If I would have to write such a program that can run in batch mode or with a UI interface, I would implement a unique program with --silent mode, to run the program in batch mode or in interactive mode.
In interactive mode, you can then use ui.Interface.refresh() to display information to the end user (show progress bar, reload a table with log records, etc). If your program will be executed as a scheduled job in background, you could write to a log file or to an SQLite database, and have a secondary UI program displaying the progress by reading the log or the db, using ON IDLE 2 or 3 secs, to refresh information displayed to the user... In this UI program you can also implement filters or search facilities to find information in the logs. Seb Title: Re: Does BDL provide a means of raising events? Post by: Matthew F. on October 03, 2016, 06:51:19 pm Good question! This is something we also want to look at in the near future, separating processes away from the front end, where some mechanism will be required to inform the front end of the back end progress/errors etc. Have you had a look at the MessageServer class yet? (see http://4js.com/online_documentation/fjs-fgl-2.50.00-manual-html/#c_fgl_ClassMessageServer.html (http://4js.com/online_documentation/fjs-fgl-2.50.00-manual-html/#c_fgl_ClassMessageServer.html)) Another potential option I guess is Web services, where the client would presumably need to request for some kind of status update from the back end every so often. Those are some interesting ideas, but unfortunately a bit complex for what I had in mind. This isn't a critical requirement for my application, so in this case I won't try to force BDL to do something that it doesn't readily support. Title: Re: Does BDL provide a means of raising events? Post by: Matthew F. on October 03, 2016, 06:54:47 pm If I would have to write such a program that can run in batch mode or with a UI interface, I would implement a unique program with --silent mode, to run the program in batch mode or in interactive mode. In interactive mode, you can then use ui.Interface.refresh() to display information to the end user (show progress bar, reload a table with log records, etc). If your program will be executed as a scheduled job in background, you could write to a log file or to an SQLite database, and have a secondary UI program displaying the progress by reading the log or the db, using ON IDLE 2 or 3 secs, to refresh information displayed to the user... In this UI program you can also implement filters or search facilities to find information in the logs. Seb Thank you. I'll keep these pointers in mind when modifying the program to run in batch mode. Title: Re: Does BDL provide a means of raising events? Post by: Reuben B. on October 06, 2016, 11:17:11 pm I'll just add that ON TIMER was added in 3.0 to provide an alternative means for polling other than ON IDLE, see http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_prog_dialogs_on_timer.html.
Title: Re: Does BDL provide a means of raising events? Post by: Enrico S. on October 10, 2016, 04:53:51 pm Hi.
Take attention when using ON IDLE & ui.interface.refresh(). If you are using tabbedContainer & startMenu with GWC and the program requesting the refresh loses the focus (a program in another tab goes foreground), you get an error (Cannot connect to GUI) when trying ui.interface.refresh(). This could be an issue for labs. Enrico |