KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > pets > presentation > pages > CategoryPage


1 package org.apache.tapestry.pets.presentation.pages;
2
3
4
5 import johnmammen.betterpetshop.service.PetshopManager;
6
7 import org.apache.tapestry.IRequestCycle;
8 import org.apache.tapestry.event.PageEvent;
9 import org.apache.tapestry.event.PageRenderListener;
10 import org.apache.tapestry.pets.PetshopBasePage;
11
12
13 import org.apache.tapestry.pets.domain.model.IProduct;
14
15 import org.apache.tapestry.pets.presentation.components.PagedModel;
16
17
18 public abstract class CategoryPage extends PetshopBasePage implements
19         PageRenderListener {
20
21     //for getting the petshop service
22
public abstract PetshopManager getPetshopService();
23
24 public void pageBeginRender(PageEvent event) {
25
26
27
28         if (getModel() == null) setModel(new PagedModel());
29
30         if (getCategory() != null) {
31             //getting the petshop service
32
setProductList(getPetshopService().findByCategory(getCategory()));
33         }
34
35     } public void selectItem(IRequestCycle cycle) {
36         Object JavaDoc[] parameters = cycle.getServiceParameters();
37         String JavaDoc prodid = ((String JavaDoc) parameters[0]);
38         String JavaDoc prodname = ((String JavaDoc) parameters[1]);
39         ProductCategoryPage productcategory = (ProductCategoryPage) cycle
40                 .getPage("ProductCategory");
41         productcategory.setProdID(prodid);
42         productcategory.setProdName(prodname);
43         cycle.activate(productcategory);
44     }
45
46     public void directJumpToPage(IRequestCycle cycle) {
47         Object JavaDoc[] parameters = cycle.getServiceParameters();
48         int page = ((Integer JavaDoc) parameters[0]).intValue();
49         int pCount = ((Integer JavaDoc) parameters[1]).intValue();
50         setCategory((String JavaDoc) parameters[2]);
51
52         PagedModel nmodel = new PagedModel();
53         nmodel.setPageCount(pCount);
54         nmodel.setPageToShow(page);
55         setModel(nmodel);
56     }
57
58     public abstract void setCategory(String JavaDoc value);
59
60     public abstract String JavaDoc getCategory();
61
62     public abstract void setProductList(IProduct[] productList);
63
64     public abstract IProduct[] getProductList();
65
66     public abstract int getProductPage();
67
68     public abstract void setProductPage(int productPage);
69
70     public abstract IProduct getProduct();
71
72     public abstract void setProduct(IProduct product);
73
74     public abstract PagedModel getModel();
75
76     public abstract void setModel(PagedModel model);
77
78 }
Popular Tags