Home » Primefaces Ajax

PrimeFaces Ajax

Primefaces provides built-in Ajax support. It provides various attributes like update, event, listener etc. Here, we are creating an example that explains ajax attributes.

Ajax Attributes

The following table contains Ajax attributes.

Attribute Default value Return type Description
listener null MethodExpr It is used to process in partial request.
Immediate false boolean It returns a boolean value that determines the phaseId, when true actions are processed at apply_request_values, when false at invoke_application phase.
async false boolean When set to true, ajax requests are not queued.
process null String It is used to process in partial request.
update null String It is used to update with ajax.
onstart null String It is used to execute before ajax request is begins.
oncomplete null String It is used to execute when ajax request is completed.
onsuccess null String It is used to execute when ajax request succeeds.
delay null String It is used to set time to delay. If less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded. If this option is not specified, or if the value of delay is the literal string ‘none’ without the quotes, no delay is used.
partialSubmit false boolean Enables serialization of values belonging to the partially processed components only.
partialSubmitFilter null String Selector to use when partial submit is on, default is “:input” to select all descendant inputs of a partially processed components.
event null String Client side event to trigger ajax request.

Ajax Basic

This example explains a built-in Ajax usage in the application. It updates the back-end value and displays output by using Ajax.

This example includes a JSF page and a ManagedBean.

JSF File

// ajax-basic.xhtml

ManagedBean

// User.java

Output:

PrimeFaces Ajax 1

After entering value and pressing submit, it produce the following output.

PrimeFaces Ajax 2

You may also like