Primefaces:Ajax Call Inside p:dialog无法正常工作 [英] Primefaces : Ajax Call Inside p:dialog is not working

查看:41
本文介绍了Primefaces:Ajax Call Inside p:dialog无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Dialog执行ajax方法,但未执行.

I am trying to execute ajax method from Dialog, but its not getting executed.

<p:dialog header="Add Product" widgetVar="addProductDialog" modal="true" height="300" width="700" dynamic="true">

   <p:toolbar styleClass="toolBar">
      <p:toolbarGroup align="left">
         <p:commandButton styleClass="grn_actbttn" value="Cancel" onclick="addProductDialog.hide();" />
      </p:toolbarGroup>
      <p:toolbarGroup align="right">
         <p:commandButton styleClass="grn_actbttn" id="addproduct" value="Add Products" actionListener="#{customerProductsBean.saveCustomerProducts}"  oncomplete="addProductDialog.hide();" />
      </p:toolbarGroup>
   </p:toolbar>

</p:dialog>

Java代码

/**
 * Method used to save selected Customer Product from Add Product Dialog 
 * @param actionEvent
 */
public void saveCustomerProducts(ActionEvent actionEvent) {

// DB call to save to database

}

p:dialog不支持AJAX调用吗?

Is it like that p:dialog doesn't support AJAX call ?

推荐答案

您的对话框在页面上呈现后将被移出表单.这是客户端小部件用于Primefaces对话框的工作方式的副作用.

Your dialog is being moved out of the form after it is rendered on the page. This is a side-effect of the way the client side widgets work for Primefaces dialogs.

在对话框中添加appendToBody="true"属性通常可以解决此问题.

Adding appendToBody="true" attribute to dialog will generally fix this.

如果这不起作用,请确保您的对话框没有被窗体包围,而是在对话框内 放置一个窗体元素.

If this doesn't work then make sure that your dialog is not surrounded by a form, but instead put a form element inside the dialog.

这篇关于Primefaces:Ajax Call Inside p:dialog无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆