如果我只进入页面并且我不使用过滤器,我点击按钮并且工作得非常好,我可以更新该字段。但如果我使用一些过滤器,就不再工作了。有帮助吗?对不起我的英语顺便说一句。这就像我过滤数据时丢失,并为按钮目标发送空值。
查看:
<h:form>
<p:commandButton style="margin-bottom: 10px;" value="Criar Produto de catalogo" action="admin_create_cProduct?faces-redirect=true" />
<br />
<p:dataTable
var="cProduct"
widgetVar="cProductTable"
summary="Lista de produtos de catalogo"
value="#{administratorManager.catalogProduct}"
emptyMessage="No catalog product found" rows="25" paginator="true"
paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,25,50">
<p:column filterBy="#{cProduct.reference}" headerText="Reference" filterMatchMode="contains">
<h:commandLink
value="#{cProduct.reference}"
action="admin_edit_cProduct?faces-redirect=true">
<f:setPropertyActionListener target="#{administratorManager.ccProduct}" value="#{cProduct}" />
</h:commandLink>
</p:column>
<p:column filterBy="#{cProduct.medicalPrecription}" headerText="Prescrição Medica" filterMatchMode="equals">
<f:facet name="filter">
<p:selectOneButton onchange="PF('cProductTable').filter()">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="True" itemValue="true" />
<f:selectItem itemLabel="False" itemValue="false" />
</p:selectOneButton>
</f:facet>
<h:outputText value="#{cProduct.medicalPrecription ? 'True': 'False'}" />
</p:column>
<p:column filterBy="#{cProduct.name}" headerText="Nome:" filterMatchMode="contains">
<h:outputText value="#{cProduct.name}" />
</p:column>
<p:column filterBy="#{cProduct.laboratory}" headerText="Laboratorio:" filterMatchMode="contains">
<h:outputText value="#{cProduct.laboratory}" />
</p:column>
<p:column filterBy="#{cProduct.activePrinciple}" headerText="Principio ativo" filterMatchMode="contains">
<h:outputText value="#{cProduct.activePrinciple}" />
</p:column>
<p:column filterBy="#{cProduct.price}" headerText="Preço" filterMatchMode="contains">
<h:outputText value="#{cProduct.price}€" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Stocks" />
</f:facet>
<h:commandLink value="Ver Stocks" action="admin_list_cProductStock?faces-redirect=true" >
<f:setPropertyActionListener target="#{administratorManager.ccProduct}" value="#{cProduct}" />
</h:commandLink>
</p:column>
</p:dataTable>
</h:form>
答案 0 :(得分:1)
我忘了将filteredValue
放入<p:dataTabel>
现在解决方案:
<p:dataTable
var="cProduct"
widgetVar="cProductTable"
summary="Lista de produtos de catalogo"
value="#{administratorManager.catalogProduct}"
emptyMessage="No catalog product found" rows="25" paginator="true"
paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,25,50" filteredValue="#{administratorManager.filteredcProduct}">
感谢各位帮忙。