Class ProductAction
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'snameis appended to this value (which is initialized with thestoreNamesetting from thesscSettingdatabase table). By default this variable is used in the <title> tag of the html header.htmlHeadKeywords: This value is replaced with the product'skeywordsproperty. By default this variable is used in the <meta>/keywords tag of the html header.htmlHeadDescription: This value is replaced with the product'sshortDescriptionproperty. By default this variable is used in the <meta>/description tag of the html header.
- Author:
- David Tobey
- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.struts.action.Action
servlet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.struts.action.ActionForwardexecute(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, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
-
Field Details
-
log
static org.apache.commons.logging.Log log
-
-
Constructor Details
-
ProductAction
public ProductAction()
-
-
Method Details
-
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 Exception - Overrides:
executein classorg.apache.struts.action.Action- Throws:
Exception
-