1 4 package com.opensymphony.webwork.example.ajax.actions; 5 6 import com.opensymphony.webwork.example.ajax.cart.ShoppingCart; 7 import com.opensymphony.webwork.example.ajax.cart.ShoppingCartAware; 8 import com.opensymphony.webwork.example.ajax.catalog.Catalog; 9 import com.opensymphony.webwork.example.ajax.catalog.CatalogAware; 10 import com.opensymphony.webwork.example.ajax.catalog.Category; 11 import com.opensymphony.webwork.interceptor.SessionAware; 12 import com.opensymphony.xwork.ActionSupport; 13 14 import java.util.Map ; 15 16 21 public class ActiveCategory extends ActionSupport implements SessionAware, CatalogAware, ShoppingCartAware { 22 public static final String ACTIVE_CATEGORY_ID = "catalog_activeCategoryId"; 23 private Map session; 24 private Category category; 25 private Catalog catalog; 26 private ShoppingCart cart; 27 28 public void setSession(Map session) { 29 this.session = session; 30 } 31 32 public void setCatalog(Catalog catalog) { 33 this.catalog = catalog; 34 } 35 36 public Catalog getCatalog() { 37 return catalog; 38 } 39 40 public Integer getCategoryId() { 41 return (Integer ) session.get(ACTIVE_CATEGORY_ID); 42 } 43 44 public Category getCategory() { 45 return category; 46 } 47 48 public String execute() throws Exception { 49 Integer categoryId = getCategoryId(); 50 if (categoryId != null) { 51 category = catalog.findCategoryForId(categoryId); 52 } 53 return SUCCESS; 54 } 55 56 public void setShoppingCart(ShoppingCart cart) { 57 this.cart = cart; 58 } 59 60 public ShoppingCart getCart() { 61 return cart; 62 } 63 } 64 | Popular Tags |