You will need to write a simple stopwatch state machine. You can wrap it up as a simple widget to display the time. Basically you just need to track the current time and decrement it every second.
This has been discussed before on StackOverflow here. See the use the GWT Timer in the bottom answer. You'll also want to have some functions to convert seconds to formatted time to display it in your widget. You could use some GWT formatters on the Date object, or just write your own functions since the math is simple.
You'll want to check on the start time/ elapsed time on the server side too since a mildly talented use could hack the browser side timer. The possible trouble point here is that there is no guarantee that your timer and the serverside will match, since JS could lose time if there was contention for the browser thread, and neither side is an RTC. The last thing you'd want is for someone to finish in time, but get rejected by the server when submitted because they were overtime.
Sincerely,
Joseph
On Thursday, May 31, 2012 6:56:21 AM UTC-4, Harshal Patil wrote:
Hi Joseph,I am creating online exam portal.In that i have to specify some time e.g 1 hour to end the exam.also it will automatically decrements the time in the 1 second of interval i.e. 1:00 hr, 00:59 hr, 00:57-----------------------------------------00:00 hr. so it will automatically ends the exam after 1 hour of interval.I have to show that decrementing timer on the panel.
On Thursday, May 31, 2012 1:43:54 AM UTC+5:30, Joseph Lust wrote:Harshal,Why do you need to add the timer to a panel? What do you want the timer to do? It is not clear from your question.Timer timer = new Timer();Sincerely,Joseph
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/DqHWr5rW--YJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment