Help loading collection into data table
[nobr]Hi all, I'm having what I believe to be a minor problem with getting my collection stored in a bean to output to a jsp page using jsf data table. I think the actual error is to due with the mapping from faces-config to the bean itself as the error message is "stockItems cannot be resolved as a member of stockListings" the stockListings bean is clearly defined in faces-config. I'm posting my faces-config.xml, the jsp page I'm using, and the bean I want to access below. I would appreciate any help anybody could provide as I can't figure out why it can't the collection in the class.
faces-config.xml==========================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>stockListings</managed-bean-name>
<managed-bean-class>logic.WebLogic</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>newsBean</managed-bean-name>
<managed-bean-class>model.DataBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>stockBean</managed-bean-name>
<managed-bean-class>model.StockBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
</navigation-rule>
</faces-config>
=================================================
showStocks.jsp==========================
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP'showStocks.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<strong>Stocks and Related Stories</strong> <br>
<f:view>
<h:dataTable border="1" var="stocks" rendered="true" value="#{stockListings.stockItems}" style="" headerClass="HEADING" rowClasses="row1">
<h:column>
<f:facet name="header">
<h:outputText value="Stocks"/>
</f:facet>
<h:outputText value="# {stocks.name}" />
</h:column>
</h:dataTable>
</f:view>
</body>
</html>
=================================================
WebLogic.jsp==========================
package logic;
import java.util.*;
import model.*;
publicclass WebLogicextends BaseLogic
{
public Collection stockItems;
//constructor
public WebLogic()
{
super();
}
//getters & setters
public Collection GetStockNames()
{
//pull out a the string name of the stock item to print in a
//data table
Collection tmpArray =new ArrayList();
for(int i = 0; i < StorageUnit.GetInstance().GetStockListSize(); i++)
tmpArray.add((StockBean)StorageUnit.GetInstance().GetStockItem(i));
stockItems = tmpArray;
return stockItems;
}
publicvoid SetStockItem(StockBean newStock)
{
StorageUnit.GetInstance().GetStockList().add(newStock);
}
}
[/nobr]

