com.aoindustries.website.framework
Class WebPage

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.aoindustries.website.framework.ErrorReportingServlet
              extended by com.aoindustries.website.framework.WebPage
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
AutoListPage, DumpURLs, FilePage, InputStreamPage, RedirectWebPage, TreePage

public abstract class WebPage
extends ErrorReportingServlet

The main web page provides the overall layout of the site. The rest of the site overrides methods of this class, but cannot override the reportingDoGet, reportingDoPost, or reportingGetLastModified methods.

Author:
AO Industries, Inc.
See Also:
Serialized Form

Field Summary
protected static WebPage[] emptyWebPageArray
          An empty array of WebPage objects to be used in returning no web pages.
static gnu.regexp.RE reHTMLPattern
           
 
Fields inherited from class com.aoindustries.website.framework.ErrorReportingServlet
BUFFER_SIZE
 
Constructor Summary
WebPage(LoggerAccessor loggerAccessor)
           
WebPage(LoggerAccessor loggerAccessor, java.lang.Object param)
           
WebPage(WebSiteRequest req)
           
 
Method Summary
 boolean canAccess(WebSiteUser user)
          Determines if the provided user can access the page.
 void doGet(com.aoindustries.io.ChainWriter out, WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          By default, GET provides no content.
protected  void doGet(WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          The layout is automatically applied to the page, then doGet is called.
protected  void doPost(com.aoindustries.io.ChainWriter out, WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          By default, a post request just calls doGet
protected  void doPost(WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          By default, a post request is just sets up the content beginning and calls doPost
protected  void doPostWithSearch(WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles any search posts, sends everything else on to doPost(WebSiteRequest,HttpServletResponse).
 boolean enforceEncryption()
          Gets whether this page should enforce the current encrpyption requirement or not.
 boolean equals(java.lang.Object O)
          Determines if this page equals another page.
 boolean equals(WebPage other)
          Determines if this page equals another page.
 java.lang.String generateURLPath(WebPage page)
          Generates a URL path for this or another page, please call getURLPath() instead.
 java.lang.String[] getAdditionalHeaders(WebSiteRequest req)
          Gets additional headers for this page.
 java.lang.String getAuthor()
          Gets the author of this page.
 WebPage[] getCachedPages(WebSiteRequest req)
          Gets all of the pages that are children of this one in the page hierarchy.
protected  long getClassLastModified()
          Gets the last modified time of the java class file.
static long getClassLoaderUptime()
          Gets the time that the classloader was instantiated.
 java.lang.String getContentVAlign(WebSiteRequest req)
          Gets the vertical alignment of the content area.
 java.lang.String getCopyright(WebSiteRequest req, WebPage requestPage)
          Gets the copyright information for this page.
 java.lang.String getDescription()
          Gets the description of this page.
protected  com.aoindustries.io.ChainWriter getHTMLChainWriter(WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          Sets the content type, encoding to UTF-8, sets the additional headers, then returns the ChainWriter.
protected  java.io.OutputStream getHTMLOutputStream(WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          Sets the content type, encoding to UTF-8, sets the additional headers, then returns the OutputStream.
 java.lang.Object getJavaScriptSrc(WebSiteRequest req)
          Gets the JavaScript's that should have script src= tags generated, urls relative to top of context path/to/javascript.js.
 java.lang.String getKeywords()
          Gets the keywords for this page.
 long getLastModified(WebSiteRequest req)
          The getLastModified defaults to -1.
static long getLastModifiedRecursive(java.io.File file)
          Recursively gets the most recent modification time of a file or directory.
 long getLastModifiedRecursive(WebSiteRequest req)
          Recursively gets the most recent modification time.
 java.lang.String getNavImageAlt(WebSiteRequest req)
          Gets the text for the navigation image to use to represent this page.
 java.lang.String getNavImageSuffix(WebSiteRequest req)
          Gets the text that will be placed in to the right of the navigation image.
 java.lang.String getNavImageURL(WebSiteRequest req, javax.servlet.http.HttpServletResponse resp, java.lang.Object params)
          Gets the URL associated with a nav image.
 WebPage getNextPage(WebSiteRequest req)
          Gets the WebPage that follows this one in the parents list of pages.
 java.lang.String getOnloadScript(WebSiteRequest req)
          Gets the JavaScript that should be executed with the onload event of the body tag
 int getPageIndexInParent(WebSiteRequest req)
          Gets the index of this page in the parents list of children pages.
abstract  WebPage getParent()
          Gets the parent of this page or null for none.
 int getPreferredContentWidth(WebSiteRequest req)
          Gets the preferred width of this content in pixels or -1 for no preference.
 WebPage getPreviousPage(WebSiteRequest req)
          Gets the WebPage that proceeds this one in the parents list of pages.
 java.lang.String getRedirectURL(WebSiteRequest req)
          Gets the URL to direct to.
 WebPage getRootPage()
          Gets the root page in the web page hierarchy.
 long getSearchLastModified()
          Gets the last modified time for search indexing.
 javax.servlet.ServletContext getServletContext()
           
 java.lang.String getShortTitle()
          A short title is used showing a path to the current location in the site.
 java.lang.String getTitle()
          Gets the title of the web page in order to generate the HTML.
 java.lang.Object getURLParams(WebSiteRequest req)
          Gets parameters that are added to the query string of URLs generated for this page.
 java.lang.String getURLPath()
          Gets the path of for the URL relative to the top of the site.
 java.lang.String getURLPattern()
          Gets the URL pattern for this page as used in web.xml.
 WebPage getWebPage(java.lang.Class<? extends WebPage> clazz, java.lang.Object param)
           
 WebPage getWebPage(java.lang.Class<? extends WebPage> clazz, WebSiteRequest req)
           
static WebPage getWebPage(javax.servlet.ServletContext context, java.lang.Class<? extends WebPage> clazz, java.lang.Object params)
          Gets an instance of WebPage given the Class.
static WebPage getWebPage(javax.servlet.ServletContext context, java.lang.Class<? extends WebPage> clazz, WebSiteRequest req)
          Gets an instance of WebPage given the Class.
 long getWebPageAndChildrenLastModified(WebSiteRequest req)
          Gets the most recent last modified time of this page and its immediate children.
 WebPageLayout getWebPageLayout(WebSiteRequest req)
          Gets the current layout for this page.
protected  WebPage[] getWebPages(WebSiteRequest req)
          Gets all of the children pages of this one in the page hierarchy.
protected abstract  WebSiteRequest getWebSiteRequest(javax.servlet.http.HttpServletRequest req)
          Gets the WebSiteRequest that handles authentication and other details of this site.
 int hashCode()
          The default hashcode for a page is the hashcode of its classname.
 boolean includeNavImageAsParent()
          Determine if the nav image for this page should remain visible, even when its children are displayed.
 boolean isHandler(java.lang.Object O)
          Determines if this page is the instance that represents a certain set of parameters.
 boolean isHandler(WebSiteRequest req)
          Determines if this page is the instance that should handle a particular request.
static java.lang.Class<? extends WebPage> loadClass(java.lang.String className)
          Dynamically loads new classes based on the source .class file's modified time.
 void printLoginForm(WebPage page, com.aoindustries.security.LoginException loginException, WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          Prints the form that is used to login.
 void printUnauthorizedPage(WebPage page, WebSiteRequest req, javax.servlet.http.HttpServletResponse resp)
          Prints the unauthorized page message.
protected  void reportingDoGet(javax.servlet.http.HttpServletRequest httpReq, javax.servlet.http.HttpServletResponse resp)
          First, resolves correct instance of WebPage.
protected  void reportingDoPost(javax.servlet.http.HttpServletRequest httpReq, javax.servlet.http.HttpServletResponse resp)
          First, resolves correct instance of WebPage.
 long reportingGetLastModified(javax.servlet.http.HttpServletRequest httpReq)
          First, resolves correct instance of WebPage.
 void search(java.lang.String[] words, WebSiteRequest req, javax.servlet.http.HttpServletResponse response, java.util.List<SearchResult> results, com.aoindustries.io.BetterByteArrayOutputStream bytes, java.util.List<WebPage> finishedPages)
          Searches this WebPage and all of its subordinate pages, returning the matches in a ArrayList with five elements per match.
 boolean showInLocationPath(WebSiteRequest req)
          Determines if this page will be displayed in the location bar.
 void standardSearch(java.lang.String[] words, WebSiteRequest req, javax.servlet.http.HttpServletResponse response, java.util.List<SearchResult> results, com.aoindustries.io.BetterByteArrayOutputStream bytes, java.util.List<WebPage> finishedPages)
          The standard implementation of the search functionality.
 boolean useEncryption()
          Determines if this page should be sent encrypted.
 boolean useNavImage()
          Determines whether or not to display the page in the left navigation.
 boolean useSiteMap()
          Determines if this page will be displayed in the standard site map.
 
Methods inherited from class com.aoindustries.website.framework.ErrorReportingServlet
doGet, doPost, getGetCount, getLastModified, getLastModifiedCount, getLogger, getLogger, getLogger, getLoggerAccessor, getPostCount, getUptime, log, log
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, getServletName, init, init
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emptyWebPageArray

protected static final WebPage[] emptyWebPageArray
An empty array of WebPage objects to be used in returning no web pages.


reHTMLPattern

public static gnu.regexp.RE reHTMLPattern
Constructor Detail

WebPage

public WebPage(LoggerAccessor loggerAccessor)

WebPage

public WebPage(WebSiteRequest req)

WebPage

public WebPage(LoggerAccessor loggerAccessor,
               java.lang.Object param)
Method Detail

canAccess

public boolean canAccess(WebSiteUser user)
                  throws java.io.IOException,
                         java.sql.SQLException
Determines if the provided user can access the page. Defaults to inheriting the behavior of the parent page.

Throws:
java.io.IOException
java.sql.SQLException

printLoginForm

public void printLoginForm(WebPage page,
                           com.aoindustries.security.LoginException loginException,
                           WebSiteRequest req,
                           javax.servlet.http.HttpServletResponse resp)
                    throws java.io.IOException,
                           java.sql.SQLException
Prints the form that is used to login.

Throws:
java.io.IOException
java.sql.SQLException

printUnauthorizedPage

public void printUnauthorizedPage(WebPage page,
                                  WebSiteRequest req,
                                  javax.servlet.http.HttpServletResponse resp)
                           throws javax.servlet.ServletException,
                                  java.io.IOException,
                                  java.sql.SQLException
Prints the unauthorized page message.

Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException

reportingGetLastModified

public final long reportingGetLastModified(javax.servlet.http.HttpServletRequest httpReq)
                                    throws java.io.IOException,
                                           java.sql.SQLException
First, resolves correct instance of WebPage. Then, if security mode mismatches, authentication failed, or the page is a redirect, returns -1 for unknown. Otherwise, call getLastModified(WebSiteRequest)

Overrides:
reportingGetLastModified in class ErrorReportingServlet
Throws:
java.io.IOException
java.sql.SQLException
See Also:
getLastModified(WebSiteRequest)

getLastModified

public long getLastModified(WebSiteRequest req)
                     throws java.io.IOException,
                            java.sql.SQLException
The getLastModified defaults to -1.

Throws:
java.io.IOException
java.sql.SQLException

getClassLastModified

protected final long getClassLastModified()
                                   throws java.io.IOException,
                                          java.sql.SQLException
Gets the last modified time of the java class file. If the class file is unavailable, it defaults to the time the servlets were loaded.

Throws:
java.io.IOException
java.sql.SQLException
See Also:
WebSiteFrameworkConfiguration.getServletDirectory(), ErrorReportingServlet.getUptime()

getWebPageAndChildrenLastModified

public long getWebPageAndChildrenLastModified(WebSiteRequest req)
                                       throws java.io.IOException,
                                              java.sql.SQLException
Gets the most recent last modified time of this page and its immediate children.

Throws:
java.io.IOException
java.sql.SQLException

getLastModifiedRecursive

public final long getLastModifiedRecursive(WebSiteRequest req)
                                    throws java.io.IOException,
                                           java.sql.SQLException
Recursively gets the most recent modification time.

Throws:
java.io.IOException
java.sql.SQLException

getLastModifiedRecursive

public static long getLastModifiedRecursive(java.io.File file)
Recursively gets the most recent modification time of a file or directory.


getSearchLastModified

public long getSearchLastModified()
                           throws java.io.IOException,
                                  java.sql.SQLException
Gets the last modified time for search indexing. The index will be recreated if the search last modified time is changed. If this method returns -1, no search index is built. This defaults to be a call to getLastModified with a null WebSiteRequest.

Throws:
java.io.IOException
java.sql.SQLException

reportingDoGet

protected final void reportingDoGet(javax.servlet.http.HttpServletRequest httpReq,
                                    javax.servlet.http.HttpServletResponse resp)
                             throws javax.servlet.ServletException,
                                    java.io.IOException,
                                    java.sql.SQLException
First, resolves correct instance of WebPage. Next, handles security mode, authentication check, and redirects. Anything left goes on to doGet.

Overrides:
reportingDoGet in class ErrorReportingServlet
Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
doGet(WebSiteRequest,HttpServletResponse)

doGet

protected void doGet(WebSiteRequest req,
                     javax.servlet.http.HttpServletResponse resp)
              throws javax.servlet.ServletException,
                     java.io.IOException,
                     java.sql.SQLException
The layout is automatically applied to the page, then doGet is called. To not have this automatically applied, override this method. By the time this method is called, security checks, authentication, and redirects have been done.

The first thing this method does is print the frameset if needed. Second, it uses the output cache to quickly print the output if possible. And third, it will call doGet(ChainWriter,WebSiteRequest,HttpServletResponse) with a stream directly out if the first two actions were not taken.

Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
doGet(ChainWriter,WebSiteRequest,HttpServletResponse)

doGet

public void doGet(com.aoindustries.io.ChainWriter out,
                  WebSiteRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  java.io.IOException,
                  java.sql.SQLException
By default, GET provides no content.

Parameters:
out - the ChainWriter to send output to
req - the current WebSiteRequest
resp - the HttpServletResponse for this request, is null when searching
Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException

reportingDoPost

protected final void reportingDoPost(javax.servlet.http.HttpServletRequest httpReq,
                                     javax.servlet.http.HttpServletResponse resp)
                              throws javax.servlet.ServletException,
                                     java.io.IOException,
                                     java.sql.SQLException
First, resolves correct instance of WebPage. Then, handles security mode, authentication check, and redirects. Anything left goes on to doPostWithSearch.

Overrides:
reportingDoPost in class ErrorReportingServlet
Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
doPostWithSearch(WebSiteRequest,HttpServletResponse)

doPostWithSearch

protected void doPostWithSearch(WebSiteRequest req,
                                javax.servlet.http.HttpServletResponse resp)
                         throws javax.servlet.ServletException,
                                java.io.IOException,
                                java.sql.SQLException
Handles any search posts, sends everything else on to doPost(WebSiteRequest,HttpServletResponse). The search assumes the search parameters of search_query and search_target. Both these values must be present for a search to be performed. Search target may be either "this_area" or "entire_site", defaulting to "area" for any other value.

Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
doPost(WebSiteRequest,HttpServletResponse)

doPost

protected void doPost(WebSiteRequest req,
                      javax.servlet.http.HttpServletResponse resp)
               throws javax.servlet.ServletException,
                      java.io.IOException,
                      java.sql.SQLException
By default, a post request is just sets up the content beginning and calls doPost

Parameters:
req - the current WebSiteRequest
resp - the HttpServletResponse for this request
Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
doPost(ChainWriter,WebSiteRequest,HttpServletResponse)

doPost

protected void doPost(com.aoindustries.io.ChainWriter out,
                      WebSiteRequest req,
                      javax.servlet.http.HttpServletResponse resp)
               throws javax.servlet.ServletException,
                      java.io.IOException,
                      java.sql.SQLException
By default, a post request just calls doGet

Parameters:
out - the ChainWriter to write to
req - the current WebSiteRequest
resp - the HttpServletResponse for this request
Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
doGet(ChainWriter,WebSiteRequest,HttpServletResponse)

enforceEncryption

public boolean enforceEncryption()
                          throws java.io.IOException,
                                 java.sql.SQLException
Gets whether this page should enforce the current encrpyption requirement or not.

Throws:
java.io.IOException
java.sql.SQLException

equals

public final boolean equals(java.lang.Object O)
Determines if this page equals another page.

Overrides:
equals in class java.lang.Object
See Also:
equals(WebPage)

equals

public boolean equals(WebPage other)
Determines if this page equals another page. By default, two pages of the same classname are considered equal.

See Also:
hashCode()

hashCode

public int hashCode()
The default hashcode for a page is the hashcode of its classname.

Overrides:
hashCode in class java.lang.Object
See Also:
equals(WebPage)

getAdditionalHeaders

public java.lang.String[] getAdditionalHeaders(WebSiteRequest req)
Gets additional headers for this page. The format must be in a String[] of name/value pairs, two elements each, name and then value.


getAuthor

public java.lang.String getAuthor()
                           throws java.io.IOException,
                                  java.sql.SQLException
Gets the author of this page. By default, the author of the parent page is used.

Throws:
java.io.IOException
java.sql.SQLException

getPreferredContentWidth

public int getPreferredContentWidth(WebSiteRequest req)
                             throws java.io.IOException,
                                    java.sql.SQLException
Gets the preferred width of this content in pixels or -1 for no preference. It is up to the WebPageLayout to make use of this value. The preferred width defaults to the preferred width of the parent page.

Throws:
java.io.IOException
java.sql.SQLException
See Also:
WebPageLayout

getContentVAlign

public java.lang.String getContentVAlign(WebSiteRequest req)
Gets the vertical alignment of the content area. Defaults to "top". It is up to the WebPageLayout to make use of this value.

See Also:
WebPageLayout

getDescription

public java.lang.String getDescription()
                                throws java.io.IOException,
                                       java.sql.SQLException
Gets the description of this page. By default, the description of the parent page is used.

Throws:
java.io.IOException
java.sql.SQLException

getRootPage

public final WebPage getRootPage()
                          throws java.io.IOException,
                                 java.sql.SQLException
Gets the root page in the web page hierarchy. The root page has no parent.

Throws:
java.io.IOException
java.sql.SQLException

getHTMLChainWriter

protected final com.aoindustries.io.ChainWriter getHTMLChainWriter(WebSiteRequest req,
                                                                   javax.servlet.http.HttpServletResponse resp)
                                                            throws java.io.IOException
Sets the content type, encoding to UTF-8, sets the additional headers, then returns the ChainWriter.

Throws:
java.io.IOException
See Also:
getAdditionalHeaders(com.aoindustries.website.framework.WebSiteRequest)

getHTMLOutputStream

protected final java.io.OutputStream getHTMLOutputStream(WebSiteRequest req,
                                                         javax.servlet.http.HttpServletResponse resp)
                                                  throws java.io.IOException
Sets the content type, encoding to UTF-8, sets the additional headers, then returns the OutputStream.

Throws:
java.io.IOException
See Also:
getAdditionalHeaders(com.aoindustries.website.framework.WebSiteRequest)

getJavaScriptSrc

public java.lang.Object getJavaScriptSrc(WebSiteRequest req)
                                  throws java.io.IOException,
                                         java.sql.SQLException
Gets the JavaScript's that should have script src= tags generated, urls relative to top of context path/to/javascript.js.

Parameters:
req - the current WebSiteRequest
Returns:
a String[] for multiple includes, a String for one, or null for none
Throws:
java.io.IOException
java.sql.SQLException

getKeywords

public java.lang.String getKeywords()
                             throws java.io.IOException,
                                    java.sql.SQLException
Gets the keywords for this page. By default, the keywords of the parent page are used.

Throws:
java.io.IOException
java.sql.SQLException

getNavImageAlt

public java.lang.String getNavImageAlt(WebSiteRequest req)
                                throws java.io.IOException,
                                       java.sql.SQLException
Gets the text for the navigation image to use to represent this page. Defaults to getShortTitle.

Returns:
the alt text of the navigation image
Throws:
java.io.IOException
java.sql.SQLException
See Also:
getShortTitle(), getNavImageSuffix(com.aoindustries.website.framework.WebSiteRequest), getNavImageURL(com.aoindustries.website.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, java.lang.Object)

getNavImageSuffix

public java.lang.String getNavImageSuffix(WebSiteRequest req)
                                   throws java.io.IOException,
                                          java.sql.SQLException
Gets the text that will be placed in to the right of the navigation image. If the image is not large enough to hold both getNavImageAlt and getNavImageSuffix, the beginning is truncated and ... appended so that both fit the image.

Throws:
java.io.IOException
java.sql.SQLException
See Also:
getNavImageAlt(com.aoindustries.website.framework.WebSiteRequest), getNavImageURL(com.aoindustries.website.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, java.lang.Object)

getNavImageURL

public java.lang.String getNavImageURL(WebSiteRequest req,
                                       javax.servlet.http.HttpServletResponse resp,
                                       java.lang.Object params)
                                throws java.io.IOException,
                                       java.sql.SQLException
Gets the URL associated with a nav image. This should be fully encoded for direct output into an XML attribute. This means URL encoded and &amp; separators instead of only & If this is a javascript: link, then should be escaped via EncodingUtils.encodeJavaScriptStringInXml.

Throws:
java.io.IOException
java.sql.SQLException
See Also:
getNavImageAlt(com.aoindustries.website.framework.WebSiteRequest), getNavImageSuffix(com.aoindustries.website.framework.WebSiteRequest), ChainWriter#encodeJavaScriptStringInXml(String,Writer)

getPageIndexInParent

public final int getPageIndexInParent(WebSiteRequest req)
                               throws java.io.IOException,
                                      java.sql.SQLException
Gets the index of this page in the parents list of children pages.

Throws:
java.io.IOException
java.sql.SQLException

getNextPage

public final WebPage getNextPage(WebSiteRequest req)
                          throws java.io.IOException,
                                 java.sql.SQLException
Gets the WebPage that follows this one in the parents list of pages.

Returns:
the WebPage or null if not found
Throws:
java.io.IOException
java.sql.SQLException

getPreviousPage

public final WebPage getPreviousPage(WebSiteRequest req)
                              throws java.io.IOException,
                                     java.sql.SQLException
Gets the WebPage that proceeds this one in the parents list of pages.

Returns:
the WebPage or null if not found
Throws:
java.io.IOException
java.sql.SQLException

getOnloadScript

public java.lang.String getOnloadScript(WebSiteRequest req)
Gets the JavaScript that should be executed with the onload event of the body tag

Parameters:
req - the current WebSiteRequest
Returns:
a String or null for none

getCachedPages

public WebPage[] getCachedPages(WebSiteRequest req)
                         throws java.io.IOException,
                                java.sql.SQLException
Gets all of the pages that are children of this one in the page hierarchy. Unless overridden, the pages are cached in a WebPage[] for faster access. The actual list of pages is obtained from getWebPages.

Pages will also not be cached if the configuration property is set to anything other than "true"

Returns:
a WebPage[] of all of the lower-level pages
Throws:
java.io.IOException
java.sql.SQLException
See Also:
WebSiteFrameworkConfiguration.useWebSiteCaching(), getWebPages(WebSiteRequest)

getParent

public abstract WebPage getParent()
                           throws java.io.IOException,
                                  java.sql.SQLException
Gets the parent of this page or null for none.

Throws:
java.io.IOException
java.sql.SQLException

getRedirectURL

public java.lang.String getRedirectURL(WebSiteRequest req)
                                throws java.io.IOException,
                                       java.sql.SQLException
Gets the URL to direct to. Redirection happens before specific frameset actions, thus allowing one to redirect various frames to different places.

Returns:
the relative or absolute URL to redirect to or null for no redirect.
Throws:
java.io.IOException
java.sql.SQLException

getShortTitle

public java.lang.String getShortTitle()
                               throws java.io.IOException,
                                      java.sql.SQLException
A short title is used showing a path to the current location in the site. The short title defaults to getTitle.

Returns:
the short page title
Throws:
java.io.IOException
java.sql.SQLException
See Also:
getTitle()

getTitle

public java.lang.String getTitle()
                          throws java.io.IOException,
                                 java.sql.SQLException
Gets the title of the web page in order to generate the HTML. The title defaults to that of the parent page.

Returns:
the page title
Throws:
java.io.IOException
java.sql.SQLException

getURLParams

public java.lang.Object getURLParams(WebSiteRequest req)
                              throws java.io.IOException,
                                     java.sql.SQLException
Gets parameters that are added to the query string of URLs generated for this page.

Throws:
java.io.IOException
java.sql.SQLException

getWebPage

public WebPage getWebPage(java.lang.Class<? extends WebPage> clazz,
                          WebSiteRequest req)
                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
getWebPage(ServletContext,Class,WebSiteRequest)

getWebPage

public static WebPage getWebPage(javax.servlet.ServletContext context,
                                 java.lang.Class<? extends WebPage> clazz,
                                 WebSiteRequest req)
                          throws java.io.IOException
Gets an instance of WebPage given the Class. Instances returned should never have the init method called and should allocate a minimal set of resources.

Unless caching is disabled, the generated pages are stored in a cache and resolved using the pages isHandler method.

Parameters:
context - the context the servlet will be run in
clazz - the Class to get an instance of
req - the request details are used to select the right instance
Returns:
a WebPage object of the given class that matches the request settings
Throws:
java.lang.IllegalArgumentException - if unable to create the instance
java.io.IOException
See Also:
WebSiteFrameworkConfiguration.useWebSiteCaching(), isHandler(WebSiteRequest)

getWebPage

public WebPage getWebPage(java.lang.Class<? extends WebPage> clazz,
                          java.lang.Object param)
                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
getWebPage(ServletContext,Class,Object)

getWebPage

public static WebPage getWebPage(javax.servlet.ServletContext context,
                                 java.lang.Class<? extends WebPage> clazz,
                                 java.lang.Object params)
                          throws java.io.IOException
Gets an instance of WebPage given the Class. Instances returned should never have the init method called and should allocate a minimal set of resources.

Unless caching is disabled, the generated pages are stored in a cache and resolved using the pages isHander method.

Parameters:
context - the context the servlet will be run in
clazz - the Class to get an instance of
params - the parameters used to select the right instance
Returns:
a WebPage object of the given class that matches the request settings
Throws:
java.lang.IllegalArgumentException - if unable to create the instance
java.io.IOException
See Also:
WebSiteFrameworkConfiguration.useWebSiteCaching(), isHandler(Object)

getClassLoaderUptime

public static long getClassLoaderUptime()
Gets the time that the classloader was instantiated. This will indicate the modified time of classes that are dynamically loaded.


loadClass

public static java.lang.Class<? extends WebPage> loadClass(java.lang.String className)
                                                    throws java.lang.ClassNotFoundException
Dynamically loads new classes based on the source .class file's modified time.

Throws:
java.lang.ClassNotFoundException

getWebPageLayout

public WebPageLayout getWebPageLayout(WebSiteRequest req)
                               throws java.io.IOException,
                                      java.sql.SQLException
Gets the current layout for this page. By default, takes the layout of the parent page.

Returns:
the WebPageLayout
Throws:
java.io.IOException
java.sql.SQLException

getWebPages

protected WebPage[] getWebPages(WebSiteRequest req)
                         throws java.io.IOException,
                                java.sql.SQLException
Gets all of the children pages of this one in the page hierarchy. Defaults to none. The results of this call are never cached. For efficiency, please call getCachedWebPages. Subclasses will override and disable the caching provided by getCachedWebPages when appropriate.

Returns:
a WebPage[] of all of the lower-level pages
Throws:
java.io.IOException
java.sql.SQLException
See Also:
getCachedPages(com.aoindustries.website.framework.WebSiteRequest), emptyWebPageArray

isHandler

public boolean isHandler(WebSiteRequest req)
Determines if this page is the instance that should handle a particular request. By default returns true, meaning it is a handler for all requests for this Class.

See Also:
getWebPage(ServletContext,Class,WebSiteRequest)

isHandler

public boolean isHandler(java.lang.Object O)
Determines if this page is the instance that represents a certain set of parameters. By default returns true, meaning it is a handler for any parameters for this Class.

See Also:
getWebPage(ServletContext,Class,Object)

getWebSiteRequest

protected abstract WebSiteRequest getWebSiteRequest(javax.servlet.http.HttpServletRequest req)
                                             throws java.io.IOException,
                                                    java.sql.SQLException
Gets the WebSiteRequest that handles authentication and other details of this site.

Throws:
java.io.IOException
java.sql.SQLException

search

public void search(java.lang.String[] words,
                   WebSiteRequest req,
                   javax.servlet.http.HttpServletResponse response,
                   java.util.List<SearchResult> results,
                   com.aoindustries.io.BetterByteArrayOutputStream bytes,
                   java.util.List<WebPage> finishedPages)
            throws javax.servlet.ServletException,
                   java.io.IOException,
                   java.sql.SQLException
Searches this WebPage and all of its subordinate pages, returning the matches in a ArrayList with five elements per match.
  1. A String for the absolute URL (including settings)
  2. The probability as a Float
  3. The title of the page
  4. The description of the page
  5. The author of the page
Defaults to standardSearch

Parameters:
words - all of the words that must match
req - the WebSiteRequest containing the users preferences
results - the ArrayList that contains the results
bytes - the SearchOutputStream to use for internal processing
Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
standardSearch(java.lang.String[], com.aoindustries.website.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, java.util.List, com.aoindustries.io.BetterByteArrayOutputStream, java.util.List)

standardSearch

public final void standardSearch(java.lang.String[] words,
                                 WebSiteRequest req,
                                 javax.servlet.http.HttpServletResponse response,
                                 java.util.List<SearchResult> results,
                                 com.aoindustries.io.BetterByteArrayOutputStream bytes,
                                 java.util.List<WebPage> finishedPages)
                          throws javax.servlet.ServletException,
                                 java.io.IOException,
                                 java.sql.SQLException
The standard implementation of the search functionality.

Throws:
javax.servlet.ServletException
java.io.IOException
java.sql.SQLException
See Also:
search(java.lang.String[], com.aoindustries.website.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, java.util.List, com.aoindustries.io.BetterByteArrayOutputStream, java.util.List)

useEncryption

public boolean useEncryption()
                      throws java.io.IOException,
                             java.sql.SQLException
Determines if this page should be sent encrypted. By default, the encryption mode of the parent page is used.

Throws:
java.io.IOException
java.sql.SQLException

includeNavImageAsParent

public boolean includeNavImageAsParent()
Determine if the nav image for this page should remain visible, even when its children are displayed. The default is false.


useNavImage

public boolean useNavImage()
                    throws java.io.IOException,
                           java.sql.SQLException
Determines whether or not to display the page in the left navigation.

Throws:
java.io.IOException
java.sql.SQLException

useSiteMap

public boolean useSiteMap()
Determines if this page will be displayed in the standard site map.


showInLocationPath

public boolean showInLocationPath(WebSiteRequest req)
Determines if this page will be displayed in the location bar.


getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface javax.servlet.ServletConfig
Overrides:
getServletContext in class javax.servlet.GenericServlet

getCopyright

public java.lang.String getCopyright(WebSiteRequest req,
                                     WebPage requestPage)
                              throws java.io.IOException,
                                     java.sql.SQLException
Gets the copyright information for this page. Defaults to the copyright of the parent page.

Throws:
java.io.IOException
java.sql.SQLException

getURLPath

public java.lang.String getURLPath()
                            throws java.io.IOException,
                                   java.sql.SQLException
Gets the path of for the URL relative to the top of the site.

Throws:
java.io.IOException
java.sql.SQLException

generateURLPath

public java.lang.String generateURLPath(WebPage page)
                                 throws java.io.IOException,
                                        java.sql.SQLException
Generates a URL path for this or another page, please call getURLPath() instead. The default behavior is to ask the parent to generate the URL. Therefore the top-level WebPage of a site must implement this method.

Throws:
java.io.IOException
java.sql.SQLException

getURLPattern

public java.lang.String getURLPattern()
                               throws java.io.IOException,
                                      java.sql.SQLException
Gets the URL pattern for this page as used in web.xml.

Throws:
java.io.IOException
java.sql.SQLException