[英]commandLink in primefaces datatable doesn't work if I add the filteredValue attribute
I have a primefaces datatable with a <p:commandLink>
in each row. 我有一个primefaces数据表,每行中都有一个<p:commandLink>
。 The user clicks it to see a different page with details about the record he selected. 用户单击它可以看到另一个页面,其中包含有关所选记录的详细信息。 It was working fine until I add a filteredValue in my datatable. 在我向数据表中添加filteredValue之前,它一直运行良好。 I need this attribute (filteredValue) in order to correctly filter and sort my datatable, as shown in this question . 我需要此属性(filteredValue)以便正确过滤和排序我的数据表,如本问题所示。
But after adding this attribute, my commandLink stops working. 但是添加此属性后,我的commandLink停止工作。 How can I make it work with the attribute? 如何使它与属性一起使用?
Here's my datatable: 这是我的数据表:
<p:dataTable var="prot" value="#{myBean.listaProtocolos}" rows="15" filteredValue="#{myBean.listaProtocolosFiltrados}" sortBy="#{prot.dataEntradaArea}" sortFunction="#{myBean.sortXMLDatas}" sortOrder="descending" paginator="true" style="font-size: 0.9em;" paginatorPosition="bottom">
<p:column filterBy="${prot.nrProtocolo}" filterMatchMode="contains" width="8%" style="text-align:center">
<f:facet name="header">ID</f:facet>
<p:commandLink action="#{myBean.verDetalhesProtocolo}" process="@this messages" update="@this messages">
<h:outputText value="#{prot.nrProtocolo}" style="text-decoration: underline;"/>
<f:setPropertyActionListener target="#{myBean.nrProtocolo}" value="#{prot.nrProtocolo}" />
</p:commandLink>
</p:column>
(etc)
and the relevant pieces of myBean: 以及相关的myBean部分:
public void verDetalhesProtocolo() {
for(ProtocoloMY pro : this.listaProtocolos){
if(pro.getNrProtocolo().trim().equalsIgnoreCase(this.nrProtocolo.trim())) {
this.protocolo = new ProtocoloMY(pro);
break;
}
}
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.getExternalContext().redirect("detalhes_protocolo_processo.xhtml");
//(This method isn't even called when I add the attribute filteredValue to my datatable)
public String getNrProtocolo() {
return nrProtocolo;
}
public void setNrProtocolo(String nrProtocolo) {
this.nrProtocolo = nrProtocolo;
}
public List<ProtocoloMY> getListaProtocolos() {
return listaProtocolos;
}
public List<ProtocoloMY> getListaProtocolosFiltrados() {
return listaProtocolosFiltrados;
}
public void setListaProtocolosFiltrados(List<ProtocoloMY> listaProtocolosFiltrados) {
this.listaProtocolosFiltrados = listaProtocolosFiltrados;
}
public void setListaProtocolos(List<ProtocoloMY> listaProtocolos) {
this.listaProtocolos = listaProtocolos;
}
And I almost forgot to say: There's some network traffic happening when I click the link, but nothing is shown in my backend console and the method in my bean isn't called. 我几乎忘了说:单击链接时发生了一些网络流量,但是后端控制台中没有显示任何内容,并且未调用bean中的方法。
I'm running primefaces v6.0. 我正在运行primefaces v6.0。
为了使PrimeFaces能够通过其唯一ID跟踪哪一行,您需要使用行POJO中使其唯一的值添加属性rowKey =“#{row.id}”到p:datatable中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.