public abstract class MainServlet extends FlashServlet
FlashServlet
that provides default
functionality for main page servlet processing and defines method
signatures for specific servlet requirements.Modifier and Type | Class and Description |
---|---|
protected class |
MainServlet.Context
Inner class used to store servlet context information.
|
FlashServlet.Stack
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
CATEGORY_PATH_LINK
The value of the "Categories.Path.Link" key in properties.
|
private static java.lang.String |
CATEGORY_PATH_SEPARATOR
The value of the "Categories.Path.Separator" key in properties.
|
private static boolean |
CATEGORY_PATH_SHOWTOP
The value of the "Categories.Path.Show.Topmost" key in properties.
|
protected static int |
DISPLAY_MODE
The value of the "Categories.Display.Mode" key in properties.
|
private static int |
EXTERNALREQ_CATEGORY
The external request type for a category request.
|
private static int |
EXTERNALREQ_NONE
The external request type for no request.
|
private static int |
EXTERNALREQ_PRODUCT
The external request type for a product request.
|
private static long |
serialVersionUID
The class' serialization version id.
|
protected static java.lang.String |
SN_ADMINMODE
The session's key for the current admin mode (cfg or tbl).
|
protected static java.lang.String |
SN_CATEGORIES
The session's key for the user's current category list.
|
protected static java.lang.String |
SN_CATEGORIES_LISTONLY
The session's key for the user's current category list only flag.
|
protected static java.lang.String |
SN_CATEGORIES_PATH
The session's key for the user's current category path.
|
protected static java.lang.String |
SN_CATEGORY
The session's key for the catalog's current category.
|
protected static java.lang.String |
SN_CONTINUE_PAGEURL
The session's key for the catalog's current continue shopping url.
|
protected static java.lang.String |
SN_PRODUCTS
The session's key for the catalog's current list of products.
|
protected static java.lang.String |
SN_PRODUCTS_INSTOCK
The session's key for the catalog's current list of products with stock.
|
protected static java.lang.String |
SN_PRODUCTS_NOSTOCK
The session's key for the catalog's current omit no stock flag.
|
protected static java.lang.String |
SN_PRODUCTS_PAFILTERS
The session's key for the catalog's current list of product attribute filters.
|
protected static java.lang.String |
SN_PRODUCTS_PAGEHIST
The session's key for the catalog's current page history.
|
protected static java.lang.String |
SN_PRODUCTS_PAGENUM
The session's key for the catalog's current page number.
|
protected static java.lang.String |
SN_PRODUCTS_PAGEURL
The session's key for the catalog's current page url.
|
protected static java.lang.String |
SOURCE_CATALOG
The source code for a catalog product ("Catalog").
|
protected static java.lang.String |
SOURCE_FAVORITES
The source code for a favorite items product ("Favorites").
|
protected static java.lang.String |
SOURCE_SEARCH
The source code for a search results product ("Search").
|
protected static java.lang.String |
SOURCE_SHOPCART
The source code for a shopping cart product ("ShopCart").
|
protected static java.lang.String |
SOURCE_SPECIAL
The source code for a special product ("Special").
|
SN_CART, SN_LOGON_STATUS, SN_SECPROFILE, SN_USER, SN_USERSFI
BROWSER_IE, BROWSER_NN, BROWSER_XX, RESP_NULL, RESP_REDIRECTED, RQST_AJAX, RQST_NULL
Constructor and Description |
---|
MainServlet() |
Modifier and Type | Method and Description |
---|---|
private void |
buildCategories(MainServlet.Context ctx)
Builds the product categories list for the current servlet context.
|
private void |
buildCategoriesDefault(MainServlet.Context ctx,
Category topcategory,
Category dftcategory)
Builds a revised category list based on given topmost (catalog) category
and given starting category.
|
private void |
buildCategoriesParent(MainServlet.Context ctx,
Category category)
Builds a revised category list, or a portion of the revised category list
based on a given parent category starting point.
|
private boolean |
buildCategoriesPrevious(MainServlet.Context ctx,
Category category,
boolean clone)
Builds a revised category list based on all or part of the previously
displayed category list.
|
private void |
buildCategoriesTopmost(MainServlet.Context ctx)
Builds a revised category list based on the user's topmost (catalog)
category and default starting category.
|
private void |
buildCategoriesTopmost(MainServlet.Context ctx,
java.lang.String category)
Builds a revised category list based on the user's topmost (catalog)
category and the given starting category.
|
protected int |
confirmSession(BaseServlet.Context baseCtx)
Determines if the servlet is being accessed within the context of a valid
user session.
|
protected FlashServlet.Context |
createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Creates the servlet context inner class.
|
private void |
findCategoryInPreviousList(MainServlet.Context ctx,
Category category)
Finds the given category in the previously displayed list of categories
and sets the context variable for the category's index (ctx.mpSelectedIdx).
|
private void |
findCategoryInPreviousList(MainServlet.Context ctx,
java.lang.String category)
Finds the given category in the previously displayed list of categories
and sets the context variable for the category's index (ctx.mpSelectedIdx).
|
protected java.util.ArrayList<CategoryListItem> |
getPreviousCategoryList(MainServlet.Context ctx)
Returns the previous category list stored in the session.
|
protected java.util.ArrayList<Category> |
getPreviousCategoryPath(MainServlet.Context ctx)
Returns the previous category path stored in the session.
|
protected boolean |
hasSubcategories(MainServlet.Context ctx,
Category category)
Answers if the given category has subcategories.
|
protected boolean |
hasSubcategories(MainServlet.Context ctx,
java.lang.String category)
Answers if the given category has subcategories.
|
private boolean |
isExpiredRequest(MainServlet.Context ctx)
Determines if the current request is expired and, if so, displays the
expired request page.
|
private int |
isExternalRequest(MainServlet.Context ctx)
Determines if an external request has been made for category or product
information and, if so, sets the
ctx.mpRedirectURL url for the
request. |
protected boolean |
isOmitNoStock(MainServlet.Context ctx)
Anwers if products with stock should be processed based on the current
session flag
SN_PRODUCTS_NOSTOCK . |
protected boolean |
isPreshopRequest(MainServlet.Context ctx)
Answers if a request has been made that uses the preshop layout (no banner
links, no navigation bar options and no displayed categories).
|
private boolean |
isRedirectURL(MainServlet.Context ctx)
Answers if the current value for
ctx.mpRedirectURL is for a valid
redirection. |
protected boolean |
isUserHelpRequest(MainServlet.Context ctx)
Answers if a request has been made for user help.
|
private CategoryListItem |
newCategoryListItem(MainServlet.Context ctx,
Category category,
int type,
java.util.ArrayList<Category> children)
Creates and returns a new category list item using the supplied values.
|
private void |
setCategoryPathData(MainServlet.Context ctx)
Retrieves and sets the category path data for the current selected category.
|
private void |
setCategoryProductData(MainServlet.Context ctx)
Retrieves and sets the product data required for the current selected
category.
|
protected void |
setTemplateCategoryPath(MainServlet.Context ctx)
Invoked by a subclass' implementation of
setTemplateData to
retrieve and set the category path data required by the html template. |
protected boolean |
sortCategoryProductData(MainServlet.Context ctx,
java.util.ArrayList<Product> products,
java.util.ArrayList<Product> productsInStock)
Sorts the given collections of products, only if additional sorting is
necessary.
|
private void |
updateServletRequest(MainServlet.Context ctx,
FlashServletRequest fsr)
Updates the given servlet request with category and category path
data so subsequent invocations of the same request will display the
same information.
|
protected void |
writePageImpl(BaseServlet.Context baseCtx)
Provides additional application-specific functionality for writing a page.
|
confirmCart, confirmRequest, confirmRetail, confirmWholesale, createNewCart, createNewSessionImpl, getPageTitle, getServletPath, getUser, initTemplateDataImpl, isLogonRequest, requestComplete, requiresLogon, resetCart, resetCategories, resetProducts, setDefaultUser, setSessionCart, setSFIShoppingUser, useExistingSessionImpl, writeCookie
createNewSession, determineBrowser, doGet, doPost, editFormFields, getCookie, getInvokerName, getInvokerName, getInvokerParams, getInvokerParams, getInvokerPath, getInvokerPath, getInvokerURL, getNextURL, getPageParams, getRequestURL, getServletName, getServletName, getServletParams, getServletParams, getServletPath, getServletURL, getServletURL, getTemplateMessage, getTemplateMessage, getTemplateMessage, getTemplateMessage, getTemplateMessage, getTemplateName, initTemplateData, isPrintable, isServerTomcat, log, qualifyURL, readParameters, redirectURL, resetFormFields, setCookieValues, setP3PCompactPolicy, setSessionValues, setTemplateData, showSiteError, showSiteError, showSiteError, useExistingSession, writeCookie, writeTempCookie
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
private static final long serialVersionUID
protected static final java.lang.String SOURCE_CATALOG
protected static final java.lang.String SOURCE_SEARCH
protected static final java.lang.String SOURCE_SHOPCART
protected static final java.lang.String SOURCE_FAVORITES
protected static final java.lang.String SOURCE_SPECIAL
protected static final java.lang.String SN_ADMINMODE
protected static final java.lang.String SN_CATEGORY
protected static final java.lang.String SN_CATEGORIES
protected static final java.lang.String SN_CATEGORIES_PATH
protected static final java.lang.String SN_CATEGORIES_LISTONLY
resetCategories
method's dolistonly
parameter for a description of how this session value is used.protected static final java.lang.String SN_PRODUCTS
protected static final java.lang.String SN_PRODUCTS_INSTOCK
protected static final java.lang.String SN_PRODUCTS_NOSTOCK
protected static final java.lang.String SN_PRODUCTS_PAFILTERS
protected static final java.lang.String SN_PRODUCTS_PAGENUM
protected static final java.lang.String SN_PRODUCTS_PAGEHIST
protected static final java.lang.String SN_PRODUCTS_PAGEURL
protected static final java.lang.String SN_CONTINUE_PAGEURL
private static final int EXTERNALREQ_NONE
private static final int EXTERNALREQ_CATEGORY
private static final int EXTERNALREQ_PRODUCT
protected static final int DISPLAY_MODE
Home
servlet.
Home
servlet. The first level
of subcategories are NOT repeated in the main area and the standard home
page is displayed.Home
servlet. The first level
of subcategories is repeated in the main area and displayed as the home
page.private static final java.lang.String CATEGORY_PATH_LINK
private static final java.lang.String CATEGORY_PATH_SEPARATOR
private static final boolean CATEGORY_PATH_SHOWTOP
protected int confirmSession(BaseServlet.Context baseCtx) throws java.io.IOException
doGet
and doPost
methods.
Overrides confirmSession
in FlashServlet
.confirmSession
in class FlashServlet
baseCtx
- (Context) The current servlet context.java.io.IOException
- - if an error occurs while confirming the
user session.protected void writePageImpl(BaseServlet.Context baseCtx)
writePage
method.
Overrides writePageImpl
in FlashServlet
.writePageImpl
in class FlashServlet
baseCtx
- (Context) The current servlet context.private void buildCategories(MainServlet.Context ctx)
ctx
- (Context) The current servlet context.private void buildCategoriesDefault(MainServlet.Context ctx, Category topcategory, Category dftcategory)
ctx
- (Context) The current servlet context.topcategory
- (Category) The topmost (catalog) category.dftcategory
- (Category) The default starting category.private void buildCategoriesParent(MainServlet.Context ctx, Category category)
ctx
- (Context) The current servlet context.category
- (Category) The category that is to be used as the
starting point for building the list.private boolean buildCategoriesPrevious(MainServlet.Context ctx, Category category, boolean clone)
ctx
- (Context) The current servlet context.category
- (Category) The selected or target category.clone
- (boolean) true
if it has already been determined
that the revised list will be an exact copy of the previously
displayed list; otherwise false
.true
if the list is successfully built,
otherwise false
.private void buildCategoriesTopmost(MainServlet.Context ctx)
ctx
- (Context) The current servlet context.private void buildCategoriesTopmost(MainServlet.Context ctx, java.lang.String category)
ctx
- (Context) The current servlet context.category
- (String) The starting category or null
if
the starting category is not known, in which case the user's
default starting category will be used.private void findCategoryInPreviousList(MainServlet.Context ctx, Category category)
ctx
- (Context) The current servlet context.category
- (Category) The selected category.private void findCategoryInPreviousList(MainServlet.Context ctx, java.lang.String category)
ctx
- (Context) The current servlet context.category
- (String) The selected category.protected java.util.ArrayList<CategoryListItem> getPreviousCategoryList(MainServlet.Context ctx)
ctx
- (Context) The current servlet context.protected java.util.ArrayList<Category> getPreviousCategoryPath(MainServlet.Context ctx)
ctx
- (Context) The current servlet context.protected boolean hasSubcategories(MainServlet.Context ctx, Category category)
ctx
- (Context) The current servlet context.category
- (Category) The category to check.true
if the category has subcategories,
otherwise false
.protected boolean hasSubcategories(MainServlet.Context ctx, java.lang.String category)
ctx
- (Context) The current servlet context.category
- (String) The category to check.true
if the category has subcategories,
otherwise false
.private boolean isExpiredRequest(MainServlet.Context ctx) throws java.io.IOException
ctx
- (Context) The current servlet context.true
if the current request is expired,
otherwise false
.java.io.IOException
- - if an error occurs while displaying the
expired request page.private int isExternalRequest(MainServlet.Context ctx)
ctx.mpRedirectURL
url for the
request.ctx
- (Context) The current servlet context.EXTERNALREQ_NONE
if no valid external request has
been made, otherwise one of the other EXTERNALREQ
codes
is returned.protected boolean isPreshopRequest(MainServlet.Context ctx)
false
. This method should be overridden by a subclass if the
subclass requires something different than the default.ctx
- (Context) The current servlet context.true
if this is a request for preshop,
otherwise false
.protected boolean isUserHelpRequest(MainServlet.Context ctx)
ctx
- (Context) The current servlet context.true
if this is a request for user help,
otherwise false
.private boolean isRedirectURL(MainServlet.Context ctx)
ctx.mpRedirectURL
is for a valid
redirection. A redirection is considered valid if it is not null
and if it is not for the exact same request that is already being requested.ctx
- (Context) The current servlet context.true
for a valid redirection, otherwise
false
.protected boolean isOmitNoStock(MainServlet.Context ctx)
SN_PRODUCTS_NOSTOCK
. If the session flag has not yet
been established, then the answer is based on the configured properties
value for "Product.Catalog.OmitNoStock.Default". A submitted form field
flag for omitting no stock products should take precedence over the value
returned here. Servlets that accept a submitted form field should set the
SN_PRODUCTS_NOSTOCK
session value to reflect what was submitted.ctx
- (Context) The current servlet context.true
if in stock products should be processed,
otherwise false
.private CategoryListItem newCategoryListItem(MainServlet.Context ctx, Category category, int type, java.util.ArrayList<Category> children)
ctx
- (Context) The current servlet context.category
- (Category) The category object associated with this
list item.type
- (int) The type of list item (topcategory or subcategory).
Must be one of the list type constants (TOPCATEGORY, SUBCATEGORY).children
- (ArrayList) A collection of children for this list item's
category.private void setCategoryPathData(MainServlet.Context ctx)
ctx
- (Context) The current servlet context.private void setCategoryProductData(MainServlet.Context ctx)
ctx
- (Context) The current servlet context.protected boolean sortCategoryProductData(MainServlet.Context ctx, java.util.ArrayList<Product> products, java.util.ArrayList<Product> productsInStock)
ctx
- (Context) The current servlet context.products
- (ArrayList) The collection of all products for the
current category.productsInStock
- (ArrayList) The collection of in-stock products
for the current category.true
if additional sorting was performed,
otherwise false
.protected void setTemplateCategoryPath(MainServlet.Context ctx)
setTemplateData
to
retrieve and set the category path data required by the html template.
The template variable created by this method is named $CategoryPath
and must be coded in the template as $str.pre($CategoryPath)
.ctx
- (Context) The current servlet context.private void updateServletRequest(MainServlet.Context ctx, FlashServletRequest fsr)
ctx
- (Context) The current servlet context.fsr
- (FlashServletRequest) The servlet request to update.protected FlashServlet.Context createContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
createContext
in FlashServlet
.
Invoked by doPost
and doGet
methods.createContext
in class FlashServlet
request
- (HttpServletRequest) The servlet's incoming request.response
- (HttpServletResponse) The servlet's outgoing response.