KickJava   Java API By Example, From Geeks To Geeks.

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


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.catalog.Catalog;
7 import com.opensymphony.webwork.example.ajax.catalog.CatalogAware;
8 import com.opensymphony.webwork.example.ajax.catalog.Product;
9
10 /**
11  * AbstractModifyCartAction
12  *
13  * @author Jason Carreira <jcarreira@eplus.com>
14  */

15 public abstract class AbstractModifyCartAction extends ShowCart implements CatalogAware {
16     protected int quantity;
17     private Integer JavaDoc productId;
18     protected Product product;
19     protected Catalog catalog;
20
21     public void setCatalog(Catalog catalog) {
22         this.catalog = catalog;
23     }
24
25     public void setQuantity(int quantity) {
26         this.quantity = quantity;
27     }
28
29     public int getQuantity() {
30         return quantity;
31     }
32
33     public void setProductId(Integer JavaDoc productId) {
34         this.productId = productId;
35     }
36
37     public Integer JavaDoc getProductId() {
38         return productId;
39     }
40
41     public Product getProduct() {
42         return product;
43     }
44
45     public void validate() {
46         if (productId != null) {
47             product = catalog.findProductById(productId);
48             if (product == null) {
49                 addFieldError("productId", "There is no product '" + productId + "' in the catalog " + catalog.getName());
50             }
51         }
52     }
53 }
54
Popular Tags