- All Implemented Interfaces:
Serializable
,Servlet
,ServletConfig
- Direct Known Subclasses:
AutoListPage
,DumpURLs
,FilePage
,InputStreamPage
,RedirectWebPage
,TreePage
doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
, or
getLastModified(javax.servlet.http.HttpServletRequest)
methods.- Author:
- AO Industries, Inc.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canAccess
(WebSiteUser user) Determines if the provided user can access the page.void
configureResources
(ServletContext servletContext, WebSiteRequest req, HttpServletResponse resp, WebPageLayout layout, Registry pageRegistry) Configures the page-scope web resources that this page uses.void
doGet
(WebSiteRequest req, HttpServletResponse resp) Prepares the request then invokesdoGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE)
.void
doGet
(WebSiteRequest req, HttpServletResponse resp, DocumentEE document) The layout is automatically applied to the page, thendoGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.web.framework.WebPageLayout, com.aoapps.html.servlet.FlowContent)
is called.<__ extends FlowContent<__>>
voiddoGet
(WebSiteRequest req, HttpServletResponse resp, WebPageLayout layout, __ flow) By default, GET provides no content.protected final void
doGet
(HttpServletRequest httpReq, HttpServletResponse resp) The main entry point forGET
requests.void
doPost
(WebSiteRequest req, HttpServletResponse resp) Prepares the request then invokesdoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE)
.void
doPost
(WebSiteRequest req, HttpServletResponse resp, DocumentEE document) The layout is automatically applied to the page, thendoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.web.framework.WebPageLayout, com.aoapps.html.servlet.FlowContent)
is called.<__ extends FlowContent<__>>
voiddoPost
(WebSiteRequest req, HttpServletResponse resp, WebPageLayout layout, __ flow) protected final void
doPost
(HttpServletRequest httpReq, HttpServletResponse resp) The main entry point forGET
requests.protected void
doPostWithSearch
(WebSiteRequest req, HttpServletResponse resp) Handles any search posts, sends everything else on todoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
.boolean
Determines if this page equals another page.final boolean
Determines if this page equals another page.generateUrlPath
(WebPage page) Generates a URL path for this or another page, please call getUrlPath() instead.getAuthor
(WebSiteRequest req) Gets the author of this page.getAuthorHref
(WebSiteRequest req, HttpServletResponse resp) Gets the URL for the author of this page.protected boolean
getAutonli
(WebSiteRequest req) Gets the automatic newline and indentation setting to use for this page.WebPage[]
getCachedChildren
(WebSiteRequest req, HttpServletResponse resp) Gets all of the pages that are children of this one in the page hierarchy.protected WebPage[]
getChildren
(WebSiteRequest req, HttpServletResponse resp) Gets all of the children pages of this one in the page hierarchy.protected final long
Gets the last modified time of the java class file.Gets the vertical alignment of the content area.getCopyright
(WebSiteRequest req, HttpServletResponse resp, WebPage requestPage) Gets the copyright information for this page.Gets the description of this page.protected Doctype
getDoctype
(WebSiteRequest req) Gets theDoctype
to use for this page.protected DocumentEE
getDocument
(WebSiteRequest req, HttpServletResponse resp) Prepares for output and returns theDocumentEE
.protected OutputStream
getHtmlOutputStream
(WebSiteRequest req, HttpServletResponse resp) Prepares for output and returns theOutputStream
.protected boolean
getIndent
(WebSiteRequest req) Gets the indentation setting to use for this page.Gets the JavaScript's that should have script src= tags generated, urls relative to top of contextpath/to/javascript.js
.Gets the keywords for this page.long
getLastModified
(WebSiteRequest req, HttpServletResponse resp) ThegetLastModified
defaults to-1
.protected final long
getLastModified
(HttpServletRequest httpReq) The main entry point forgetLastModified()
requests.final long
Recursively gets the most recent modification time.static long
getLastModifiedRecursive
(File file) Recursively gets the most recent modification time of a file or directory.Gets the text for the navigation image to use to represent this page.Gets the text that will be placed in to the right of the navigation image.getNavImageUrl
(WebSiteRequest req, HttpServletResponse resp, URIParameters params) Gets the URL associated with a nav image, fully encoded.final WebPage
getNextPage
(WebSiteRequest req, HttpServletResponse resp) Gets theWebPage
that follows this one in the parents list of pages.Gets the JavaScript that should be executed with the onload event of the body tag.final int
Gets the index of this page in the parents list of children pages.abstract WebPage
Gets the parent of this page ornull
for none.Gets the preferred width of this content ornull
for no preference.final WebPage
getPreviousPage
(WebSiteRequest req, HttpServletResponse resp) Gets theWebPage
that proceeds this one in the parents list of pages.int
Gets the redirect type, defaults to 302 (temporary).Gets the absolute or context-relative URL to direct to.final WebPage
Gets the root page in the web page hierarchy.long
Gets the last modified time for search indexing.protected Serialization
Gets theSerialization
to use for this page.A short title is used showing a path to the current location in the site.getTitle
(WebSiteRequest req) Gets the title of the web page in order to generate the HTML.static long
Gets the time the servlet environment was loaded.Gets parameters that are added to the query string of URLs generated for this page.Gets the context-relative path for the URL.Gets the URL pattern for this page as used inweb.xml
.getWebPage
(Class<? extends WebPage> clazz) Gets a web page given no parameters.getWebPage
(Class<? extends WebPage> clazz, URIParameters params) Gets a web page with parameters.getWebPage
(Class<? extends WebPage> clazz, WebSiteRequest req) Gets a web page given no parameters.static WebPage
getWebPage
(ServletContext context, Class<? extends WebPage> clazz) Gets an instance ofWebPage
given theClass
.static WebPage
getWebPage
(ServletContext context, Class<? extends WebPage> clazz, URIParameters params) Gets an instance ofWebPage
given theClass
.static WebPage
getWebPage
(ServletContext context, Class<? extends WebPage> clazz, WebSiteRequest req) Gets an instance ofWebPage
given theClass
.long
Gets the most recent last modified time of this page and its immediate children.Gets the current layout for this page.protected abstract WebSiteRequest
Gets theWebSiteRequest
that handles authentication and other details of this site.int
hashCode()
The default hashcode for a page is the hashcode of its classname.boolean
Determine if the nav image for this page should remain visible, even when its children are displayed.boolean
isHandler
(URIParameters params) 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.Dynamically loads new classes based on the source .class file's modified time.void
printLoginForm
(WebPage page, LoginException loginException, WebSiteRequest req, HttpServletResponse resp) Prints the form that is used to login.void
printUnauthorizedPage
(WebPage page, WebSiteRequest req, HttpServletResponse resp) Prints the unauthorized page message.void
search
(String[] words, WebSiteRequest req, HttpServletResponse response, List<SearchResult> results, CharArrayWriter buffer, Set<WebPage> finishedPages) Searches this WebPage and all of its subordinate pages, returning the matches in aArrayList
with five elements per match.protected void
service
(HttpServletRequest req, HttpServletResponse resp) Stores the current response in a request attribute namedRESPONSE_REQUEST_ATTRIBUTE
.void
setHeaders
(WebSiteRequest req, HttpServletResponse resp) Sets headers for this page.boolean
Determines if this page will be displayed in the location bar.final void
standardSearch
(String[] words, WebSiteRequest req, HttpServletResponse resp, List<SearchResult> results, CharArrayWriter buffer, Set<WebPage> finishedPages) The standard implementation of the search functionality.boolean
Determines whether or not to display the page in the left navigation.boolean
Determines if this page will be displayed in the standard site map.Methods inherited from class com.aoapps.web.resources.servlet.PageServlet
service
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, getServletName, init, init, log, log
-
Field Details
-
SEARCH_TWO
The name of the search form during per-page searches.- See Also:
-
emptyWebPageArray
An empty array ofWebPage
objects to be used in returning no web pages. -
reHTMLPattern
-
-
Constructor Details
-
WebPage
public WebPage()
-
-
Method Details
-
getUptime
public static long getUptime()Gets the time the servlet environment was loaded. -
configureResources
public void configureResources(ServletContext servletContext, WebSiteRequest req, HttpServletResponse resp, WebPageLayout layout, Registry pageRegistry) Configures the page-scope web resources that this page uses.Implementers should call
super.configureResources(…)
as a matter of convention, despite this default implementation doing nothing. -
canAccess
Determines if the provided user can access the page. Defaults to inheriting the behavior of the parent page.- Throws:
ServletException
-
printLoginForm
public void printLoginForm(WebPage page, LoginException loginException, WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Prints the form that is used to login.- Throws:
ServletException
IOException
-
printUnauthorizedPage
public void printUnauthorizedPage(WebPage page, WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Prints the unauthorized page message.- Throws:
ServletException
IOException
-
getLastModified
The main entry point forgetLastModified()
requests. Prepares the request and performs initial actions:- Wraps the request in
WebSiteRequest
viagetWebSiteRequest(javax.servlet.http.HttpServletRequest)
. - Resolves the current instance of
WebPage
viagetWebPage(java.lang.Class, com.aoapps.web.framework.WebSiteRequest)
. - Handles any login request (parameter
WebSiteRequest.LOGIN_REQUESTED
="true") by returning-1
for unknown. - Resolves the current
WebSiteUser
viaWebSiteRequest.getWebSiteUser(javax.servlet.http.HttpServletResponse)
(if any). When login required and failed, returns-1
for unknown. - Ensures the user can access the page,
returns
-1
for unknown when not authorized. - If is a redirect,
returns
-1
for unknown. - Finally, dispatches the request to
getLastModified(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
.
- Overrides:
getLastModified
in classHttpServlet
- See Also:
- Wraps the request in
-
getLastModified
ThegetLastModified
defaults to-1
.- Throws:
ServletException
-
getClassLastModified
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:
ServletException
- See Also:
-
getWebPageAndChildrenLastModified
public long getWebPageAndChildrenLastModified(WebSiteRequest req, HttpServletResponse resp) throws ServletException Gets the most recent last modified time of this page and its immediate children.- Throws:
ServletException
-
getLastModifiedRecursive
public final long getLastModifiedRecursive(WebSiteRequest req, HttpServletResponse resp) throws ServletException Recursively gets the most recent modification time.- Throws:
ServletException
-
getLastModifiedRecursive
Recursively gets the most recent modification time of a file or directory. -
getSearchLastModified
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 togetLastModified
with nullWebSiteRequest
andHttpServletResponse
.- Throws:
ServletException
-
getSerialization
Gets theSerialization
to use for this page.- Parameters:
req
-null
during search- See Also:
-
getDoctype
Gets theDoctype
to use for this page.- Parameters:
req
-null
during search- See Also:
-
getAutonli
Gets the automatic newline and indentation setting to use for this page. Defaults toDocumentEE.getAutonli(javax.servlet.ServletContext, javax.servlet.ServletRequest)
.- Parameters:
req
-null
during search- See Also:
-
getIndent
Gets the indentation setting to use for this page. Defaults toDocumentEE.getIndent(javax.servlet.ServletContext, javax.servlet.ServletRequest)
.- Parameters:
req
-null
during search- See Also:
-
getDocument
protected DocumentEE getDocument(WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Prepares for output and returns theDocumentEE
.- clears the output buffer.
- Sets the response content type.
- Sets the response character encoding
to the default
UTF-8
. - Sets any additional headers.
Both the
Serialization
andDoctype
may have been set on the request, and these must be considered in the content type.- Throws:
ServletException
IOException
- See Also:
-
getHtmlOutputStream
protected OutputStream getHtmlOutputStream(WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Prepares for output and returns theOutputStream
.- clears the output buffer.
- Sets the response content type.
- Sets the response character encoding
to the default
UTF-8
. - Sets any additional headers.
Both the
Serialization
andDoctype
may have been set on the request, and these must be considered in the content type.- Throws:
ServletException
IOException
- See Also:
-
service
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException Stores the current response in a request attribute namedRESPONSE_REQUEST_ATTRIBUTE
. This is used bygetLastModified(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
.- Overrides:
service
in classHttpServlet
- Throws:
ServletException
IOException
-
doGet
protected final void doGet(HttpServletRequest httpReq, HttpServletResponse resp) throws ServletException, IOException The main entry point forGET
requests. Prepares the request and performs initial actions:- Wraps the request in
WebSiteRequest
viagetWebSiteRequest(javax.servlet.http.HttpServletRequest)
. - Resolves the current instance of
WebPage
viagetWebPage(java.lang.Class, com.aoapps.web.framework.WebSiteRequest)
. - Handles any logout request (parameter
WebSiteRequest.LOGOUT_REQUESTED
="true") viaHttpServletRequestWrapper.logout()
. - Handles any login request (parameter
WebSiteRequest.LOGIN_REQUESTED
="true") by invokingprintLoginForm(com.aoapps.web.framework.WebPage, com.aoapps.security.LoginException, com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
and stops here. - Resolves the current
WebSiteUser
viaWebSiteRequest.getWebSiteUser(javax.servlet.http.HttpServletResponse)
(if any). When login required and failed, invokesprintLoginForm(com.aoapps.web.framework.WebPage, com.aoapps.security.LoginException, com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
and stops here. - Ensures the user can access the page,
invokes
printUnauthorizedPage(com.aoapps.web.framework.WebPage, com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
when not authorized and stops here. - If is a redirect, sends the redirect of the correct type and stops here.
- Finally, dispatches the request to
doGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
.
- Overrides:
doGet
in classHttpServlet
- Throws:
ServletException
IOException
- See Also:
- Wraps the request in
-
doGet
public void doGet(WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Prepares the request then invokesdoGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE)
. To not have these steps automatically applied, override this method. By the time this method is called, security checks, authentication, and redirects have been done.- Sets the serialization.
- Sets the DOCTYPE.
- Gets the
response writer
. - Invokes
doGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE)
.
- Throws:
ServletException
IOException
- See Also:
-
doGet
public void doGet(WebSiteRequest req, HttpServletResponse resp, DocumentEE document) throws ServletException, IOException The layout is automatically applied to the page, thendoGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.web.framework.WebPageLayout, com.aoapps.html.servlet.FlowContent)
is called. To not have the layout automatically applied, override this method. By the time this method is called, security checks, authentication, redirects, doctype, and serialization have been done.- Parameters:
req
- theWebSiteRequest
for this request, ornull
when searchingresp
- theHttpServletResponse
for this request, ornull
when searchingdocument
- theDocumentEE
to send output to- Throws:
ServletException
IOException
- See Also:
-
doGet
public <__ extends FlowContent<__>> void doGet(WebSiteRequest req, HttpServletResponse resp, WebPageLayout layout, __ flow) throws ServletException, IOException By default, GET provides no content.- Parameters:
req
- theWebSiteRequest
for this request, ornull
when searchingresp
- theHttpServletResponse
for this request, ornull
when searchinglayout
- theWebPageLayout
that has been appliedflow
- theFlowContent
to send output to- Throws:
ServletException
IOException
- See Also:
-
doPost
protected final void doPost(HttpServletRequest httpReq, HttpServletResponse resp) throws ServletException, IOException The main entry point forGET
requests. Prepares the request and performs initial actions:- Wraps the request in
WebSiteRequest
viagetWebSiteRequest(javax.servlet.http.HttpServletRequest)
. - Resolves the current instance of
WebPage
viagetWebPage(java.lang.Class, com.aoapps.web.framework.WebSiteRequest)
. - Handles any logout request (parameter
WebSiteRequest.LOGOUT_REQUESTED
="true") viaHttpServletRequestWrapper.logout()
. - Handles any login request (parameter
WebSiteRequest.LOGIN_REQUESTED
="true") by invokingprintLoginForm(com.aoapps.web.framework.WebPage, com.aoapps.security.LoginException, com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
and stops here. - Resolves the current
WebSiteUser
viaWebSiteRequest.getWebSiteUser(javax.servlet.http.HttpServletResponse)
(if any). When login required and failed, invokesprintLoginForm(com.aoapps.web.framework.WebPage, com.aoapps.security.LoginException, com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
and stops here. - Ensures the user can access the page,
invokes
printUnauthorizedPage(com.aoapps.web.framework.WebPage, com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
when not authorized and stops here. - If is a redirect, sends the redirect of the correct type and stops here.
- Avoid unexpected POST action after a (re)login: If has parameter
WebSiteRequest.LOGIN_REQUESTED
="true" or bothWebSiteRequest.LOGIN_USERNAME
andWebSiteRequest.LOGIN_PASSWORD
parameters, dispatch todoGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
and stop here. - Finally, dispatches the request to
doPostWithSearch(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
.
- Overrides:
doPost
in classHttpServlet
- Throws:
ServletException
IOException
- See Also:
- Wraps the request in
-
doPostWithSearch
protected void doPostWithSearch(WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Handles any search posts, sends everything else on todoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
. The search assumes the search parameters ofWebSiteRequest.SEARCH_QUERY
andWebSiteRequest.SEARCH_TARGET
. Both these values must be present for a search to be performed. Search target may be eitherWebSiteRequest.SEARCH_THIS_AREA
orWebSiteRequest.SEARCH_ENTIRE_SITE
, defaulting toWebSiteRequest.SEARCH_THIS_AREA
for any other value.- Throws:
ServletException
IOException
- See Also:
-
doPost
public void doPost(WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Prepares the request then invokesdoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE)
. To not have these steps automatically applied, override this method. By the time this method is called, security checks, authentication, and redirects have been done.- Sets the serialization.
- Sets the DOCTYPE.
- Gets the
response writer
. - Invokes
doPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE)
.
- Throws:
ServletException
IOException
- See Also:
-
doPost
public void doPost(WebSiteRequest req, HttpServletResponse resp, DocumentEE document) throws ServletException, IOException The layout is automatically applied to the page, thendoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.web.framework.WebPageLayout, com.aoapps.html.servlet.FlowContent)
is called. To not have the layout automatically applied, override this method. By the time this method is called, security checks, authentication, redirects, doctype, and serialization have been done.- Parameters:
req
- theWebSiteRequest
for this request, ornull
when searchingresp
- theHttpServletResponse
for this request, ornull
when searchingdocument
- theDocumentEE
to send output to- Throws:
ServletException
IOException
- See Also:
-
doPost
public <__ extends FlowContent<__>> void doPost(WebSiteRequest req, HttpServletResponse resp, WebPageLayout layout, __ flow) throws ServletException, IOException By default, a POST request just callsdoGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.web.framework.WebPageLayout, com.aoapps.html.servlet.FlowContent)
.- Parameters:
req
- the currentWebSiteRequest
resp
- theHttpServletResponse
for this requestlayout
- theWebPageLayout
that has been appliedflow
- theFlowContent
to send output to- Throws:
ServletException
IOException
- See Also:
-
equals
Determines if this page equals another page. -
equals
Determines if this page equals another page. By default, two pages of the same class are considered equal.- See Also:
-
hashCode
public int hashCode()The default hashcode for a page is the hashcode of its classname. -
setHeaders
Sets headers for this page. -
getAuthor
Gets the author of this page. By default, the author of the parent page is used.- Throws:
ServletException
-
getAuthorHref
Gets the URL for the author of this page. By default, the URL of the author of the parent page is used.- Throws:
ServletException
-
getPreferredContentWidth
Gets the preferred width of this content ornull
for no preference. It is up to theWebPageLayout
to make use of this value. The preferred width defaults to the preferred width of the parent page.- Throws:
ServletException
- See Also:
-
getContentValign
Gets the vertical alignment of the content area. Defaults to"top"
. It is up to theWebPageLayout
to make use of this value.- See Also:
-
getDescription
Gets the description of this page. By default, the description of the parent page is used. May not contain HTML.- Throws:
ServletException
-
getRootPage
Gets the root page in the web page hierarchy. The root page has no parent.- Throws:
ServletException
-
getJavascriptSrc
Gets the JavaScript's that should have script src= tags generated, urls relative to top of contextpath/to/javascript.js
.- Parameters:
req
- the currentWebSiteRequest
- Returns:
- a
String[]
for multiple includes, aClass
for one, aWebPage
for one, aObject
for one viaObject.toString()
, ornull
for none - Throws:
ServletException
-
getKeywords
Gets the keywords for this page. By default, no keywords.- Throws:
ServletException
-
getPageIndexInParent
public final int getPageIndexInParent(WebSiteRequest req, HttpServletResponse resp) throws ServletException Gets the index of this page in the parents list of children pages.- Throws:
ServletException
-
getNextPage
public final WebPage getNextPage(WebSiteRequest req, HttpServletResponse resp) throws ServletException Gets theWebPage
that follows this one in the parents list of pages.- Returns:
- the
WebPage
ornull
if not found - Throws:
ServletException
-
getPreviousPage
public final WebPage getPreviousPage(WebSiteRequest req, HttpServletResponse resp) throws ServletException Gets theWebPage
that proceeds this one in the parents list of pages.- Returns:
- the
WebPage
ornull
if not found - Throws:
ServletException
-
getOnloadScript
Gets the JavaScript that should be executed with the onload event of the body tag. This is a default only used when anull
onload is passed toWebPageLayout.startPage(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.web.framework.WebPage, com.aoapps.html.servlet.DocumentEE, java.lang.String)
.- Parameters:
req
- the currentWebSiteRequest
- Returns:
- a
String
ornull
for none
-
getCachedChildren
public WebPage[] getCachedChildren(WebSiteRequest req, HttpServletResponse resp) throws ServletException Gets all of the pages that are children of this one in the page hierarchy. Unless overridden, the pages are cached in aWebPage[]
for faster access. The actual list of pages is obtained fromgetChildren(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse)
.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:
ServletException
- See Also:
-
getParent
Gets the parent of this page ornull
for none.- Throws:
ServletException
-
getRedirectUrl
Gets the absolute or context-relative URL to direct to.- Returns:
- the context-relative or absolute URL to redirect to or
null
for no redirect. - Throws:
ServletException
-
getRedirectType
public int getRedirectType()Gets the redirect type, defaults to 302 (temporary). -
getShortTitle
A short title is used showing a path to the current location in the site. The short title defaults togetTitle
.- Returns:
- the short page title
- Throws:
ServletException
- See Also:
-
getTitle
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:
ServletException
-
getUrlParams
Gets parameters that are added to the query string of URLs generated for this page.- Returns:
- The parameters, may be
null
or empty when none. - Throws:
ServletException
- See Also:
-
getWebPage
public WebPage getWebPage(Class<? extends WebPage> clazz, WebSiteRequest req) throws ServletException Gets a web page given no parameters.- Throws:
ServletException
- See Also:
-
getWebPage
public static WebPage getWebPage(ServletContext context, Class<? extends WebPage> clazz, WebSiteRequest req) throws ServletException Gets an instance ofWebPage
given theClass
. Instances returned should never have theinit
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.When creating a new instance of
WebPage
, searches for constructors in the following order:- Single argument
WebSiteRequest
, given the request. - Single argument
URIParameters
, given aServletRequestParameters
wrapper around request. - No-args constructor.
- Parameters:
context
- the context the servlet will be run inclazz
- theClass
to get an instance ofreq
- the request details are used to select the right instance- Returns:
- a
WebPage
object of the given class that matches the request settings - Throws:
IllegalArgumentException
- if unable to create the instanceServletException
- See Also:
- Single argument
-
getWebPage
public WebPage getWebPage(Class<? extends WebPage> clazz, URIParameters params) throws ServletException Gets a web page with parameters.- Parameters:
params
- The parameters used to select the right instance.- Throws:
ServletException
- See Also:
-
getWebPage
Gets a web page given no parameters.- Throws:
ServletException
- See Also:
-
getWebPage
public static WebPage getWebPage(ServletContext context, Class<? extends WebPage> clazz, URIParameters params) throws ServletException Gets an instance ofWebPage
given theClass
. Instances returned should never have theinit
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.- Single argument
URIParameters
, given the parameters. - No-args constructor.
- Parameters:
context
- the context the servlet will be run inparams
- The parameters used to select the right instance.- Returns:
- a
WebPage
object of the given class that matches the request settings - Throws:
IllegalArgumentException
- if unable to create the instanceServletException
- See Also:
- Single argument
-
getWebPage
public static WebPage getWebPage(ServletContext context, Class<? extends WebPage> clazz) throws ServletException Gets an instance ofWebPage
given theClass
. Instances returned should never have theinit
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.- Single argument
URIParameters
, given empty parameters. - No-args constructor.
- Parameters:
context
- the context the servlet will be run in- Returns:
- a
WebPage
object of the given class that matches the request settings - Throws:
IllegalArgumentException
- if unable to create the instanceServletException
- See Also:
- Single argument
-
loadClass
Dynamically loads new classes based on the source .class file's modified time.- Throws:
ClassNotFoundException
-
getWebPageLayout
Gets the current layout for this page. When req is null, should returnSearchLayout
or equivalent.This default implementation returns
SearchLayout.getInstance()
for a search request (req is null), or inherits the layout of the parent.- Parameters:
req
- theWebSiteRequest
for this request, ornull
when searching- Returns:
- the
WebPageLayout
- Throws:
ServletException
-
getChildren
protected WebPage[] getChildren(WebSiteRequest req, HttpServletResponse resp) throws ServletException 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 callgetCachedWebPages
. Subclasses will override and disable the caching provided bygetCachedWebPages
when appropriate.- Returns:
- a
WebPage[]
of all of the lower-level pages - Throws:
ServletException
- See Also:
-
isHandler
Determines if this page is the instance that should handle a particular request.By default calls
isHandler(com.aoapps.net.URIParameters)
, wrapping request inServletRequestParameters
. When no request, usesEmptyURIParameters
.- See Also:
-
isHandler
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 thisClass
.- See Also:
-
getWebSiteRequest
Gets theWebSiteRequest
that handles authentication and other details of this site.- Throws:
ServletException
-
search
public void search(String[] words, WebSiteRequest req, HttpServletResponse response, List<SearchResult> results, CharArrayWriter buffer, Set<WebPage> finishedPages) throws ServletException, IOException Searches this WebPage and all of its subordinate pages, returning the matches in aArrayList
with five elements per match.- A
String
for the absolute URL (including settings) - The probability as a
Float
- The title of the page
- The description of the page
- The author of the page
standardSearch
- Parameters:
words
- all of the words that must matchreq
- theWebSiteRequest
containing the users preferencesresults
- theArrayList
that contains the resultsbuffer
- theSearchOutputStream
to use for internal processing- Throws:
ServletException
IOException
- See Also:
- A
-
standardSearch
public final void standardSearch(String[] words, WebSiteRequest req, HttpServletResponse resp, List<SearchResult> results, CharArrayWriter buffer, Set<WebPage> finishedPages) throws ServletException, IOException The standard implementation of the search functionality.- Throws:
ServletException
IOException
- See Also:
-
useSiteMap
public boolean useSiteMap()Determines if this page will be displayed in the standard site map. -
showInLocationPath
Determines if this page will be displayed in the location bar. -
getServletContext
- Specified by:
getServletContext
in interfaceServletConfig
- Overrides:
getServletContext
in classGenericServlet
-
getCopyright
public String getCopyright(WebSiteRequest req, HttpServletResponse resp, WebPage requestPage) throws ServletException Gets the copyright information for this page. Defaults to the copyright of the parent page. May not contain HTML.TODO: 3.0.0: Use dcterms: http://stackoverflow.com/questions/6665312/is-the-copyright-meta-tag-valid-in-html5 https://wiki.whatwg.org/wiki/MetaExtensions http://dublincore.org/documents/dcmi-terms/
- Throws:
ServletException
-
getUrlPath
Gets the context-relative path for the URL.- Throws:
ServletException
-
generateUrlPath
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-levelWebPage
of a site must implement this method.- Throws:
ServletException
-
getUrlPattern
Gets the URL pattern for this page as used inweb.xml
.- Throws:
ServletException
-