KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.tapestry.pets.presentation.pages;
2
3 import java.text.NumberFormat JavaDoc;
4
5
6 import johnmammen.betterpetshop.service.PetshopManager;
7
8 import org.apache.commons.lang.StringUtils;
9 import org.apache.tapestry.IRequestCycle;
10 import org.apache.tapestry.event.PageEvent;
11 import org.apache.tapestry.event.PageRenderListener;
12 import org.apache.tapestry.pets.PetshopBasePage;
13
14 import org.apache.tapestry.pets.domain.model.IItem;
15 import org.apache.tapestry.pets.presentation.components.PagedModel;
16
17
18 public abstract class ProductCategoryPage extends PetshopBasePage implements
19         PageRenderListener {
20     //for getting the petshop service
21
public abstract PetshopManager getPetshopService();
22
23     public void pageBeginRender(PageEvent event) {
24    
25         if (getProdID() != null)
26             setItemsList(getPetshopService().getItemsByProduct(getProdID()));
27
28         if (getModel() == null) setModel(new PagedModel());
29
30         if (getCurrencyFormat() == null)
31                 setCurrencyFormat(NumberFormat.getCurrencyInstance(getEngine()
32                         .getLocale()));
33     }
34
35     public abstract void setProdID(String JavaDoc prodid_value);
36
37     public abstract String JavaDoc getProdID();
38
39     public abstract void setProdName(String JavaDoc prodname_value);
40
41     public abstract String JavaDoc getProdName();
42
43     public abstract void setItemsList(IItem[] iList);
44
45     public abstract IItem[] getItemsList();
46
47     public abstract IItem getCurrentItem();
48
49     public abstract void setCurrentItem(IItem value);
50
51     public abstract NumberFormat JavaDoc getCurrencyFormat();
52
53     public abstract void setCurrencyFormat(NumberFormat JavaDoc format);
54
55     public abstract PagedModel getModel();
56
57     public abstract void setModel(PagedModel model);
58
59     public int getCurrentPage() {
60         return getModel().getPageToShow();
61     }
62
63     public int getPageCount() {
64         return getModel().getPageCount();
65     }
66
67     public void directJumpToPage(IRequestCycle cycle) {
68         Object JavaDoc[] parameters = cycle.getServiceParameters();
69         int page = ((Integer JavaDoc) parameters[0]).intValue();
70         int pCount = ((Integer JavaDoc) parameters[1]).intValue();
71         String JavaDoc[] state = StringUtils.split((String JavaDoc) parameters[2], "#");
72
73         PagedModel nmodel = new PagedModel();
74         nmodel.setPageCount(pCount);
75         nmodel.setPageToShow(page);
76         setModel(nmodel);
77         setProdID(state[0]);
78         setProdName(state[1]);
79     }
80
81     public void directShowItemDetails(IRequestCycle cycle) {
82         Object JavaDoc[] parameters = cycle.getServiceParameters();
83         ProductDetailsPage prodDetails = (ProductDetailsPage) cycle
84                 .getPage("ProductDetails");
85         prodDetails.setItemID(((String JavaDoc) parameters[0]));
86         cycle.activate(prodDetails);
87     }
88
89 }
Popular Tags