Olá Pessoal sou novo no desenvolvimento WEB, após uma pesquisa descobri que não achei exemplos que esclareçam a minha dúvida, Estou com problemas em popular uma datatable do jsf, as seguintes páginas comtém onde eh apresentado o problema:
<?xml version="1.0" encoding="UTF-8" ?><%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h” %>
<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f” %>
<f:view>
Data table<h:form>
<h:outputText value=“Lista de requisitos” style=“font-size:40px;color:#0000FF” />
<h:dataTable id=“dt1” value="#{tableBean.items}" var=“item” bgcolor="#F1F1F1" border=“10” cellpadding=“5” cellspacing=“3” first=“0” rows=“5” width=“50%” dir=“LTR” frame=“hsides” rules=“all” summary=“This is a JSF code to create dataTable.” >
<f:facet name=“header”>
<h:outputText value="#{projectBean.projectName}" />
</f:facet>
<h:column>
<f:facet name=“header”>
<h:outputText value=“Id” />
</f:facet>
<h:outputText value="#{item.id}"></h:outputText>
</h:column>
<h:column>
<f:facet name=“header”>
<h:outputText value=“Name”/>
</f:facet>
<h:outputText value="#{item.name}"></h:outputText>
</h:column>
<h:column>
<f:facet name=“header”>
<h:outputText value=“Version”/>
</f:facet>
<h:outputText value="#{item.version}"></h:outputText>
</h:column>
<h:column>
<f:facet name=“header”>
<h:outputText value=“Type”/>
</f:facet>
<h:outputText value="#{item.type}"></h:outputText>
</h:column>
<h:column>
<f:facet name=“header”>
<h:outputText value=“Category”/>
</f:facet>
<h:outputText value="#{item.category}"></h:outputText>
</h:column>
<h:column>
<f:facet name=“header”>
<h:outputText value=“priority”/>
</f:facet>
<h:outputText value="#{item.priority}"></h:outputText>
</h:column>
<f:facet name=“footer”>
<h:outputText value=“Project Abstract: #{projectBean.projectAbstract}” />
</f:facet>
</h:dataTable>
<h:outputLabel for=“add” value="Adicionar Requisitos: " />
<h:commandButton action=“add” value=“Adicionar” />
</h:form>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
página que adiciona dados!
<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h” %>
<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f” %>
<f:view>
Adiciona Requisitos<h:form>
<h:outputText value=“Adicionar requisitos” style=“font-size:40px;color:#0000FF” />
<h:outputLabel for=“name” value=“Entre com o nome do requisito: " />
<h:inputText id=“name” value=”#{tableBean.name}" />
<h:outputLabel for=“version” value=“Entre com a versão: " />
<h:inputText id=“version” value=”#{tableBean.version}" />
<h:outputLabel for=“type” value=“Entre com o tipo: " />
<h:inputText id=“type” value=”#{tableBean.type}" />
<h:outputLabel for=“category” value=“Entre com a categoria: " />
<h:inputText id=“category” value=”#{tableBean.category}" />
<h:outputLabel for=“priority” value=“Entre com a prioridade: " />
<h:inputText id=“priority” value=”#{tableBean.priority}" />
<h:outputText value=“1-Normal, 2-Extra, 3-Urgente” ></h:outputText>
<h:outputLabel for=“ok” value="Retorna a lista: " />
<h:commandButton action=“ok” value=“OK” > <f:actionListener type=“com.tutorial.TableBean” />
</h:commandButton>
</h:form>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bean declarado na request session
package com.tutorial;
import java.util.ArrayList;
import java.util.Collection;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
// Our Managed Bean
public class TableBean implements ActionListener {
private int id;
private String name;
private double version;
private String type;
private String category;
private int priority;
private Collection<ReqItem> items;
public TableBean() {
}
public Collection<ReqItem> getItems() {
if (items != null && !items.isEmpty()) {
items = new ArrayList<ReqItem>();
}
return items;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getVersion() {
return version;
}
public void setVersion(double version) {
this.version = version;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public String add() {
ReqItem item = new ReqItem();
item.setId(getId());
item.setName(getName());
item.setVersion(getVersion());
item.setType(type);
item.setCategory(category);
item.setPriority(priority);
items.add(item);
return "itemAdded";
}
public void processAction(ActionEvent arg0) throws AbortProcessingException {
System.out.println("TableBean.proccessaction");
add();
}
}
///////////////////////////////////////////////////////////////////////////////////////////
classe usada pelo bean acima
package com.tutorial;
public class ReqItem {
int id;
String name;
double version;
String type;
String category;
int priority;
public ReqItem() {
super();
// TODO Auto-generated constructor stub
}
public ReqItem(int id, String name, double version, String type,
String category, int priority) {
this.id = id;
this.name = name;
this.version = version;
this.type = type;
this.category = category;
this.priority = priority;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getVersion() {
return version;
}
public void setVersion(double version) {
this.version = version;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
}
Eu estou a alguns dias me matando aqui para saber por qual motivo este código não funciona, eu estou usando eclipse europa, tomcat 5.5 , wtp 2.0, jsf 1.1, java 5.0, os dados não são inseridos na tabela que continua em branco,