我在 JSF2应用程序中使用 Primefaces。我有一个 <p:dataTable>
,我希望用户能够直接对单独的行执行各种操作,而不是选择行。为此,我在上一篇专栏文章中介绍了几个 <p:commandLink>
。
我的问题是: 如何将行 ID 传递给由命令链接启动的操作,以便我知道要对哪一行进行操作?我尝试使用 <f:attribute>
:
<p:dataTable value="#{bean.items}" var="item">
...
<p:column>
<p:commandLink actionListener="#{bean.insert}" value="insert">
<f:attribute name="id" value="#{item.id}" />
</p:commandLink>
</p:column>
</p:dataTable>
但它总是产生0-显然行变量 f
不可用时,属性呈现(它工作时,我使用一个固定的值)。
有人有别的办法吗?