數據表我是新來PrimeFaces嘗試了在PrimeFaces數據表爲例PrimeFaces不工作
public class Datatable {
private String fname;
private String lname;
private int age;
public Datatable(String fname, String lname, int age) {
// TODO Auto-generated constructor stub
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
在這裏,我已經聲明的類是什麼在數據表中
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="solodat")
@RequestScoped
public class Solodata implements Serializable{
private static final long serialVersionUID = 1L;
public Solodata() {}
private List<Datatable>addeta;
public List<Datatable> getAddeta() {
return addeta;
}
public void setAddeta(List<Datatable> addeta) {
this.addeta = addeta;
}
@PostConstruct
public void init() {
List<Datatable> addeta=new ArrayList<Datatable>();
addeta.add(new Datatable("man","eater",14));
addeta.add(new Datatable("solo","world",28));
addeta.add(new Datatable("antan","evanious",20));
addeta.add(new Datatable("hi","daa",29));
addeta.add(new Datatable("thallu","vandi",30));
addeta.add(new Datatable("prime","faces",1000));
addeta.add(new Datatable("crime","shit",1412));
addeta.add(new Datatable("shit","head",18));
}
}
這裏領域在名單上有獲取值:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://www.java.com/jsf/html"
xmlns:f="http://www.java.com/jsf/core"
xmlns:p="http://www.primefaces.org/ui">
<h:head>
<title>DATA TABLES DEMO</title>
</h:head>
<h:body>
<h:form>
<h1>output values</h1>
<p:dataTable var="sol" value="#{solodat.addeta}" >
<p:column headerText="LASTNAME">
<h:outputText value="#{sol.lname}"/>
</p:column>
<p:column headerText="age">
<h:outputText value="#{sol.age}"/>
</p:column>
<p:column headerText="first">
<h:outputText value="#{sol.fname}"/>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
這是XHTML頁面獲得通過數據bean的值表,但JSF顯示空白頁面。任何幫助,將不勝感激。
什麼服務器,你運行的?是否有任何primeface標籤正在工作? – 2014-12-06 13:14:02