如何在 JSF 中创建计时器
我想创建一个在线测试系统,所以我需要一个计时器。当用户开始测试时,计时器将开始倒计时。但是,当用户转到下一个问题刷新页面时,计时器仍将运行。我怎样才能做到这一点任何建议?
I want to create an online test system, so i need a timer. When user start the test the timer will start counting down. But when user go to next question refresh the page the timer will still running. How can I do that any suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 PrimeFaces 投票 选项。
计数器将始终保存在服务器上。
You can use PrimeFaces Poll option.
The counter will always be saved on the server.
您还可以使用 PrimeFaces Extensions,它们的 API 中有计时器 。
示例:您将测试开始放入
@SessionScoped
bean,然后计算剩余秒数,该秒数将用作
元素的输入:然后您的test.xhtml 将包含元素
You can also use PrimeFaces Extensions, they have timer in their API.
Example: you put start of the test into
@SessionScoped
bean, then calculate seconds remaining which will be used as an input to<pe:timer>
element:and then your test.xhtml would contain element