I think you are may be following the tutorial too much.
See below an simple working example:
Car class
package test_war.test_war;
public class Car {
private String name;
private Double price;
private int year;
public String getName() {
return name;
}
public Car(String name, Double price, int year) {
super();
this.name = name;
this.price = price;
this.year = year;
}
public void setName(String name) {
this.name = name;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
}
BackBean (Viewscoped)
package test_war.test_war;
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.ViewScoped;
@ManagedBean(name = "testBean")
@ViewScoped
public class TestBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<Car> cars;
private Car selectedCar;
public Car getSelectedCar() {
return selectedCar;
}
public void setSelectedCar(Car selectedCar) {
this.selectedCar = selectedCar;
}
@PostConstruct
public void init() {
cars = new ArrayList<Car>();
cars.add(new Car("test1", 111.11, 2011));
cars.add(new Car("test2", 711.11, 2012));
cars.add(new Car("test3", 511.11, 2001));
cars.add(new Car("test4", 411.11, 2000));
}
public List<Car> getCars() {
return cars;
}
public void setCars(List<Car> cars) {
this.cars = cars;
}
}
View(main.xhtml)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>A Simple JavaServer Faces 2.0 View</title>
</h:head>
<h:body>
<h:form id="form">
<p:dataTable id="cars" var="car" value="#{testBean.cars}"
rowKey="#{car.name}" selection="#{testBean.selectedCar}"
selectionMode="single">
<f:facet name="header">
Click "View" button after selecting a row to see details
</f:facet>
<p:column headerText="Name">
#{car.name}
</p:column>
<p:column headerText="Year">
#{car.year}
</p:column>
<p:column headerText="Price">
#{car.price}
</p:column>
<f:facet name="footer">
<p:commandButton id="viewButton" value="View" icon="ui-icon-search"
update=":form:display" oncomplete="carDialog.show()" />
</f:facet>
</p:dataTable>
<p:dialog id="dialog" header="Car Detail" widgetVar="carDialog"
resizable="false" width="200" showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="Name:" />
<h:outputText value="#{testBean.selectedCar.name}" />
<h:outputText value="Year:" />
<h:outputText value="#{testBean.selectedCar.year}" />
<h:outputText value="Price:" />
<h:outputText value="#{testBean.selectedCar.price}" />
</h:panelGrid>
</p:dialog>
</h:form>
</h:body>
</html>
Output
If you need the whole project as WAR/Zip file let me knw.