Hi all,
There is a problem I have been struggling with, and I don't seem to be able to get a good solution. Therefore I'm turning to the APEX community for help.
I have a situation in which an APEX page is loaded. When this page is loaded I need to check if a certain file exists, if it does the page should get some data out of this file (amongst other data), if it doesn't, the page should retry until the file does exist.
The filename is not known beforehand, so I'm using some javacode (in the database) to create a directory list in a table. When the table is empty, I assume that the file does not exist yet.
To do this, I tried several approaches.
First I tried using a dynamic action that fires OnLoad to call the java, combined with a dynamic action that reloads the page with a condition that checks if a row in the table exists.
This worked partly. The reloading works, but because I used dynamic action, all my Before Header processes also fired and I want to prevent that (because some of those processes depend on the contents of the file).
Second I tried the same thing, but now in a Before Header process with sequence 1 (so it's the first one to fire). In the PL/SQL I called the java, queried the table and used apex_util.redirect_url to reload the page. But this resulted in a loop that the browser can't handle.
So now I'm turning to you guys.
What would be a good approach and how can I implement that approach?
I cannot use a timer, because the process to create the file is a human task that can take 1 to 100 seconds.
What I'm really looking for is some sort of polling process that is started before anything on the page is loaded, and continues when the file is found. So I'm thinking javascript, but I'm not familiar enough to find a good example.
Thanks for any help!