简体   繁体   English

JSF:在2个视图之间传递数据

[英]JSF : Passing data between 2 views

I'm a french computer science student, and I have a small JSF project for school. 我是法国的计算机科学专业的学生,​​并且有一个用于学校的小型JSF项目。 I'm a little bit noob and I try to pass data between 2 view but I fail. 我有点菜鸟,我尝试在2视图之间传递数据,但失败了。

First I have a view which list all my customers, in a datatable. 首先,我有一个视图,该视图在数据表中列出了所有客户。 In this datatable I have a link to show a customer profile. 在此数据表中,我有一个链接来显示客户资料。 I use, for both view, a CustomerController which is a requestscoped managedbean. 对于这两种视图,我都使用一个CustomerController,它是一个requestscoped托管bean。

Before I use a global sessionscoped controller but I think it's not the good way to pass data. 在使用全局sessionscoped控制器之前,但我认为这不是传递数据的好方法。

Then I found this article : JSF Best Practices , it recommend to use to pass object between views. 然后我找到了这篇文章: JSF Best Practices ,它建议使用在视图之间传递对象。 I didn't manage to make it work. 我没有设法使它工作。

And finally I found also this question from Stackoverflow : f:setPropertyActionListener sets null value instead of intended value which use 最后我也从Stackoverflow中发现了这个问题: f:setPropertyActionListener设置了空值,而不是使用的预期值

My question is : what is the best ways to pass data ? 我的问题是:传递数据的最佳方法是什么? And how manage it ? 以及如何管理呢?

It's explained in this article from BalusC. BalusC在本文对此进行了解释。 You need to send id of your selected item to second view through h:link and catch it then with <f:event> . 您需要通过h:link将所选项目的ID发送到第二个视图,然后使用<f:event>捕获。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM