I know this looks like a lot of text, but I think it's a pretty simple concept I'm missing.
我知道这看起来像很多文字,但我认为这是一个非常简单的概念,我不知道。
I'm writing a web application with Facelets. I've got a custom tag rq:request-list that takes a list of requests as a parameter and outputs a lovely table to display them. So far, so good.
我正在使用Facelets编写Web应用程序。我有一个自定义标记rq:request-list,它将请求列表作为参数输出并输出一个可爱的表来显示它们。到现在为止还挺好。
rq:request-list starts out like you'd expect:
rq:请求列表就像你期望的那样开始:
<!-- ... -->
<ice:dataTable value="#{list}" var="req">
<ice:column>
<f:facet name="header">Date last edited</f:facet>
<ice:outputText value="#{req.dateModified}" />
</ice:column>
<!-- ... -->
And that turns out just fine. It even has a link in the table to edit the request. Yippee!
结果很好。它甚至在表格中有一个链接来编辑请求。 yippee的!
<ice:column rendered="#{spokespersonView}">
<f:facet name="header">Edit</f:facet>
<h:commandLink value="Edit" action="edit_r" rendered="#{RequestSessionBean.mutable}">
<f:setPropertyActionListener target="#{RequestSessionBean.request}" value="#{req}"/>
</h:commandLink>
</ice:column>
That takes us to the editing page, after setting the request in the backing bean to the one represented by the table row we're at. This is where the problem's at. And it's subtle.
在将支持bean中的请求设置为我们所在的表行所代表的请求之后,这将我们带到编辑页面。这就是问题所在。它很微妙。
rq:request-list is used several times in one page; as such:
rq:request-list在一个页面中多次使用;因此:
<ui:repeat value="#{ExperimentListBean.usersExperiments}" var="exp">
<rq:request-list list="#{RequestListBean.requestsByExperiment[exp]}" showExperiment="false" spokespersonView="true" />
</ui:repeat>
Now the tables appear OK; that is, all the text is right. However, the commandLinks point to the wrong Requests ... they point to the Request of the corresponding row of the last rq:request-list on the page. The data pertaining to the Requests is outputted as it should be in the table, but {req} points to the wrong request when it comes to clicking on a commandLink.
现在表格显示正常;也就是说,所有文字都是正确的。但是,commandLinks指向错误的请求...它们指向页面上最后一个rq:request-list的相应行的请求。与请求有关的数据应该在表中输出,但{req}指向单击commandLink时的错误请求。
To reiterate, if I have a few rq:request-lists on a page, the Edit link for the first row of every rq:request-list points to the first request (row) in the last rq:request-list on the page. The Edit link for the second row of every rq:request-list points to the second request (row) of the last rq:request-list on the page. Etc.
重申一下,如果我在页面上有几个rq:request-lists,则每个rq:request-list的第一行的Edit链接指向页面上最后一个rq:request-list中的第一个请求(行) 。每个rq:request-list的第二行的Edit链接指向页面上最后一个rq:request-list的第二个请求(行)。等等。
How can I get {req} to point to what I it was, and not just be an index in a list that is outdated?
我怎样才能{req}指出它是什么,而不仅仅是过时的列表中的索引?
Thanks!
1 个解决方案
#1
Take a look at this blog entry, you probably use repeat which is executed once, when the component tree is build, instead of foreach which get evaluated at rendering time. (But this is just a shot in the dark, I don't tried your example)
看一下这篇博客文章,你可能会使用在构建组件树时执行一次的repeat,而不是在渲染时得到的foreach。 (但这只是一个黑暗中的镜头,我没试过你的例子)
#1
Take a look at this blog entry, you probably use repeat which is executed once, when the component tree is build, instead of foreach which get evaluated at rendering time. (But this is just a shot in the dark, I don't tried your example)
看一下这篇博客文章,你可能会使用在构建组件树时执行一次的repeat,而不是在渲染时得到的foreach。 (但这只是一个黑暗中的镜头,我没试过你的例子)