[英]JSF 2.0 Passing object between request scope beans using a link
for some time I'm trying to pass an object between two pages, that are using different managed beans. 一段时间以来,我试图在使用不同托管bean的两个页面之间传递对象。 I'm using jsf 2.1 and primefaces 3.1. 我正在使用jsf 2.1和primefaces 3.1。
My case: 我的情况:
I've tried sending some parameters from page 1 as GET request and process them from page 2. It works, but this is not the solution I want. 我尝试从第1页发送一些参数作为GET请求并从第2页处理它们。它可以工作,但这不是我想要的解决方案。 I need the whole object that was selected. 我需要选择的整个对象。 I was thinking to pass it in the request map, or to declare the bean responsible for page 1 as @SessionScoped and to inject this bean from the second one. 我正在考虑在请求映射中传递它,或将负责第1页的bean声明为@SessionScoped,并从第二个bean注入该bean。
What I don't succeed is to find out which object was selected before changing the page. 我没有成功的是在更改页面之前找出选择了哪个对象。 I've tried using ajax, or an actionListener for the link tags, but nothing works. 我尝试使用ajax或actionListener作为链接标签,但没有任何效果。 Before performing the actionListener or the ajax event, the page is changed... 在执行actionListener或ajax事件之前,页面已更改...
How can I first set the selected object/row and only after that change the page? 如何首先设置选定的对象/行,然后才更改页面?
Thank you for your help. 谢谢您的帮助。
Instead of using h:link
, you would want to use p:commandLink
, set the selected object in actionListener
, and change the page in oncomplete
phase, with a javascript line like location = 'page2.xhtml';
与其使用h:link
, actionListener
使用p:commandLink
,在actionListener
设置选定的对象,并使用诸如location = 'page2.xhtml';
类的javascript行在oncomplete
阶段更改页面location = 'page2.xhtml';
. 。
You can find the related tag documentation below. 您可以在下面找到相关的标签文档。 It also exists in version 3.1. 它也存在于3.1版中。
http://www.primefaces.org/docs/vdl/3.4/primefaces-p/commandLink.html http://www.primefaces.org/docs/vdl/3.4/primefaces-p/commandLink.html
PS: Either page 1 or page 2 still needs to be session-scoped, otherwise it won't work. PS:第1页或第2页仍然需要进行会话作用域检查,否则它将无法工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.