1 package org.apache.tapestry.pets.presentation.components; 2 3 import org.apache.tapestry.BaseComponent; 4 import org.apache.tapestry.IMarkupWriter; 5 import org.apache.tapestry.IRequestCycle; 6 import org.apache.tapestry.event.PageDetachListener; 7 import org.apache.tapestry.event.PageEvent; 8 9 import org.apache.tapestry.pets.domain.model.IProduct; 10 import org.apache.tapestry.pets.presentation.pages.ProductCategoryPage; 11 12 public class FavoriteCategory extends BaseComponent implements PageDetachListener 13 { 14 private String favoriteCategory; 15 private String language; 16 private IProduct[] productList; 17 private IProduct currentProduct; 18 19 public void pageDetached(PageEvent event) 20 { 21 currentProduct = null; 22 productList = null; 23 } 24 25 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) 26 { 27 setProductList(); 28 super.renderComponent(writer, cycle); 29 } 30 31 public void finishLoad() 32 { 33 getPage().addPageDetachListener(this); 34 } 35 36 public void setProductList() 37 { 38 } 40 41 public IProduct[] getProductsList() 42 { 43 return productList; 44 } 45 46 public IProduct getCurrentProduct() 47 { 48 return this.currentProduct; 49 } 50 51 public void setCurrentProduct(IProduct value) 52 { 53 this.currentProduct = value; 54 } 55 56 public void selectItem(IRequestCycle cycle) 57 { 58 Object [] parameters = cycle.getServiceParameters(); 59 String prodid = ((String ) parameters[0]).toString(); 60 String prodname = ((String ) parameters[1]).toString(); 61 ProductCategoryPage productcategory = (ProductCategoryPage) cycle.getPage("ProductCategory"); 62 productcategory.setProdID(prodid); 63 productcategory.setProdName(prodname); 64 cycle.activate(productcategory); 66 } 67 68 public String getFavoriteCategory() 69 { 70 return favoriteCategory; 71 } 72 73 public void setFavoriteCategory(String favoriteCategory) 74 { 75 this.favoriteCategory = favoriteCategory; 76 } 77 78 public String getLanguage() 79 { 80 return language; 81 } 82 83 public void setLanguage(String language) 84 { 85 this.language = language; 86 } 87 } 88 | Popular Tags |