Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
async-event and page refresh
#1
We often use async events, but it happens from time to time that we have to refresh the whole page in certain cases - as a result of an asnyc event.
Can that be done in any way?
Reply
#2
We solved this with an OnTimer event.
If callback routines are triggered via dialogues, then some controls could not be updated (runs asynchronously, I think).
Now we start a timer with a short interval in the callback function.
That works very well.
As a short notification is posted also, that fits quite well anyway.
Reply
#3
Following works for me. Call it from your Async... event


Code:
procedure TDlgBase.TriggerFullPostFromAsyncEvent;
var js: string;
begin
  // https://forums.embarcadero.com/thread.jspa?messageID=675140&#675140
  js := 'location.reload();';

  WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(js);
end;
Reply
#4
(05-10-2021, 09:02 AM)jeroen.rottink Wrote: Following works for me. Call it from your Async... event


Code:
procedure TDlgBase.TriggerFullPostFromAsyncEvent;
var js: string;
begin
  // https://forums.embarcadero.com/thread.jspa?messageID=675140&#675140
  js := 'location.reload();';

  WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(js);
end;



Hi Jeroen,

thanks for your input. That's exactly how I would do it.

Optionally a boolean parameter can be used when calling reload() which instructs the browser to bypass the cache and request it again from the server:

Code:
procedure TDlgBase.TriggerFullPostFromAsyncEvent;
var js: string;
begin
  js := 'location.reload(true);';

  WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(js);
end;

Cheers
Reply
#5
We are adding a new method to TIWForm which will do this automagically. You just need to call

IWForm.ReloadAsync;

and it will take care of that for you.

Cheers
Reply
#6
(05-19-2021, 01:19 AM)Alexandre Machado Wrote: We are adding a new method to TIWForm which will do this automagically. You just need to call

IWForm.ReloadAsync;

and it will take care of that for you.

Cheers

Hi Alexandre,

Nice but please check if reload() still should take a parameter. See https://stackoverflow.com/questions/5512...deprecated

Kind regards,
Jeroen.
Reply
#7
(05-19-2021, 05:30 AM)jeroen.rottink Wrote:
(05-19-2021, 01:19 AM)Alexandre Machado Wrote: We are adding a new method to TIWForm which will do this automagically. You just need to call

IWForm.ReloadAsync;

and it will take care of that for you.

Cheers

Hi Alexandre,

Nice but please check if reload() still should take a parameter. See https://stackoverflow.com/questions/5512...deprecated

Kind regards,
Jeroen.

Hi Jeroen,

thanks for the heads up. Yes, I'm aware that there is an optional parameter that was made deprecated recently.

On the page that you pointed out some users claim that some browsers will ignore the flag. Once IW is still supposed to support some older browsers (like IE), I'm keeping the parameter for now, because I couldn't find any browser that won't work with it. I believe all the browsers will just ingore whatever parameter you pass (true or false) and will always load it the same way.

Later we can change the call and remove the parameter.
Reply
#8
Intraweb does not recognize this method (IWForm1.ReloadAsync)for me in version 15.2.69. Is there a library to include in the uses clause?
Reply
#9
The method is called AsyncReload()
Reply
#10
Ouch, thanks for the correction Jeroen. It is AsyncReload() indeed. Have no idea WTH I was thinking :-)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)