📅  最后修改于: 2021-01-08 12:13:13             🧑  作者: Mango
RichFaces提供了可以从JavaServer Faces页面发送Ajax请求的标记库。以下是Web应用程序中使用的重要标记。
要实现此标记,我们需要创建以下文件。
// index.xhtml
// User.java
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class User {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
// web.xml
javax.faces.PROJECT_STAGE
Development
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/faces/*
30
faces/index.xhtml
运行index.xhtml文件后,它将产生以下输出。
// commandLink.xhtml
// User.java
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class User {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
// web.xml
javax.faces.PROJECT_STAGE
Development
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/faces/*
30
faces/index.xhtml
输出:
//ajax-event.xhtml
a4j:ajax Tag
// web.xml
javax.faces.PROJECT_STAGE
Development
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/faces/*
30
faces/index.xhtml
// User.java
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class User {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
输出: