[英]JSF- <p:dataTable> issue with the Ajaxmethod
我有一个<p:dataTable>
并且在行中有一个日期字段,每当用户通过系统或手动更改日期时,我都需要向用户显示对话,Ajax方法将调用以更新来自备用bean的消息。
这是我正在使用的特定行的代码。
<p:calendar value="#{dets.exceptionDueDate}" pattern="MM/dd/yyyy"
size="10" navigator="true"
rendered="#{systemDetailsBean.editCmdActionflg==true and (dets.firstColumn!='1' or dets.secondColumn!='1')}">
<f:convertDateTime pattern="MM/dd/yyyy" />
<p:ajax event="dateSelect"
listener="#{systemDetailsBean.showPopup}"
process="@this :SystemDetailsinfoForm:line :commentsform:commentsdt"
partialSubmit="true" />
<p:ajax event="change" listener="#{systemDetailsBean.showPopup}"
process="@this :SystemDetailsinfoForm:line :commentsform:commentsdt"
partialSubmit="true" />
<f:attribute name="index" value="_#{index}" />
<f:attribute name="componentId" value="exe" />
</p:calendar>
如您所见,日历正在调用两个事件方法,即“ dateselect”和“ change”
我添加了两种方法,因为用户可能可以通过两种方式系统地提供日期。
支持bean中的Ajax方法如下
public void showPopup(ActionEvent event) {
String compId = (String) event.getComponent().getAttributes()
.get("componentId");
int index = Integer.parseInt(((String) event.getComponent()
.getAttributes().get("index")).replace("_", ""));
//Blah blah...
}
我的问题是考虑<p:dataTable>
有12 rows
,当我更改特定行中的日期列时,AjaxMethod被调用了12 times
。因此,由于这一原因,我无法在Ajax方法中处理某些消息在后备豆中。
当我在特定行中选择一个日期列时,如何只能限制一次Ajax方法的调用。如您所见,我可以获取该行的索引。 但是我不知道如何限制XHTML中的方法调用。
任何建议对于解决此问题确实很有帮助。
我通过将“ process”属性替换为“ update”属性来解决了此问题,并添加了“ execute = @ this”属性。
这是我更新的代码
<p:ajax event="dateSelect" execute="@this"
listener="#{systemDetailsBean.showPopup}"
update="@this :SystemDetailsinfoForm:line :commentsform:commentsdt"
partialSubmit="true" />
<p:ajax event="change" listener="#{systemDetailsBean.showPopup}" execute="@this"
update="@this :SystemDetailsinfoForm:line :commentsform:commentsdt"
partialSubmit="true" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.