📅  最后修改于: 2021-01-08 12:36:08             🧑  作者: Mango
此组件用于呈现表。它以表格形式显示数据。它与< rich:column >和< rich:columnGroup >组件一起使用以列出数据模型的内容。
value属性用于保存数据模型,而var属性指定在遍历数据模型时要使用的变量。
dataTable需要一组< rich:column >组件来定义内容。
下表包含DataTable的Style类和相应的外观参数。
Class | Function | Skin Parameters | Mapped CSS properties |
---|---|---|---|
.rf-dt | It is used to define styles for the table. | tableBackgroundColor tableBorderWidth |
background-color border-left-width, border-top-width |
.rf-dt-cap | It is used to define styles for the table caption. | No skin parameters. | |
.rf-dt-r | It is used to define styles for a table row. | No skin parameters. | |
.rf-dt-fst-r | It is used to define styles for the first row in a table. | No skin parameters. | |
.rf-dt-c | It is used to define styles for a table cell. | tableBackgroundColor tableBorderWidth |
background-color border-bottom-width, border-right-width |
.rf-dt-nd | It is used to define styles for a node. | tableBorderColor | border-bottom-color, border-right-color |
.rf-dt-hdr | It is used to define styles for a table header. | No skin parameters. | |
.rf-dt-hdr-fst | It is used to define styles for the first header. | No skin parameters. | |
.rf-dt-hdr-c | It is used to define styles for a header cell. | tableHeaderBackgroundColor tableBorderWidth |
background-color border-bottom-width, border-right-width |
.rf-dt-shdr | It is used to define styles for a table sub-header. | No skin parameters. | |
.rf-dt-shdr-fst | It is used to define styles for the first sub-header. | No skin parameters. | |
.rf-dt-shdr-c | It is used to define styles for a sub-header cell. | tableHeaderBackgroundColor | background-color |
.rf-dt-ftr | It is used to define styles for a table footer. | No skin parameters. | |
.rf-dt-ftr-fst | It is used to define styles for the first footer. | No skin parameters. |
在下面的示例中,我们正在实现< rich:dataTable >组件。本示例包含以下文件。
// data-table.xhtml
Rich Data Table
Student ID
Student Name
Student Email
Student Contact
// StudentRecord.java
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class StudentRecord {
String id;
String name;
String email;
String contactNumber;
List records;
public StudentRecord(){}
public StudentRecord(String id, String name, String email, String contactNumber) {
this.id = id;
this.name = name;
this.email = email;
this.contactNumber = contactNumber;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContactNumber() {
return contactNumber;
}
public void setContactNumber(String contactNumber) {
this.contactNumber = contactNumber;
}
public List getRecords() {
records = new ArrayList();
records.add(new StudentRecord("101", "Raju", "raju@abc.com", "52534252"));
records.add(new StudentRecord("102", "Rama", "rama@abc.com", "52235252"));
records.add(new StudentRecord("103", "John", "john@abc.com", "52456252"));
records.add(new StudentRecord("104", "Peter", "peter@abc.com", "55625252"));
return records;
}
public void setRecords(List records) {
this.records = records;
}
public int getNumberOfRecords(){
return this.records.size();
}
}
输出: