Updating an HTML control asynchronously

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Updating an HTML control asynchronously

#1

Postby Segi » Tue Mar 27, 2018 11:05 pm

I have an Ebase application (which I cannot share) where you enter a part number and click on a button which begins running a server-side task that is a very time consuming task. It can take up to 15-20 minutes to complete depending on the part number entered.

I have an HTML control called StatusText that displays status messages as it executes. Each new status message is appended after the existing status message.

When you click on the button to start running the task, all previous status messages are cleared by setting the field which holds the status text to ""

When the task starts running, a status message is displayed that reads "Started running at <TIME>"

If a certain kind of error occurs when trying to generate a file, a status message is added to the status but the application continues to run.

When the task completes, it shows a message that reads "Finished running at <TIME>"

My problem is with the way that Ebase runs synchronously instead of asynchronously. The status text isn't updated immediately. Instead the status messages that have been added since the user clicked on the button are only updated once the task is finished, again because Ebase runs asynchronously.

I know that you can run server side code from the client side but is there a way on the server side to have the status messages update in real time ?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Updating an HTML control asynchronously

#2

Postby Jon » Wed Mar 28, 2018 2:55 pm

Segi,

Tricky. The Ebase system will only run one task at a time for a given client so the first task - the long-running one - will block any subsequent calls including $eb.executefunction calls. One way to do this would be to separate out your long running task into a separate form and then kick this off in background using services.scheduler.runBackgroundForm(). Then you're faced with the problem with how to feedback status information from this background task - you could do this via servlet context attributes (system.servletContext) or via the database. A bit clunky but I think it would work.

Jon
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Updating an HTML control asynchronously

#3

Postby Segi » Wed Mar 28, 2018 3:56 pm

Jon,

Thanks for the feedback. This sounds too complicated to make it worth rewriting the logic for this application. I hope that Ebase can figure out how to make things run asynchronously in a future update
0 x


Who is online

Users browsing this forum: No registered users and 6 guests