1 package com.dotmarketing.portlets.product.struts; 2 3 import java.util.List ; 4 5 import javax.portlet.ActionRequest; 6 import javax.servlet.http.HttpServletRequest ; 7 8 import org.apache.struts.Globals; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionMapping; 11 import org.apache.struts.action.ActionMessage; 12 import org.apache.struts.validator.ValidatorForm; 13 14 import com.dotmarketing.util.UtilMethods; 15 import com.liferay.portal.util.Constants; 16 17 public class ProductForm extends ValidatorForm { 18 19 private static final long serialVersionUID = 1L; 20 private long inode; private String title; private String shortDescription; private String longDescription; private boolean reqShipping; private boolean featured; private String comments; 28 private String [] productTypes; 30 private String [] topics; 31 private String [] FilesInodesList; 33 private String [] FilesInodes; 34 35 private long smallImage; 37 private long selectedSmallImage; 38 private long mediumImage; 39 private long selectedMediumImage; 40 private long largeImage; 41 private long selectedLargeImage; 42 43 private String orderBy = "sort_order"; 44 private String direction = "asc"; 45 private String keyword; 46 private List products; 47 private List formats; 48 private String [] relatedProducts; 49 private boolean showOnWeb; 50 public ProductForm() 51 { 52 } 53 54 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 55 if(request.getParameter("cmd")!=null && request.getParameter("cmd").equals(Constants.ADD)) { 56 return super.validate(mapping, request); 57 } 58 return null; 59 } 60 61 public boolean isFeatured() { 62 return featured; 63 } 64 65 public void setFeatured(boolean featured) { 66 this.featured = featured; 67 } 68 69 public long getInode() { 70 return inode; 71 } 72 73 public void setInode(long inode) { 74 this.inode = inode; 75 } 76 77 public String getLongDescription() { 78 return longDescription; 79 } 80 81 public void setLongDescription(String longDescription) { 82 this.longDescription = longDescription; 83 } 84 85 public boolean isReqShipping() { 86 return reqShipping; 87 } 88 89 public void setReqShipping(boolean reqShipping) { 90 this.reqShipping = reqShipping; 91 } 92 93 public String getTitle() { 94 return title; 95 } 96 97 public void setTitle(String title) { 98 this.title = title; 99 } 100 101 public String getKeyword() { 102 return keyword; 103 } 104 105 public void setKeyword(String keyword) { 106 this.keyword = keyword; 107 } 108 109 public String [] getProductTypes() { 110 return productTypes; 111 } 112 113 public void setProductTypes(String [] productTypes) { 114 this.productTypes = productTypes; 115 } 116 117 public String getDirection() { 118 return direction; 119 } 120 121 public void setDirection(String direction) { 122 this.direction = direction; 123 } 124 125 public String getOrderBy() { 126 return orderBy; 127 } 128 129 public void setOrderBy(String orderBy) { 130 this.orderBy = orderBy; 131 } 132 133 public List getFormats() { 134 return formats; 135 } 136 137 public void setFormats(List formats) { 138 this.formats = formats; 139 } 140 141 public List getProducts() { 142 return products; 143 } 144 145 public void setProducts(List products) { 146 this.products = products; 147 } 148 149 public String [] getTopics() { 150 return topics; 151 } 152 153 public void setTopics(String [] topics) { 154 this.topics = topics; 155 } 156 157 public String [] getFilesInodesList() { 158 return FilesInodesList; 159 } 160 161 public void setFilesInodesList(String [] filesInodesList) { 162 FilesInodesList = filesInodesList; 163 } 164 165 public String getShortDescription() { 166 return shortDescription; 167 } 168 169 public void setShortDescription(String shortDescription) { 170 this.shortDescription = shortDescription; 171 } 172 173 public String [] getFilesInodes() { 174 return FilesInodes; 175 } 176 177 public void setFilesInodes(String [] filesInodes) { 178 FilesInodes = filesInodes; 179 } 180 181 public long getLargeImage() { 182 return largeImage; 183 } 184 185 public void setLargeImage(long largeImage) { 186 this.largeImage = largeImage; 187 } 188 189 public long getMediumImage() { 190 return mediumImage; 191 } 192 193 public void setMediumImage(long mediumImage) { 194 this.mediumImage = mediumImage; 195 } 196 197 public long getSmallImage() { 198 return smallImage; 199 } 200 201 public void setSmallImage(long smallImage) { 202 this.smallImage = smallImage; 203 } 204 205 public long getSelectedLargeImage() { 206 return selectedLargeImage; 207 } 208 209 public void setSelectedLargeImage(long selectedLargeImage) { 210 this.selectedLargeImage = selectedLargeImage; 211 } 212 213 public long getSelectedMediumImage() { 214 return selectedMediumImage; 215 } 216 217 public void setSelectedMediumImage(long selectedMediumImage) { 218 this.selectedMediumImage = selectedMediumImage; 219 } 220 221 public long getSelectedSmallImage() { 222 return selectedSmallImage; 223 } 224 225 public void setSelectedSmallImage(long selectedSmallImage) { 226 this.selectedSmallImage = selectedSmallImage; 227 } 228 229 public ActionErrors validate(ActionMapping mapping,ActionRequest req) 230 { 231 ActionErrors ae = new ActionErrors(); 232 if(!UtilMethods.isSet(title)) 233 { 234 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Title")); 235 } 236 if(productTypes.length == 0) 237 { 238 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Product Type")); 239 } 240 if(!UtilMethods.isSet(shortDescription)) 241 { 242 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Short Description")); 243 } 244 if(!UtilMethods.isSet(longDescription)) 245 { 246 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Long Description")); 247 } 248 260 return ae; 261 } 262 263 public String [] getRelatedProducts() { 264 return relatedProducts; 265 } 266 267 public void setRelatedProducts(String [] relatedProducts) { 268 this.relatedProducts = relatedProducts; 269 } 270 271 public String getComments() { 272 return comments; 273 } 274 275 public void setComments(String comments) { 276 this.comments = comments; 277 } 278 279 public boolean isShowOnWeb() { 280 return this.showOnWeb; 281 } 282 283 public void setShowOnWeb(boolean showOnWeb) { 284 this.showOnWeb = showOnWeb; 285 } 286 } 287 | Popular Tags |