数据表的Primefaces数据变得混乱

时间:2015-09-01 13:17:16

标签: jsf-2 primefaces jsf-2.2

对不起标题,但我必须解释我想做什么以及什么不起作用。我使用JSF 2.2.10和primefaces 5.2.6的web ui在模型上显示了搜索掩码和搜索结果。 每个搜索实例都显示为tabView中的标签。单击选项卡后,其相应的搜索实例将显示在tabView中的dataTable下。在搜索模板上创建搜索实例,因此不同的搜索实例可以具有不同的输入字段和不同的结果字段(数据表中的列)。 无论是否更改了搜索字段,用户都可以再次执行对现有搜索实例的搜索。这是我的问题......直到用户第二次执行搜索实例,他才会工作。现在,当tabView中的选项卡发生更改时,将抛出异常并且javascript控制台显示“请求返回错误:parsererror primefaces.js.jsf?ln = primefaces $ v = 5.2.6:1&#” 39; 现在,例如搜索实例1的数据与搜索实例2混合。来自搜索实例1的结果字段(数据表列)试图从搜索实例2获得,但是这可能失败。 只有在第二次执行搜索实例时才会出现这种情况。如果没有第二次执行,我可以在选项卡之间进行更改我想我的数据结构还可以。 课程SearchInstance""""选项卡并包含SearchResult列表。此SearchResultMap,其中包含结果字段。

这是tabView的xhtml。 tabView仅在此处用作触发器。选项卡实际上不包含dataTable及其组件,它仅更新表单,内容包含在tabView下:

<h:form id="searchInstancesFormId">
    <p:tabView id="searchTabViewId" value="#{searchBL.searchInstances}" var="curSearch" activeIndex="#{searchBL.activeTabIndex}">
        <p:ajax event="tabChange" oncomplete="resizeResultViews();" listener="#{searchBL.setSelectedSearch(curSearch)}"
            update="@form" immediate="true" process="@this" />
        <p:ajax event="tabClose" listener="#{searchBL.removeSearchInstance(curSearch)}" update="@this"
            oncomplete="resizeResultViews();" immediate="true" process="@this" />
        <p:tab closable="#{curSearch.isCloseable()}">
        </p:tab>
    </p:tabView>

    <h:panelGrid id="mainSearchAreaGridId">
        <ui:include
            src="#{not searchBL.selectedSearch.closeable ? '/sections/search/firstSearchTab.xhtml' : '/sections/search/searchInstanceTab.xhtml'}">
            <ui:param name="curSearchInst" value="#{searchBL.selectedSearch}" />
        </ui:include>
    </h:panelGrid>
</h:form>

第一个标签是第二个标签中的搜索模板标签,上面有搜索实例。

这是dataTable xhtml。检索到curValue时会出现此问题。在这里&#39; hitlistBL&#39; bean使用当前属性名称查询结果字段映射。这里是之前选择的搜索实例中的名称,它尝试从新选择的搜索实例中获取值:

<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" filteredValue="#{curSearch.filteredValues}" 
    selection="#{curSearch.selectedSearchResults}" widgetVar="hitlistTableVar">

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

如果使用以下内容执行搜索实例。完成新搜索,并使用新结果交换搜索实例成员搜索结果:

<p:commandButton id="doSearchButtonFullMaskId" value="#{msgs['label.button.searchTemplate.search']}" icon="searchButtonIcon"
                styleClass="searchButton" action="#{searchMaskBL.doSearch(curSearchInst)}" update="@form" process="@form"
                oncomplete="resizeResultViews(); PF('hitlistTableVar').clearFilters();" style="margin-top: 10px;" />

很抱歉这是很多文字,很难解释。我不知道这是我的缺陷还是某处有错误。也许这个javascript parsererror可以给出一个提示,但我不知道如何进入/调试它。

更新:看起来像是ajax响应的一个不完善的xml?:

XML-Verarbeitungsfehler: nicht wohlgeformt Adresse: moz-nullprincipal:  {96f3db57-4075-4d80-a250-03491a2ce33f} Zeile Nr. 90, Spalte 132: ...rrorpages/500.xhtml?dswid=-9189"></redirect>]]>]]></update></partial-response......-------------------------------------------------^

它指向></redirect>]]>]]><

的右括号

0 个答案:

没有答案