com.softslate.commerce.customer.product
Class ProductAction
java.lang.Object
org.apache.struts.action.Action
com.softslate.commerce.customer.core.BaseAction
com.softslate.commerce.customer.product.ProductAction
public class ProductAction
- extends BaseAction
Struts action class that corresponds to the product page. Used for requests
to "/Product.do".
The execute
method of this class populates a product's
information from the database and puts it in the request scope for use by the
view layer. Given a
ProductForm
with its
code
property populated, it creates and initializes an
instance of Product
.
It then invokes
ProductProcessor.getProductFromCode(Product)
to load the product's information from the database. It puts the initialized
Product
object in the request scope as an attribute with the
names "productForm" and "product". A Map
representing the
product's custom settings and other settings is also placed in the request
scope as an attribute named "productSettings".
The execute
method next loads a Map
of
attribute-only SKUs and places it in the request as an attribute named
"attributeSKUs" so they may be displayed on the product page. (Attribute-only
SKUs are SKUs which are not tied to any particular product but which may
still be relevant to the product being displayed.)
Next, the execute
method determines the user's "current
category" for purposes of breadcrumbing and places it in a session attribute
named "currentCategory", holding the code
property of the
user's current category. If the user has clicked a link from a category page
to arrive at the product page, a request parameter named "category" is used.
Otherwise, for example if the user has arrived from the search results page
or some other source, the product's primaryCategory
is used.
The current category determines what category appears above the product in
the breadcrumbing links, as well as what category is highlighted in the
category tree.
Finally, three other request attributes are set from the product's data. Each
of these variables is initialized with default values in
BaseRequestProcessor.processPreprocess(HttpServletRequest, HttpServletResponse)
and altered here with product-specific data:
htmlHeadTitle
: The product's name
is
appended to this value (which is initialized with the storeName
setting from the sscSetting
database table). By default this
variable is used in the <title> tag of the html header.
htmlHeadKeywords
: This value is replaced with the
product's keywords
property. By default this variable is used
in the <meta>/keywords tag of the html header.
htmlHeadDescription
: This value is replaced with the
product's shortDescription
property. By default this variable
is used in the <meta>/description tag of the html header.
An instance of
CartDiscountProcessor
is
also instantiated and place in the request scope as an attribute named
"cartDiscountProcessor", to help in the display of discounts applicable to
the user.
- Author:
- David Tobey
- See Also:
ProductForm
,
Product
,
ProductProcessor
Field Summary |
(package private) static org.apache.commons.logging.Log |
log
|
Fields inherited from class org.apache.struts.action.Action |
defaultLocale, servlet |
Method Summary |
org.apache.struts.action.ActionForward |
execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
Methods inherited from class org.apache.struts.action.Action |
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
static org.apache.commons.logging.Log log
ProductAction
public ProductAction()
execute
public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
- Overrides:
execute
in class org.apache.struts.action.Action
- Throws:
java.lang.Exception
Copyright ? SoftSlate, LLC 2003?2005