Jsf primefaces dataTable具有动态列,并且过滤不再更新

Jsf primefaces dataTable具有动态列,并且过滤不再更新,jsf,primefaces,jsf-2.2,Jsf,Primefaces,Jsf 2.2,我有一个primefaces数据表,其中包含动态列,并对显示搜索结果的每一列进行过滤。每次执行搜索后,都会使用update=“@form”更新数据表。 不幸的是,在用户对列进行筛选之后,数据表不再更新。执行搜索后,数据表不会显示新的搜索结果,直到用户更改视图并返回到数据表(搜索结果存储在会话中),这将从头构建新的数据表 这是数据表xhtml: <p:dataTable id="searchResultTableId" scrollable="true" value="#{curSearch

我有一个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>

在执行“搜索”按钮时,需要清除筛选。 使用
widgetVar=“hitlistTableVar”
用于数据表,然后

在命令按钮上清除过滤器

 oncomplete="hitlistTableVar.clearFilters();"
希望它能解决你的问题


`

您在控制台或页面源代码中有任何错误吗?没有javascript错误,服务器端也没有异常。代码中的更新=“@form”在哪里?您是否在数据表中处理筛选器事件?您是否用h:form标记包围了您的数据表?是否在数据表中指定了filteredValue属性?请进行mcve…使用搜索按钮完成更新:
清除筛选器后,数据表将更新…谢谢。我提到的tabView问题似乎是另一个问题。在过去的两天里,我调查了这个clearFilters()调用所带来的一个错误。请参阅在AJAX更新后调用Javascript表函数将触发第二个AJAX请求,这可能会导致问题。因此,我建议在服务器端的第一个请求中清除过滤器。如果尚未使用EL表达式,请将其绑定。