为什么一些JSF组件停止进行部分处理/渲染?

发布于 2025-02-08 07:47:09 字数 2309 浏览 2 评论 0原文

以一种形式,我有一个复选框,其选项可有效地以另一种形式对PrimeFaces数据表进行过滤:

     <h:form id="mainForm">
          <!-- some other code here -->
          <p:selectManyCheckbox id="..." value="#{Bean.eventTypeFilters}" >
               <p:ajax listener="#{ManagedBean.applyEventTypeFilters}" update="form:DataTable" />
                    <f:selectItem itemLabel="Access" itemValue="Access" />
                    <f:selectItem itemLabel="Execution" itemValue="Execution" />
                    <f:selectItem itemLabel="Lambda" itemValue="Lambda" />
          </p:selectManyCheckbox>     
     </h:form>

当我检查或取消选中选项时,数据表会自动更新自身以反映其,并且在侦听器属性中详细介绍了该功能在P:Ajax标签中进行。

备用bean中该方法的代码:

    public void applyEventTypeFilters() {
        System.out.println("APPLY EVENT TYPE FILTERS START");
        List<Log> newFilteredLogs = new ArrayList<>();
        for (Log l : allLogs) {
            if (eventTypeFilters.contains(l.getEventType()) && (apiFilter == null || l.getApi().equals(apiFilter))) {
                newFilteredLogs.add(l);
            }
        }
        filteredLogs = newFilteredLogs;
        System.out.println("APPLY EVENT TYPE FILTERS END");
    }

这是数据表中的JSF代码:

<h:form id="secondForm">
     <p:dataTable id="DataTable" widgetVar="DataTable" value="#{Bean.filteredLogs}" var="log" rowKey="#{log.logId}" 
     rows="10" paginator="true" 
     paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
     rowsPerPageTemplate="10,20,50">

          <p:column headerText="Extended Request Id" sortBy="#{log.extendedRequestId}" filterBy="#                                                            
          {log.extendedRequestId}" >
                     <h:outputText value="#{log.extendedRequestId}" />
          </p:column>
    </p:dataTable>
</h:form>

但是,每当我在上面详细信息中输入过滤器输入框,然后在第1个代码中详细介绍的复选框中检查或取消选中的选项块,数据表停止自动更新自身,但是从服务器日志中,我仍然可以看到,在检查/取消检查时的服务器端方法被调用。

我的问题是:我如何确保即使我也同时利用另一个组件中的其他此类能力(在这种情况下,在这种情况下为滤波器),即使我同时使用其他此类能力,我仍将部分处理/渲染的能力仍然存在?

另外,我相信,在过滤表时,有一个列表是自动创建的包含过滤对象的列表。如何获得对此列表的更多直接控制?

非常感谢!

In one form, I have a checkbox whose options effectively carry out filtering of a PrimeFaces data table in another form:

     <h:form id="mainForm">
          <!-- some other code here -->
          <p:selectManyCheckbox id="..." value="#{Bean.eventTypeFilters}" >
               <p:ajax listener="#{ManagedBean.applyEventTypeFilters}" update="form:DataTable" />
                    <f:selectItem itemLabel="Access" itemValue="Access" />
                    <f:selectItem itemLabel="Execution" itemValue="Execution" />
                    <f:selectItem itemLabel="Lambda" itemValue="Lambda" />
          </p:selectManyCheckbox>     
     </h:form>

When I check or uncheck an option above, the data table automatically updates itself to reflect it, and the function detailed in the listener attribute within the p: ajax tag is carried out.

The code of the method in the backing bean:

    public void applyEventTypeFilters() {
        System.out.println("APPLY EVENT TYPE FILTERS START");
        List<Log> newFilteredLogs = new ArrayList<>();
        for (Log l : allLogs) {
            if (eventTypeFilters.contains(l.getEventType()) && (apiFilter == null || l.getApi().equals(apiFilter))) {
                newFilteredLogs.add(l);
            }
        }
        filteredLogs = newFilteredLogs;
        System.out.println("APPLY EVENT TYPE FILTERS END");
    }

Here is the JSF code of the data table:

<h:form id="secondForm">
     <p:dataTable id="DataTable" widgetVar="DataTable" value="#{Bean.filteredLogs}" var="log" rowKey="#{log.logId}" 
     rows="10" paginator="true" 
     paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
     rowsPerPageTemplate="10,20,50">

          <p:column headerText="Extended Request Id" sortBy="#{log.extendedRequestId}" filterBy="#                                                            
          {log.extendedRequestId}" >
                     <h:outputText value="#{log.extendedRequestId}" />
          </p:column>
    </p:dataTable>
</h:form>

However, whenever I type in the filter input box in as detailed above, and then check or uncheckout an option in the checkbox detailed in the 1st code block, the data table stops automatically updating itself, but from the server logs I still see that the server-side method upon checking/unchecking is called.

My question is: How do I ensure that the capacity for partial processing/rendering of the 1st checkbox component remains even when I am also simultaneously making use of other such capacities in another component(in this case the filter)?

Also, I believe that when filtering the table, there is a list which is automatically created containing the filtered objects. How do I gain more direct control over this list?

Thanks a great deal!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文