使用p:selectOneMenu过滤p:datatable的问题

时间:2014-02-24 10:26:15

标签: jsf java-ee primefaces datatable

我有一个p:datatable,每行有一个p:selectOneMenus。问题:

如果我将过滤器应用于其中一列,则p:selectOneMenu会获取错误类,并且还会忘记当前选择(来自bean)。

导致此问题的原因是什么?

欢迎任何想法!

提前谢谢!

PS:我正在使用PrimeFaces 4.0和JSF 2.0

修改

<p:dataTable id="customersDataTable" widgetVar="customersDataTableWidget" var="customer"
                    value="#{customerListManagedBean.customers}"
                    emptyMessage="#{bwadminmsg.tableNoRecordsFound}"
                    rows="#{sortTableSessionManagedBean.tableRowCount}"
                    paginator="true"
                    paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"  
                    rowsPerPageTemplate="5,10,15,20,25,30"
                    paginatorPosition="bottom"
                    paginatorAlwaysVisible="true"
                    currentPageReportTemplate="{currentPage} / {totalPages}"
                    selectionMode="single"
                    selection="#{customerListManagedBean.selectedCustomer}"
                    sortMode="single"
                    sortBy="#{sortTableSessionManagedBean.toLowerLatinCase(customer.customer.companyName)}"
                    sortOrder="ascending"
                    styleClass="customersDataTable"
                    filteredValue="#{customerListManagedBean.filteredCustomers}" >

                    <p:ajax event="rowDblselect"
                        listener="#{customerListManagedBean.onCustomerRowSelect}"/>

                    <p:ajax event="sort" listener="#{sortTableSessionManagedBean.customersDataTableSortListener}"/>

                    <p:columnGroup type="header">
                    <p:row>
                        <p:column 
                            id="companyNameColumnHeader"
                            sortBy="#{sortTableSessionManagedBean.toLowerLatinCase(customer.customer.companyName)}" 
                            filterBy="#{customer.customer.companyName}"
                            filterMatchMode="contains" 
                            styleClass="customHeader"
                            >
                        </p:column>
                        <p:column
                            id="phoneNumberColumnHeader"
                            headerText="#{msg.definitionRefreshLabel}" 
                            sortBy="#{sortTableSessionManagedBean.toLowerLatinCase(customer.customer.phoneNumber)}"
                            filterBy="#{customer.customer.phoneNumber}"
                            filterMatchMode="contains"
                            styleClass="customHeader"
                            />
                        <p:column
                            id="townColumnHeader"
                            sortBy="#{sortTableSessionManagedBean.toLowerLatinCase(customer.customer.billSettlement)}"
                            filterBy="#{customer.customer.billSettlement}"
                            filterMatchMode="contains"
                            styleClass="customHeader"
                            />
                        <p:column
                            id="actualCustomerColumnHeader"
                            styleClass="customHeader"
                            sortBy="#{sortTableSessionManagedBean.toLowerLatinCase(customer.currentCustomerUser)}"
                            filterBy="#{customer.currentCustomerUser}"
                            filterMatchMode="contains"
                            />
                    </p:row>
                    <p:row>
                        <p:column 
                            id="selectedCompanyNameColumn"
                            headerText="#{customerListManagedBean.selectedCustomer.customer.companyName}"
                            styleClass="selectedHeader ui-dt-c">
                        </p:column>

                        <p:column 
                            id="selectedPhoneNumberColumn"
                            headerText="#{customerListManagedBean.selectedCustomer.customer.phoneNumber}"
                            styleClass="selectedHeader ui-dt-c">
                        </p:column>

                        <p:column 
                            id="selectedTownColumn"
                            headerText="#{customerListManagedBean.selectedCustomer.customer.billSettlement}"
                            styleClass="selectedHeader ui-dt-c">
                        </p:column>

                        <p:column 
                            id="selectedActualCustomerColumn"

                            styleClass="selectedHeader ui-dt-c hiddenSelectorPlaceholder">
                        </p:column>
                    </p:row>
                    <p:row>
                    <p:column colspan="4"></p:column>
                    </p:row>
                </p:columnGroup>

                    <p:column 
                        id="companyNameColumn">
                        <h:outputText value="#{customer.customer.companyName}" styleClass="ui-dt-c customWidthColumn"/>
                    </p:column>

                    <p:column 
                        id="phoneNumberColumn">
                        <h:outputText value="#{customer.customer.phoneNumber}" styleClass="ui-dt-c customWidthColumn"/>
                    </p:column>

                    <p:column 
                        id="townColumn">
                        <h:outputText value="#{customer.customer.billSettlement}" styleClass="ui-dt-c customWidthColumn"/>
                    </p:column>

                    <p:column 
                        id="actualCustomerColumn"
                        >
                        <p:selectOneMenu id="actualCustomerSelect"
                        styleClass="actualCustomerSelector"
                        value="#{customer.currentCustomerUser}"
                        >
                            <f:selectItems value="#{customer.managers}" 
                            var="manager"
                            itemLabel="#{manager}"
                            itemValue="#{manager}"/>
                            <p:ajax listener="#{customer.customerChangeListener}" partialSubmit="true"
                            process="@this" onsuccess="customerChangeConfigDialogVar.show()"></p:ajax>
                            </p:selectOneMenu>
                    </p:column>

                </p:dataTable>

0 个答案:

没有答案