数据表我是新来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