KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.tapestry.pets.presentation.pages;
2
3 import java.text.NumberFormat JavaDoc;
4
5 import johnmammen.betterpetshop.service.PetshopManager;
6
7 import org.apache.tapestry.event.PageEvent;
8 import org.apache.tapestry.event.PageRenderListener;
9 import org.apache.tapestry.pets.PetshopBasePage;
10
11 import org.apache.tapestry.pets.domain.model.IItem;
12
13 public abstract class ProductDetailsPage extends PetshopBasePage implements
14         PageRenderListener {
15
16     //for getting the petshop service
17
public abstract PetshopManager getPetshopService();
18
19     public void pageBeginRender(PageEvent event) {
20         if (getItemID() != null) setItemDetails();
21         if (getCurrencyFormat() == null)
22                 setCurrencyFormat(NumberFormat.getCurrencyInstance(getEngine()
23                         .getLocale()));
24     }
25
26     private void setItemDetails() {
27
28         // PetshopManager petManager=null;
29
// try {
30
// WebApplicationContext appcontext = WebApplicationContextUtils
31
// .getWebApplicationContext(getRequestCycle()
32
// .getRequestContext().getServlet()
33
// .getServletContext());
34
// petManager = (PetshopManager) appcontext.getBean("petshopService");
35
// }catch(Exception e){
36
//
37
// }
38

39         //IItem item = Products.getItem(getItemID(), getUserLanguage());
40
IItem item = getPetshopService().getItem(getItemID());
41 // setPrice(item.getPrice().doubleValue());
42
// setQty(item.getQty());
43
// setItemName(item.getItemName());
44
// setItemAttr(item.getItemAttr1());
45
// setDesc(item.getDesc());
46
// setImage(item.getImage());
47

48         setPrice(item.getListprice().doubleValue());
49         setQty(item.getQty());
50         setItemName(item.getProduct().getProductdetail().getName());
51         setItemAttr(item.getItemid());
52         setDesc(item.getProduct().getProductdetail().getDescn());
53         setImage(item.getProduct().getImage());
54         setBackOrdered((getQty() > 0) ? false : true);
55     }
56
57     public abstract NumberFormat JavaDoc getCurrencyFormat();
58
59     public abstract void setCurrencyFormat(NumberFormat JavaDoc format);
60
61     public abstract void setItemID(String JavaDoc itemID);
62
63     public abstract String JavaDoc getItemID();
64
65     public abstract double getPrice();
66
67     public abstract int getQty();
68
69     public abstract String JavaDoc getItemName();
70
71     public abstract String JavaDoc getItemAttr();
72
73     public abstract String JavaDoc getDesc();
74
75     public abstract String JavaDoc getImage();
76
77     public abstract boolean isBackOrdered();
78
79     public abstract void setBackOrdered(boolean b);
80
81     public abstract void setDesc(String JavaDoc string);
82
83     public abstract void setImage(String JavaDoc string);
84
85     public abstract void setItemAttr(String JavaDoc string);
86
87     public abstract void setItemName(String JavaDoc string);
88
89     public abstract void setPrice(double d);
90
91     public abstract void setQty(int q);
92
93 }
Popular Tags