[英]Primefaces: Select same row in p:dataTable multiple times
I have a simple p:dataTable
which fires an AJAX event when selecting a row: 我有一个简单的p:dataTable
,它在选择一行时会触发AJAX事件:
<p:dataTable var="c" value="#{myBean.dmCars}"
selection="#{myBean.car}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{myBean.select}"/>
<p:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{c.name}"/>
</p:column>
</p:dataTable>
This works fine, but I can only select a row once. 这可以正常工作,但我只能选择一次行。 I want to select the same row multiple times and the event listener of p:ajax
invoked for each click. 我想多次选择同一行,并为每次单击调用p:ajax
的事件侦听器。
Update I think it's because the row has somewhere the state selected . 更新我认为是因为该行在某处选择了状态。 You see the selected row with a grey background in this example: http://www.primefaces.org/showcase/ui/datatableRowSelectionInstant.jsf 在此示例中,您看到带有灰色背景的所选行: http : //www.primefaces.org/showcase/ui/datatableRowSelectionInstant.jsf
@Daniel and @MattHandy, thank you both for your support. @Daniel和@MattHandy,谢谢你们的支持。 I found a solution to this issue: 我找到了解决此问题的方法:
public void select()
{
// Do some stuff
car=null;
}
In the backing bean i set the value holder to null
after I've processed the event. 在处理事件后,我在支持bean中将值持有者设置为null
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.