Elias Pinheiro
Elias Pinheiro

Reputation: 13

When I use filter the buttons does not work properly PrimeFaces

If I only enter in page and I don't use filter, I click in the button and work very well, and I can update the field. But if I use some filter, don't work anymore. Any help? sorry my English by the way. It's like when I do filter the data is lost, and sent null values for the button target.

View:

<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> 

Upvotes: 0

Views: 1438

Answers (1)

Elias Pinheiro
Elias Pinheiro

Reputation: 13

I forgot to put filteredValue in <p:dataTabel> now work the solution:

<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}">

Thanks guys for try to help.

Upvotes: 1

Related Questions