📜  Primefaces Ajax

📅  最后修改于: 2021-01-08 03:54:46             🧑  作者: Mango

PrimeFaces阿贾克斯

Primefaces提供内置的Ajax支持。它提供了各种属性,例如更新,事件,侦听器等。在这里,我们创建一个解释ajax属性的示例。

Ajax属性

下表包含Ajax属性。

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基本

此示例说明了应用程序中内置的Ajax用法。它使用Ajax更新后端值并显示输出。

该示例包括一个JSF页面和一个ManagedBean。

JSF文件

// ajax-basic.xhtml





Ajax Basic Example


Basic Ajax Example

ManagedBean

// User.java

package com.javatpoint;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class User implements Serializable{
String name;
String lastName;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}   

public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

输出:

输入值并按提交后,将产生以下输出。