78465

Primefaces : Ajax Call Inside p:dialog is not working

Question:

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 Code

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

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

Answer1:

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.

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 <strong>inside</strong> the dialog.

Recommend

  • Inline CKEditor toolbar has no alignment buttons for h2 elements
  • JSF DataTable Select One Row Using Radio Button
  • JSF reading dynamic input element in a managed bean
  • How to set the specificity of a css over-ride class for XPages
  • not rendered when using MyFaces instead of Mojarra
  • Coordinator Layout and Relative Layout issue
  • Way to make WPF DockPanel auto-resize based on its children's size?
  • Module parse failed: Unexpected token ionic 3
  • Custom UINavigationController UIToolbar subclass
  • How can I add a UIToolbar to a UIViewController?
  • How to set user avatar for Navigation drawer via url in android?
  • refresh previous page in onsen ui on back button
  • Chrome extension on an extension?
  • Custom plugin with DOM manipulation CKEditor 4.x
  • How to set HtmlEditorExtender's content server-side
  • New line in page for no reason
  • MATLAB uitable row generation from user input
  • Primefaces Dialog Framework - Open dialog - close it - open another dialog
  • Two different SelectItems return single selected value
  • JSeperator in JToolBar moves the components to right end
  • CKEditor separate the toolbar from the editor
  • Open (overflow) menu programmatically
  • Make background for table rows extend past the bounds of the table
  • How do one only submit click event (div), when using jquery live function?
  • What is the JSF behaviour, if you bind the same backing bean property to two input fields in the sam
  • Bokeh custom ToolTips {safe} tag displays nothing
  • TCPDF's getNumLines() is sometimes wrong
  • Why does CollectionViewSource.GetDefaultView(…) return the wrong CurrentItem from inside a Task thre
  • Change the width of the JQM panels
  • Play Framework nested form errors missing
  • why fullscreen functionality is not working in chrome?
  • IOS > Open URL in Safari with POST
  • Opening two instances of InAppBrowser (_system and _blank) prevents events from triggering
  • Replace Fragment with another on back button
  • Primefaces ManyCheckbox inside ui:repeat calls setter method only for last loop
  • preg_replace Double Spaces to tab (\\t) at the beginning of a line
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Disable Enter in editText android
  • How to check if every primary key value is being referenced as foreign key in another table
  • python regex in pyparsing