个性化阅读
专注于IT技术分析

RichFaces rich:list用法示例

点击下载

本文概述

此组件用于呈现项目列表。我们可以创建数字排序列表, 无序列表, 项目符号列表等。它使用数据模型来管理可以动态更新的列表项。

样式类和皮肤参数

下表包含列表的样式类和相应的外观参数。

Class Function Skin Parameters 映射的CSS属性
.rf-ulst-itm 它用于为无序列表中的项目定义样式。 generalTextColor generalFamilyFont 彩色字体系列
.rf-olst-itm 它用于为无序列表中的项目定义样式。 generalTextColor generalFamilyFont color font-family
.rf-dlst-trm 它用于定义定义列表中项目术语的样式。 generalTextColor generalFamilyFont color font-family
.rf-dlst-dfn 用于定义定义列表中项目定义的样式。 generalTextColor generalFamilyFont generalSizeFont 颜色字体系列字体大小

例子

在下面的示例中, 我们正在实现<rich:list>组件。本示例包含以下文件。

JSF文件

// rich-list.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<f:view>
<h:head>
<title>Rich List </title>
</h:head>
<h:body>
<h:form>
<h:form>
<rich:list var="student" value="#{studentRecord.records}" type="definitions" rows="5" title="Cars">
<f:facet name="term">
<h:outputText value="#{student.id}" styleClass="label"></h:outputText>
</f:facet>
<h:outputText value="Name:" styleClass="label"></h:outputText>
<h:outputText value="#{student.name}" /><br/>
<h:outputText value="Email:" styleClass="label"></h:outputText>
<h:outputText value="#{student.email}" /><br/>
<h:outputText value="Contact:" styleClass="label"></h:outputText>
<h:outputText value="#{student.contactNumber}" /><br/>
</rich:list>
</h:form>
</h:form>
</h:body>
</f:view>
</ui:composition>

托管豆

// 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<StudentRecord> 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<StudentRecord> 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<StudentRecord> records) {
this.records = records;
}
public int getNumberOfRecords(){
return this.records.size();
} 
}

输出

RichFaces列表1

赞(0)
未经允许不得转载:srcmini » RichFaces rich:list用法示例

评论 抢沙发

评论前必须登录!