页面加载后将列表绑定到数据表(不是延迟加载)
我们的页面有一个数据表,显示来自网络服务的记录。 Web 服务查询数据库,查询可能需要 10 秒到 100 秒。
我最初在支持 bean 构造函数中加载绑定到数据表的数组列表:
private ArrayList myList;
public MyBean
{
myList = WebServices.getList();
}
在这种情况下,整个页面仅在 Web 服务返回所有数据后才开始呈现。
我应该在哪里调用 web 服务(即,执行 myList = WebServices.getList();
)以便并行加载页面的其余部分,并在数据表中显示进度条或其他内容网络服务运行吗?
我想我关于 JSF/IceFaces 生命周期的概念还不清楚...
另外,这与延迟加载无关,因为为此我们也必须在数据库查询中实现分页。
谢谢!
Our page has a datatable which shows records from a web service. The web service queries a database, and the query can take from 10 secs to 100 secs.
I was initially loading the arraylist binded to the datatable in the backing bean constructor:
private ArrayList myList;
public MyBean
{
myList = WebServices.getList();
}
In this scenario, the entire page starts to render only after the web service returns all data.
Where should I call the webservice (i.e., do myList = WebServices.getList();
) in order to have the rest of the page load in parallel, and show a progress bar or something in the datatable while the webservice runs?
I guess my concepts about the JSF/IceFaces lifecycle are not clear...
Also, this is not about lazy loading, because for that we would have to implement pagination in our datatabase query, too.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了使用线程的解决方法。
最初我不知道
PersistentFacesState
和executeAndRender();
,因此即使线程会更新数组列表,视图也不会刷新。这是因为 JSF/IceFaces 生命周期已经结束。保留视图然后重新渲染它也解决了这个问题。
希望这个解决方案可以帮助某人。
I found a work around using Threads.
Initally I was not aware of the
PersistentFacesState
andexecuteAndRender();
, so even though the thread would update the array list, the view wasn't being refreshed. This was because the JSF/IceFaces lifecycle had already ended.Persisting the view and then re-rendering it solved this problem, too.
Hope this solution helps someone.