FileDocCategorySizeDatePackage
CatalogBean.javaAPI DocExample2009Tue Feb 28 11:34:06 GMT 2006com.ora.jsp.beans.shopping

CatalogBean

public class CatalogBean extends Object implements Serializable
This class represents a product catalog. It holds a list of products available for sale.

This is just a demo so the product list is hardcoded, created at instantiation. A real version would get the information from an external data source.

author
Hans Bergsten, Gefion software
version
2.0

Fields Summary
private Map
catalog
Constructors Summary
public CatalogBean()
Constructor. Creates all ProductBean objects and adds them to the catalog.


                    
      
        ProductBean prod = new ProductBean();
        prod.setId("1000");
        prod.setName("JavaServer Pages");
        prod.setDescr("Learn how to develop a JSP based web application.");
        prod.setPrice(32.95f);
        catalog.put("1000", prod);

        prod = new ProductBean();
        prod.setId("2000");
        prod.setName("Java Servlet Programming");
        prod.setDescr("Learn how to develop a servlet based web application.");
        prod.setPrice(32.95f);
        catalog.put("2000", prod);

        prod = new ProductBean();
        prod.setId("3000");
        prod.setName("Java In a Nutshell");
        prod.setDescr("Learn the Java programming language.");
        prod.setPrice(32.95f);
        catalog.put("3000", prod);
    
Methods Summary
public ProductBean[]getProductList()
Returns all products as an Iterator, suitable for looping.

return
an Iterator for all ProductBean instances

	ProductBean[] products = new ProductBean[catalog.size()];
	catalog.values().toArray(products);
        return products;
    
public java.util.MapgetProductsById()
Returns a Map with all ProductBean instances, keyed by ID.

return
an Map of all ProductBean instances

        return catalog;