Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf p:dataTable在选择其他筛选器时修改下拉筛选器_Jsf_Primefaces_Datatable_Primefaces Extensions - Fatal编程技术网

Jsf p:dataTable在选择其他筛选器时修改下拉筛选器

Jsf p:dataTable在选择其他筛选器时修改下拉筛选器,jsf,primefaces,datatable,primefaces-extensions,Jsf,Primefaces,Datatable,Primefaces Extensions,我正在使用带有过滤器的primefacesdatatable。在过滤器中,我有两个下拉选择框。我想在选择第一个下拉框后修改第二个下拉框 这是我的密码: <p:dataTable id="stockTable1" widgetVar="stockTable" var="stock" value="#{stockBean.stockList}" filteredValue="#{stockBean.filteredStocks}" paginator="true" rows="10"

我正在使用带有过滤器的
primefaces
datatable。在过滤器中,我有两个下拉选择框。我想在选择第一个下拉框后修改第二个下拉框

这是我的密码:

<p:dataTable id="stockTable1" widgetVar="stockTable" var="stock" value="#{stockBean.stockList}" filteredValue="#{stockBean.filteredStocks}" paginator="true" rows="10" 
             paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
             rowsPerPageTemplate="5,10,20, 50">
    <p:column headerText="Product Id" sortBy="#{stock.name}" filterBy="#{stock.name}">
        <h:outputText value="#{stock.name}" />
    </p:column>
    <p:column headerText="Category" sortBy="#{stock.categoryId}" filterBy="#{stock.categoryId}" filterMatchMode="exact">
        <f:facet name="filter">
            <p:selectOneMenu onchange="PF('stockTable').filter()" value="#{stockBean.selectedCategory}">
                <f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
                <f:selectItems value="#{stockBean.categoryNames}" />
            </p:selectOneMenu>
        </f:facet>
        <h:outputText value="#{stock.categoryId}" />
    </p:column>
    <p:column headerText="Sub Category" sortBy="#{stock.subCategoryId}" filterBy="#{stock.subCategoryId}" filterMatchMode="exact" >
        <f:facet name="filter">
            <p:selectOneMenu onchange="PF('stockTable').filter()" immediate="true" id="subChange">
                <f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
                <f:selectItems value="#{stockBean.subcategoryNames}" />
            </p:selectOneMenu>
        </f:facet>
        <h:outputText id="stockDescription" value="#{stock.subCategoryId}" />
    </p:column>
    <p:column headerText="Last Updated" sortBy="#{stock.updatedTS}" >
        <h:outputText value="#{stock.updatedTS}" >
            <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss"/>
        </h:outputText>
    </p:column>
</p:dataTable>


我想在选择类别后修改子类别下拉框。

您可以将
p:ajax
事件附加到第一个
p:selectOneMenu

<p:selectOneMenu onchange="PF('stockTable').filter()"
                 value="#{stockBean.selectedCategory}">

<!-- ... -->

    <p:ajax event="change" 
            process="stockTable1"
            update="stockTable1"
            partialSubmit="true"
            listener="#{stockBean.changeSubcategoryNames}"/>

例如,您可以在新方法
stockBean.changeSubcategoryNames
内部调整
subChange
的值