Class CartAddForm
java.lang.Object
org.apache.struts.action.ActionForm
com.softslate.commerce.customer.core.BaseForm
com.softslate.commerce.customer.order.CartAddForm
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AddItemForm
,CartEditForm
,CartItemEditForm
Struts form class for submissions to add items to the current user's cart.
Used for requests to "/CartAdd.do" and "/CartAddMultiple.do".
The validate
method of this class checks the
orderProductQuantities
property to make sure the user entered
a quantity greater than zero for at least one product. It checks the
orderProductCodes
property to make sure that at least one
product code was submitted.
It also populates the orderAttributes
property with submitted
product attributes and their values, and checks the
requiredAttributeCodes
property to make sure values were
submitted for required product attributes.
Here is a summary of the request parameters involved in a request to add items to the cart:
orderProductQuantities
: An array of integers corresponding to the quantities of each item being added to the cart.orderProductCodes
: An array of product codes corresponding to each item being added to the cart. The order of the product codes must correspond to the order of the quantities in theorderProductQuantities
parameter.requiredAttributeCodes
: An array of required attributes. Each element of the array is a pipe-separated concatenation of the attribute code and the product code, in the form of productCode|attributeCode. Note that the check for required attributes is done in this class based on elements included in the request submission. It is also repeated withinCartProcessor.processAddItems(Map)
, against the database itself.requiredAttributeNames
: An array of the names of the required attributes. Each element of the array is the name of the corresponding required attribute in therequiredAttributeCodes
property. They are included in the request so that an error message can be displayed to the customer without the need to hit the database.- Attributes and their values: Any number of additional request parameters may exist that contain the attribute values selected or entered by the customer. The names of these parameters are a pipe-separated concatenation of the product code and attribute code, in the form of productCode|attributeCode. The values of each parameter contain what the customer entered, in the case of the expandedInput and compactInput attribute types. In the case of the other attribute types, the value consists of the code of the option that the customer selected.
- Author:
- David Tobey
- See Also:
-
Field Summary
Modifier and TypeFieldDescription(package private) static org.apache.commons.logging.Log
private HashMap
private String[]
private String[]
private String[]
private String[]
private String[]
private static final long
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionString[]
String[]
String[]
String[]
String[]
void
setOrderAttributes
(HashMap orderAttributes) void
setOrderProductCodes
(String[] orderProductCodes) void
setOrderProductQuantities
(String[] orderProductQuantities) void
setProductNames
(String[] productNames) void
setRequiredAttributeCodes
(String[] requiredAttributeCodes) void
setRequiredAttributeNames
(String[] requiredAttributeNames) org.apache.struts.action.ActionErrors
validate
(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) void
Checks that required attributes were submitted, and constructs this form'sorderAttributes
property, which holds a Map of the submitted attributes.void
void
Checks that at least one product code was submitted.void
Checks that the user entered a quantity greater than 0 for at least one product.Methods inherited from class com.softslate.commerce.customer.core.BaseForm
formUtils, getBusinessObjectFactory, getErrors, getMapping, getMessage, getMessages, getRequest, getSettings, getUser, html5OrXhtml, initializeProperties, setBusinessObjectFactory, setErrors, setMapping, setMessages, setRequest, setSettings, setUser
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, reset, setMultipartRequestHandler, setServlet, validate
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
log
static org.apache.commons.logging.Log log -
orderProductCodes
-
requiredAttributeCodes
-
requiredAttributeNames
-
productNames
-
orderProductQuantities
-
orderAttributes
-
-
Constructor Details
-
CartAddForm
public CartAddForm()
-
-
Method Details
-
getOrderProductCodes
-
setOrderProductCodes
-
getRequiredAttributeCodes
-
setRequiredAttributeCodes
-
getRequiredAttributeNames
-
setRequiredAttributeNames
-
getProductNames
-
setProductNames
-
getOrderProductQuantities
-
setOrderProductQuantities
-
getOrderAttributes
-
setOrderAttributes
-
validate
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) - Overrides:
validate
in classorg.apache.struts.action.ActionForm
-
validateQuantity
public void validateQuantity()Checks that the user entered a quantity greater than 0 for at least one product. -
validateProductCode
public void validateProductCode()Checks that at least one product code was submitted. -
validateAttributes
public void validateAttributes()Checks that required attributes were submitted, and constructs this form'sorderAttributes
property, which holds a Map of the submitted attributes. -
validateMaxItemsPerOrder
public void validateMaxItemsPerOrder()
-