lundi 27 février 2017

Select many checkbox ajax update view on second event

I'm trying to filter a datatable on categories using a select selectManyCheckbox. The idea is that when a checkbox is clicked, the datatable values are updated. Now the problem is that the values are updated after selecting a checkbox twice, but this results in a datable with incorret values. Here is my xhtml page.

<p:layout id="dossierLayout" widgetVar="dossierLayout">
                <p:layoutUnit id="categoriesLayoutUnit" position="west"
                              header="#{msg['dossier.page.layoutWest.header']}">
                    <p:selectManyCheckbox id="dossierCategories" value="#{dossierBean.dossierFileCategoriesFilter}"
                                          layout="pageDirection" columns="1" converter="dossierCategorieConverter" immediate="true">

                        <f:selectItems value="#{dossierBean.dossierFileCategorieList}" var="dossierCategorie"
                                       itemLabel="#{dossierCategorie.categorieDescription}"
                                       itemValue="#{dossierCategorie}"/>
                        <p:ajax listener="#{dossierBean.filterfiles}" update="dossierForm:dossierFiles" />
                    </p:selectManyCheckbox>
                </p:layoutUnit>

                <p:layoutUnit id="dossierFilesLayoutUnit" position="center">
                    <p:dataTable id="dossierFiles" value="#{dossierBean.filteredFiles}" widgetVar="dossierFiles" filteredValue="#{dossierBean.filteredFiles}" var="dossierFile">

                        <f:facet name="header">
                            <p:outputPanel>
                                <h:outputText value="#{msg['dossier.page.datatable.globalSearch.label']}"/>
                                <p:inputText id="dossierNameFilterInput" value="#{dossierBean.dossierNameFilter}"/>
                                <p:watermark id="dossierNameFilterInputWaterMark" for="dossierNameFilterInput" value="#{msg['dossier.page.layoutWest.header.watermark']}"/>
                            </p:outputPanel>
                            <p:commandButton id="dossierNameFilterSearch" value="#{msg['cmn.search']}" actionListener="#{dossierBean.filterFilesByName}" update="dossierFiles"/>
                            <p:commandButton id="dossierNameFilerSearchEmpty" value="#{msg['cmn.clear']}" actionListener="#{dossierBean.clearFilterName}" update="dossierFiles"/>
                        </f:facet>

                        <p:column id="dossierFileName" filterBy="#{dossierFile.nameDocument}" filterStyle="display: none;" filterMatchMode="contains" headerText="#{msg['dossier.page.datatable.columheader.Name']}">
                            <h:outputText styleClass="#{dossierFile.dossierFileIcon.docType}"/>
                            <h:outputText value="#{dossierFile.nameDocument}"/>
                        </p:column>

                        <p:column id="dossierFileLastChanged" headerText="#{msg['dossier.page.datatable.columheader.Date']}">
                            <h:outputText value="#{dossierFile.dateLastChange}"/>
                        </p:column>

                        <p:column id="dossierFileUser" headerText="#{msg['dossier.page.datatable.columheader.User']}">
                            <h:outputText value="#{dossierFile.user}"/>
                        </p:column>

                        <p:column id="dossierFileCategorie" headerText="#{msg['dossier.page.datatable.columheader.Categorie']}">
                            <h:outputText value="#{dossierFile.categorie.categorieDescription}"/>
                        </p:column>

                        <p:column id="dossierFileLocation" headerText="#{msg['dossier.page.datatable.columheader.Location']}">
                            <h:outputText value="#{dossierFile.nameFolder}"/>
                        </p:column>

                    </p:dataTable>
                </p:layoutUnit>
             </p:layout>




Aucun commentaire:

Enregistrer un commentaire