KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > example > ajax > actions > ActiveCategory


1 /*
2  * Copyright (c) 2005 Your Corporation. All Rights Reserved.
3  */

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 JavaDoc;
15
16 /**
17  * ActiveCategory
18  *
19  * @author Jason Carreira <jcarreira@eplus.com>
20  */

21 public class ActiveCategory extends ActionSupport implements SessionAware, CatalogAware, ShoppingCartAware {
22     public static final String JavaDoc ACTIVE_CATEGORY_ID = "catalog_activeCategoryId";
23     private Map JavaDoc session;
24     private Category category;
25     private Catalog catalog;
26     private ShoppingCart cart;
27
28     public void setSession(Map JavaDoc 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 JavaDoc getCategoryId() {
41         return (Integer JavaDoc) session.get(ACTIVE_CATEGORY_ID);
42     }
43
44     public Category getCategory() {
45         return category;
46     }
47
48     public String JavaDoc execute() throws Exception JavaDoc {
49         Integer JavaDoc 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