1 package org.apache.tapestry.pets.presentation.pages; 2 3 import java.text.NumberFormat ; 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 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 39 IItem item = getPetshopService().getItem(getItemID()); 41 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 getCurrencyFormat(); 58 59 public abstract void setCurrencyFormat(NumberFormat format); 60 61 public abstract void setItemID(String itemID); 62 63 public abstract String getItemID(); 64 65 public abstract double getPrice(); 66 67 public abstract int getQty(); 68 69 public abstract String getItemName(); 70 71 public abstract String getItemAttr(); 72 73 public abstract String getDesc(); 74 75 public abstract String getImage(); 76 77 public abstract boolean isBackOrdered(); 78 79 public abstract void setBackOrdered(boolean b); 80 81 public abstract void setDesc(String string); 82 83 public abstract void setImage(String string); 84 85 public abstract void setItemAttr(String string); 86 87 public abstract void setItemName(String string); 88 89 public abstract void setPrice(double d); 90 91 public abstract void setQty(int q); 92 93 } | Popular Tags |