KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > product > struts > ProductPriceForm


1 package com.dotmarketing.portlets.product.struts;
2
3 import javax.portlet.ActionRequest;
4
5 import org.apache.struts.Globals;
6 import org.apache.struts.action.ActionErrors;
7 import org.apache.struts.action.ActionMapping;
8 import org.apache.struts.action.ActionMessage;
9 import org.apache.struts.validator.ValidatorForm;
10
11 public class ProductPriceForm extends ValidatorForm {
12
13     private static final long serialVersionUID = 1L;
14
15     private long inode; //identifier
16
private long productFormatInode; //persistent
17
private int minQty; //persistent
18
private int maxQty; //persistent
19
private float retailPrice; //persistent
20
private float partnerPrice; //persistent
21

22     public ProductPriceForm() {
23     }
24
25     public long getInode() {
26         return inode;
27     }
28
29     public void setInode(long inode) {
30         this.inode = inode;
31     }
32
33     public int getMaxQty() {
34         return maxQty;
35     }
36
37     public void setMaxQty(int maxQty) {
38         this.maxQty = maxQty;
39     }
40
41     public int getMinQty() {
42         return minQty;
43     }
44
45     public void setMinQty(int minQty) {
46         this.minQty = minQty;
47     }
48
49     public float getPartnerPrice() {
50         return partnerPrice;
51     }
52
53     public void setPartnerPrice(float partnerPrice) {
54         this.partnerPrice = partnerPrice;
55     }
56
57     public long getProductFormatInode() {
58         return productFormatInode;
59     }
60
61     public void setProductFormatInode(long productFormatInode) {
62         this.productFormatInode = productFormatInode;
63     }
64
65     public float getRetailPrice() {
66         return retailPrice;
67     }
68
69     public void setRetailPrice(float retailPrice) {
70         this.retailPrice = retailPrice;
71     }
72
73     public ActionErrors validate(ActionMapping mapping,ActionRequest req)
74     {
75         ActionErrors ae = new ActionErrors();
76         if(minQty < 0)
77         {
78             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Min Qty"));
79         }
80         if(maxQty < 0 || maxQty < minQty)
81         {
82             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Max Qty"));
83         }
84         if(retailPrice <= 0)
85         {
86             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Retail Price"));
87         }
88         if(partnerPrice <= 0)
89         {
90             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Partner Price"));
91         }
92         return ae;
93     }
94 }
95
Popular Tags