How to use the "onsuccess" method of command ?

UI Components for JSF
Post Reply
keating
Posts: 21
Joined: 08 Nov 2010, 15:18

14 Nov 2010, 10:49

How to use the "onsuccess" method of command ?
How to make command know "ajax request succeeds" ?

averri
Posts: 136
Joined: 07 Sep 2009, 15:51
Location: Brazil

14 Nov 2010, 15:31

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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 41 guests