gpt4 book ai didi

jsf-2 - 在 jsf 中多次调用 Ajax 方法

转载 作者:行者123 更新时间:2023-12-02 02:05:20 26 4
gpt4 key购买 nike

我有一个在 <p:selectOneButton/> 上使用 Ajax 的复合组件, 当 Ajax 调用 actionListener<p:commandButton/>它调用 10 次然后运行该方法。我认为问题是由 <p:dataGrid/> 引起的因为当我把我的<p:commandButtton/>来自 <p:dataGrid/> access ,它工作正常但是当我在 <p:dataGrid/> 中使用它时Ajax 调用 actionListener不止一次。

这是.xhtml:

<table style="width: 100%">
<tr>
<td><p:selectOneButton value="#{inviteRequestManagedBean.filterType}">
<f:selectItem itemLabel="#{inviteRequest_msg.request}" itemValue="request" />
<f:selectItem itemLabel="#{inviteRequest_msg.archive}" itemValue="archive" />
<f:ajax event="change" render="requestDataGrid" />
</p:selectOneButton></td>
</tr>
<tr>
<td><p:dataGrid id="requestDataGrid" var="tBusinessPartnerRequestInfo" value="#{inviteRequestManagedBean.filterBusinessRequest()}" columns="1"
rows="2">
<p:column>
<div>
<table border="0" width="100%">
<tr>
<td><p:graphicImage value="#{tBusinessPartnerRequestInfo.partySender_imageUrl}" /></td>
<td>
<div>
<table border="0" width="100%">
<tr>
<td><h:outputLabel value="#{tBusinessPartnerRequestInfo.requestDate}" /></td>
</tr>
<tr>
<td><h:outputLabel value="#{tBusinessPartnerReques`enter code here`tInfo.partySender_fullName}" /></td>
</tr>
</table>
</div>
</td>
<td><p:commandButton id="acceptCommonButton" value="#{inviteRequest_msg.accept}" process="@this"
actionListener="#{inviteRequestManagedBean.acceptRequest(tBusinessPartnerRequestInfo.id)}">
</p:commandButton></td>
<td><p:commandButton id="noNowCommonButton" value="#{inviteRequest_msg.notnow}"
actionListener="#{inviteRequestManagedBean.notNowRequest(tBusinessPartnerRequestInfo.id)}">
</p:commandButton></td>
</tr>
</table>
</div>
<hr />
</p:column>
</p:dataGrid> <p:panel>


</p:panel></td>
</tr>
</table>

我该如何解决这个问题?

谢谢。

最佳答案

我认为您可以在 ajax 请求中使用选项 partialSubmit 和 process 来仅处理必要的信息,如下所示:

<p:selectOneButton value="#{inviteRequestManagedBean.filterType}">
<f:selectItem itemLabel="#{inviteRequest_msg.request}" itemValue="request" />
<f:selectItem itemLabel="#{inviteRequest_msg.archive}" itemValue="archive" />

<f:ajax event="change" render="requestDataGrid" partialSubmit="true" process="@this" />
</p:selectOneButton>

如果这解决了您的问题,您可以在 primefaces 展示中看到更多内容:

Partial submit

Partial process

关于jsf-2 - 在 jsf 中多次调用 Ajax 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15354543/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com