cancel
Showing results for 
Search instead for 
Did you mean: 

Personas 3.0: .setTimeout(): The time interval does not show impact.

Former Member
0 Kudos

Hi Personas experts,

I am trying some UI events that can be triggered by the timeout function. But it seems that the timeout intervel does not effect. My JS look like this:

      setTimeout(myEventHandler(),3000);  //I expect the event handler func to be called after 3 secs.

and

      window.setTimeout(myEventHandler(), 3000);

It seems that no matter which value I used, the handler function is called in the same time interval.

Does anyone have idea why the time interval 3000 does not have impact?

Thanks.

Dong

Accepted Solutions (1)

Accepted Solutions (1)

clemens_gantert
Active Participant
0 Kudos

Hi,

there two things to note to your original question

  1. You have to pass a function to the setTimeout() method. "setTimeout(myEventHandler,3000);" instead of "setTimeout(myEventHandler(),3000); ".
  2. The timeout function is executed, but afterwards the screen is not refreshed, therefore making you believe that that your handler did not work or wasn't executed. You can force a screen refresh if you put the following line at the end of you handler script:
    sap.personas.scripting.executeScriptInternal({src:''});
    This line executes an empty script ( src = '') and then refreshes the screen.

Best Regards,

Clemens

Former Member
0 Kudos

Hi Clemens,

Thanks very much for the great answer. If I knew how to upload a video here, I'd like to show my animation dog moves around the screen . I guess I would be able to make more attractive Personas UI with animations!

Br,

Dong

clemens_gantert
Active Participant
0 Kudos

You're welcome. Glad to hear if works for you.

Cheers,

Clemens

cristin_charbonneau
Participant
0 Kudos

Good morning.

I'm running in to the same issue with what I think is the screen not refreshing.

I have both a field and a label on my flavor. I want an initial value of "30" displayed and then set a time / interval to count down the value every minute until the value reaches zero.

The script is counting down and I can see the countdown in the log but the field / label is not being reset. I have tried combinations of the suggestion above but it isn't working.

I am working in Personas 3.0 SP10 on Slipstream. I have tried adding the script to various screen events and nothing changes.

My script is attached. countdownscript.txt

Any suggestions are greatly appreciated.

Kind Regards,

Cristin

Answers (1)

Answers (1)

0 Kudos

hi dong,

This worked for me:

function doTask(){

  alert("Hello");    

}

setTimeout(doTask,5000);

Sushant

Former Member
0 Kudos

Hi,

The callback func did work (ie was called) in my case, but the issue is:

It did not delay 3000 ms. The function seemed to be called in the same time delay no matter what value was set. Eg, 8000 gave the same time delay.

In your example, what do you mean "worked"? Did you test different values than 5000 and did you see the different time delay? Eg, use 10000, did you get long time delay? Can you confirm this?

Thx.

Dong

zach_shafer
Member
0 Kudos

Looking forward to hearing if you made any progress with this.  I'm doing some testing within Personas 3.0, and am running into a similar issue.  For comparison, the part I am having trouble with is simply clicking a button - here is the code I used:

function pressEnter(){

  session.findById("wnd[0]/tbar[1]/btn[8]").press();

}

setTimeout(pressEnter,5000)

With the above, the button is never 'pushed.'  I've messed with it all afternoon and made no progress.

Did you ever figure out how to get your setTimeout working?

Former Member
0 Kudos

Hi,

Sorry I am busy with other stuff , but give a quick reply: my timeout func is basically showing an image. What I noticed was that the statement just showing a log string did come out after the timeout period, but on UI the image was shown before the timeout period. Don't know why.

Br,

Dong