使用动态列和过滤的primefaces dataTable不再更新

时间:2015-08-31 14:34:03

标签: jsf primefaces jsf-2.2

我有一个带有动态列的primefaces数据表,并为显示搜索结果的每列进行过滤。每次使用update="@form"执行搜索后,数据表都会更新。 不幸的是,在用户对列进行过滤之后,数据表不再更新。在执行搜索之后,数据表不显示新的搜索结果,直到用户更改视图并返回到数据表(搜索结果存储在会话中),这将从头开始构建数据表。

这是数据表xhtml:

<p:dataTable id="searchResultTableId" scrollable="true" value="#{curSearch.getSearchResults()}" scrollHeight="300" var="curSearchResult"
    sortMode="multiple" rowKey="#{curSearchResult.hashCode()}" draggableColumns="true" resizableColumns="true" styleClass="hitlistDataTable"
    paginator="true" rows="#{curSearch.hitlistRowsPerPage}" rowIndexVar="rowIndex"
    paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
    rowsPerPageTemplate="#{curSearch.rowsPerPageTemplate}" paginatorPosition="bottom" tableStyleClass="searchResultTable"
    selection="#{curSearch.selectedSearchResults}" widgetVar="hitlistTableVar">

    <p:ajax event="colReorder" update="searchResultTableId :editPropertyFormId:editPropertyDialogId" oncomplete="hitlistTableResized();" />

    <p:ajax event="rowSelect" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="rowUnselect" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="toggleSelect" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="rowSelectCheckbox"
        update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="rowUnselectCheckbox"
        update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="contextMenu" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId"
        oncomplete="PF('searchResultTableContextMenuVar').show(currentEvent);" />

    <!-- double click listener -->
    <p:ajax event="rowDblselect"
        listener="#{editPropertyBL.initForEdit(curSearch.selectedSearchResults.get(0), curSearch.getDataViewDefinition())}"
        oncomplete="PF('editPropertyDialogVar').show();" update=":editPropertyFormId @(.resultlistActionGrid)" />

    <p:column style="width: 16px;">
        <p:rowToggler />
    </p:column>
    <p:column selectionMode="multiple" style="width: 16px; text-align:center; padding-right: 12px;" />

    <p:columns value="#{curSearch.determinePrimaryPropertyNames()}" var="curPrimaryPropName"
        sortBy="#{curSearchResult[curPrimaryPropName].getValue()}" filterBy="#{curSearchResult[curPrimaryPropName].getValue()}"
        filterMatchMode="contains">

        <f:facet name="header">
            <h:outputText value="#{displayNameResolver.resolveDisplayNameOfHitlistProperty(curPrimaryPropName, curSearch)}" />
        </f:facet>

        <ui:param name="curValue" value="#{hitlistBL.generatePropertyValue(curSearchResult, curPrimaryPropName)}" />
        <ui:param name="isDocumentTitle" value="#{hitlistBL.isDocumentTitle(curPrimaryPropName)}" />
        <ui:param name="isChoice" value="#{hitlistBL.isChoice(curPrimaryPropName, curSearch)}" />

        <!-- doc title -->
        <h:panelGroup rendered="#{curSearchResult.isChanged() and (isDocumentTitle)}" style="padding-right: 4px;">
            <i class="fa fa-refresh" />
        </h:panelGroup>
        <!-- <p:commandLink action="#{contentBL.showContentExtern(curSearch.getViewId(), curSearchResult)}" value="#{curValue}" ajax="false"
            rendered="#{(curSearchResult.isOfDataType('STRING', curPrimaryPropName)) and (isDocumentTitle) and (not isChoice)}" target="_blank" /> -->

        <!-- document title -->
        <h:outputText value="#{curValue}" title="#{curSearchResult.getRepresentationsAsString()}"
            rendered="#{(curSearchResult.isOfDataType('STRING', curPrimaryPropName)) and (isDocumentTitle) and (not isChoice)}" />

        <!-- data type STRING -->
        <h:outputText value="#{curValue}"
            rendered="#{curSearchResult.isOfDataType('STRING', curPrimaryPropName) and (not isDocumentTitle) and (not isChoice)}" />

        <!-- data type UUID -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('UUID', curPrimaryPropName) and (not isChoice)}" />

        <!-- data type INTEGER32 -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('INTEGER32', curPrimaryPropName) and (not isChoice)}">
            <f:convertNumber integerOnly="true" groupingUsed="false" />
        </h:outputText>

        <!-- data type DOUBLE -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('DOUBLE', curPrimaryPropName) and (not isChoice)}">
            <f:convertNumber groupingUsed="false" />
        </h:outputText>

        <!-- data type DATETIME -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('DATETIME', curPrimaryPropName) and (not isChoice)}">
            <f:convertDateTime type="both" dateStyle="short" timeStyle="short" timeZone="#{settingsBL.getTimeZoneIdSet()}"
                pattern="#{settingsBL.dateTimePattern}" />
        </h:outputText>

        <!-- CHOICE -->
        <h:outputText value="#{hitlistBL.determineChoiceUiValue(curSearch.getViewId(), curSearchResult, curPrimaryPropName)}"
            rendered="#{(not isDocumentTitle) and (isChoice)}" />

    </p:columns>

    <p:rowExpansion>
        <h:panelGrid id="addPropsOuterGridId" cellpadding="0" cellspacing="0" columns="2" columnClasses="expRowImage, expRowProps"
            styleClass="resultListRowExpansionGrid">
            <h:panelGroup style="height: 200px;">
                <p:graphicImage value="#{imageCacheBean.image}" height="200" cache="false"
                    rendered="#{curSearchResult.isContentRepresentationWithNameExisting('thumbnails')}">
                    <f:param name="searchTabId" value="#{curSearch.getTabId().toString()}" />
                    <f:param name="searchViewId" value="#{searchViewBL.getSelectedSearchViewId().toString()}" />
                    <f:param name="searchPid" value="#{curSearchResult.getPid().getPidString()}" />
                </p:graphicImage>
            </h:panelGroup>

            <p:dataGrid id="addPropDataGridId" var="curSecondaryPropName" value="#{curSearch.determineSecondaryPropertyNames()}" columns="1"
                layout="grid" styleClass="hitlistAdditionalPropDataGrid" emptyMessage="">

                <ui:param name="isChoice" value="#{hitlistBL.isChoice(curSecondaryPropName, curSearch)}" />

                <h:panelGrid id="addPropsInnerGridId" columns="2" cellpadding="0" cellspacing="0"
                    columnClasses="hitlistAddPropLabel, hitlistAddPropValue" style="width: 100%;">
                    <h:outputText value="#{displayNameResolver.resolveDisplayNameOfHitlistProperty(curSecondaryPropName, curSearch)}: " />

                    <ui:param name="curSecondaryValue" value="#{hitlistBL.generatePropertyValue(curSearchResult, curSecondaryPropName)}" />

                    <!-- data type STRING -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('STRING', curSecondaryPropName) and (not isChoice)}" />

                    <!-- data type UUID -->
                    <h:outputText value="#{curSecondaryValue}" rendered="#{curSearchResult.isOfDataType('UUID', curSecondaryPropName) and (not isChoice)}" />

                    <!-- data type INTEGER32 -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('INTEGER32', curSecondaryPropName) and (not isChoice)}">
                        <f:convertNumber integerOnly="true" groupingUsed="false" />
                    </h:outputText>

                    <!-- data type DOUBLE -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('DOUBLE', curSecondaryPropName) and (not isChoice)}">
                        <f:convertNumber groupingUsed="false" />
                    </h:outputText>

                    <!-- data type DATETIME -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('DATETIME', curSecondaryPropName) and (not isChoice)}">
                        <f:convertDateTime type="both" dateStyle="short" timeStyle="short" timeZone="#{settingsBL.getTimeZoneIdSet()}"
                            pattern="#{settingsBL.dateTimePattern}" />
                    </h:outputText>

                    <!-- CHOICE -->
                    <h:outputText value="#{hitlistBL.determineChoiceUiValue(curSearch.getViewId(), curSearchResult, curSecondaryPropName)}"
                        rendered="#{isChoice}" />

                </h:panelGrid>
            </p:dataGrid>
        </h:panelGrid>
    </p:rowExpansion>

</p:dataTable>

1 个答案:

答案 0 :(得分:1)

您需要在搜索按钮时清除过滤。 使用  您的数据表的widgetVar="hitlistTableVar"然后

命令按钮上的

清除过滤器。

 oncomplete="hitlistTableVar.clearFilters();"

希望它能解决你的问题。

`