How to use the "onsuccess" method of command ?
How to make command know "ajax request succeeds" ?
How to use the "onsuccess" method of command ?
Hi, you can use the 'onsuccess' to trigger anything you want. The value of 'onsuccess' property must be the name of a JavaScript function.
For example, suppose that you want to display an alert window when ajax request succeeds:
<p:commandButton value="Submit" action="anything" onsuccess="alert('On success triggered!')" />
Regarding the second question (How to make command know "ajax request succeeds"): the answer is simple, using the 'onsuccess' property as described.
If you want to process the ajax response globally (for all ajax components), so I suggest you to use the p:ajaxStatus. Please check the showcase:
http://www.primefaces.org/showcase/ui/pprAjaxStatus.jsf
For example, suppose that you want to display an alert window when ajax request succeeds:
<p:commandButton value="Submit" action="anything" onsuccess="alert('On success triggered!')" />
Regarding the second question (How to make command know "ajax request succeeds"): the answer is simple, using the 'onsuccess' property as described.
If you want to process the ajax response globally (for all ajax components), so I suggest you to use the p:ajaxStatus. Please check the showcase:
http://www.primefaces.org/showcase/ui/pprAjaxStatus.jsf
-
- Information
-
Who is online
Users browsing this forum: No registered users and 41 guests