Simple Javascript Countdown

I need a simple Countdown Clock. I know there is a Lib for that but I don’t need all those fancy features and think this is a little op for my project.
Im using vaadin 6 (just for the records)

My first try was kinda simple. I’ve built a javascript countdown function and put it into a Label with content type “XHTML”.
As you’ve guessed right. It didn’t work.

Is it possible to create such a minimalistic timer?

lg Coco

The easiest and cleanest way in Vaadin 7 would be to create it as a Javascript Component.
When it comes to Vaadin 6 the cleanest way would probably be to create a small Custom GWT widget which adds the html and js to the page. (You might have to look a bit in html+js integration in GWT if you want to go this way)
You might also be able to do it with the Label but you have to execute the JS on some kind of event and not inside a
(
https://vaadin.com/forum#!/thread/71598/2380825
). Maybe even Window.executeJavascript() might help if you e.g. add a

with a specific id using Label with XHTML and then somehow find the div inside the executeJavascript Javascript code and run your timer on it.

I cannot use Vaadin7 because I’m extending the Activiti-Explorer, wich is based on Vaadin 6.8.8.

Ive already tried it with Windows.executeJavaScript… but it didn’t work ether.
I made a alertbox appear when the page loaded. (this has worked out great for me)
With larger JS-sources the function wasn’t defined (not callable via Firebug-console.
Maybe I need to build a better JS-Load funcition.

Yeah it seems like functions stop existing when defined inside an event as soon as it ran one time…
You could add a custom script tag containing the function to the header by extending ApplicationServlet and then overriding a method called writeAjaxPageHeader (or something like this) where you can use page.append() to add new content to the of the site. Here is a small example (
https://vaadin.com/forum#!/thread/96973
).
I still think that a small GWT widget would be the better/cleaner solution though.

ok the page.append… solution worked. Thanks !