JSF:在 backingBean 仍在工作时显示页面
也许这个标题不太准确,但问题就在这里。 我正在做一些 JSF 项目,我需要以下内容:
当用户登录我的应用程序时(即,当他导航到主页时),需要一种从互联网和/或数据库获取一些货币汇率的方法叫。该方法的执行(页面解析、数据保存等)大约持续 5-6 秒。我不希望从登录到主页的导航持续 5-6 秒,我希望发生以下其中之一(尚未决定哪一个):
1)当用户登录时,他会看到主页(立即,而不是5-6 秒后)并且能够在方法在后台工作时单击和/或导航。
2)当用户登录时,他(立即)看到主页,一些加载登录到页面的一部分,并且在执行方法后,他看到带有汇率的数据表。
问题是,如何做到这一点? 如果我将该方法放在 HomePageBean 构造函数中,则在执行方法之前不会显示页面。也许我可以在主页上放置一些不可见的元素,并在某些 Getter 中调用该方法,但我不知道这是否是正确的方法(看起来像 hack)或者它实际上是否有效。
我正在使用 JSF 2.0 和 Primefaces。 提前致谢
maybe this title is not really precise, but here's the problem.
I'm doing some JSF project and I need a following:
When user logs on my application (ie. when he navigates to Home page), a method, which gets some money exchange rates from the internet and/or database, needs to be called. The execution of that method (page parsing, data saving etc.) lasts about 5-6 seconds. I don't want that navigation from Login to Home page lasts 5-6 seconds, i want one of these (didn't decide which one yet) to happen:
1) When user logs in, he sees Home page (immediately, not after 5-6 seconds) and is able to click and/or navigate while method is working in background.
2) When user logs in, he sees Home page (immediately), some loading sign in one part of the page and after method is executed, he sees dataTable with exchange rates.
Question is, how to do any of this?
If I put that method in HomePageBean constructor, page wont be displayed until method is executed. Maybe i can put some invisible element on Home page and call that method within some Getter, but i don't know if that's the right way to do (seems like hack) or will it actually work.
I'm using JSF 2.0 and Primefaces.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ApplicationScoped bean,如下例所示:
这是访问应用程序范围 bean 的支持 bean。
Use ApplicationScoped bean like in example below:
And here is your backing bean accessing application-scoped bean.