cancel
Showing results for 
Search instead for 
Did you mean: 

Count Down Timer in Webdynpro

Former Member
0 Kudos

Hello All,

I am in need to implement a <b>count down timer</b> for an online application developed in Webdynpro. The count down timer logic is available as a java script file.

Options tried out till now..

1. Included the the html file with java script into src/mimes/components

2. Create a IFrame and provide the src file as the html file.

Works fine. But ...

- The problem with this option is when any action happens (eg. a button click), the same refreshes the entire view that makes the timer to start from first.

Does anybody have any alternative solutions to implement this functionality. Kindly reply.

Thanks & Regards,

Venkat.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Venkat,

Try the following: pass timeout as parameter of html file (i.e. countdown.html?timeout=987654321). In HTML file access this parameter with JavaScript.

Now on WD side you should:

1. Make URL of IFrame bound to context attribute (so you can alter it)

2. Track "start" time.

3. URL attribute must be calculated, it returns static part of URL + timeout parameter as delta between current time and start time.

This will only work if WD let you pass URL parameter to mime resource.

VS

Former Member
0 Kudos

Hi Valery,

Thanks for your immediate reply.

Would like to explain my scenario bit more clearly:

1. I have an online test appln that would run for a specific time period say 2 hrs (7200 secs)

2. On completion of the 2 hrs time, the application has to naviage automatically from the main screen to another screen notifying completion of exam.

Checked out with TimedTrigger object (& Java script) specifics in your earlier post, which specifies triggering of events after a particular delay (in secs).

Would appreciate your kind help with this regard.

PS: If you have any document specifying the steps regarding passing timeout as parameter of html file, kindly send it across to venkat6531@yahoo.com

Thanks & Regards,

Venkat.

Former Member
0 Kudos

Venkat,

Then it seems the scenario is possible without JS at all.

1. Bind <b>delay</b> of <b>TimedTrigger</b> to read-only calculated context attribute of type <b>integer</b>, say its name is <i>Timeout</i>.

2. Define private view controller variable startTime:


//@@begin others
private long startTime;
//@@end

3. In wdDoInit initialize this variable as:

startTime = System.currentTimeMillis();

4. In generated getter for <i>Timeout</i> attribute write the following:


return Math.max(1, (int) ( ( System.currentTimeMillis() - startTime ) / 1000 - 7200));

This way TimedTrigger delay will be updated after every client-server request, so even user hit some buttons or links, total delay will be approx. the same. The only way to stop this self-updating timer is to navigate away from view -- answer to questions andl click submit. Otherwise TimedTrigger will fire event.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Oops...

In [4] formula is broken, should be:

return Math.max(1, (int) ( ( startTime - System.currentTimeMillis() ) / 1000L + 7200));

VS

Former Member
0 Kudos

Hi Valery,

Thanks a lot for your reply.

A few more to clarify from my side:

a) When will this method getTimeout() of the calculate attribute will be called and return the value.

b).Can i directly set the delay to 7200sec in the timer UI property delay.

I am not sure how this calculated attribute will react.

Kindly advise.

PS: Points rewarded.

Regards,

venkat.

Former Member
0 Kudos

Venkat,

a). getTimeout() will be called every time WD renders response to client -- after action handling (for Button, Link2Action ect) and after internal events like scrolling in table.

b). No, you have to use formula here instead of constant. Otherwise after every action the TimedTrigger delay will be 7200. And in my solutions it will be the remaining part of 7200

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

P.S. I'm writing blog post with sample project that describes this solution.

Former Member
0 Kudos

Venkat,

Also you have marked this question as answered... just for sake of completeness:

/people/valery.silaev/blog/2006/11/27/final-countdown

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Hi,

Thanks a lot for this post.

In my scenario, the password shown in the UI need to be vanished after 5 mins.

I followed this post and trigger a dummy event.The page is refreshed after 300 secs in my case.

After the 5 mins refresh in the UI, the page is still getting refreshed for every 1 sec. Is there any way to stop this?

Regards,

Senthil

Former Member
0 Kudos

Hi ,

Can someone help on my query?

How to stop the page loading/refresh happening every 1 sec after the TimedTrigger event?

Basically it should refresh once with the delay of 5 mins so that the password shown in the UI will be removed.

After that there should not be any refresh.

Thanks in adavance!

Regards,

Senthil

Answers (0)