- 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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanAccess(WebSiteUser user) Determines if the provided user can access the page.voidconfigureResources(ServletContext servletContext, WebSiteRequest req, HttpServletResponse resp, WebPageLayout layout, Registry pageRegistry) Configures the page-scope web resources that this page uses.voiddoGet(WebSiteRequest req, HttpServletResponse resp) Prepares the request then invokesdoGet(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE).voiddoGet(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 voiddoGet(HttpServletRequest httpReq, HttpServletResponse resp) The main entry point forGETrequests.voiddoPost(WebSiteRequest req, HttpServletResponse resp) Prepares the request then invokesdoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse, com.aoapps.html.servlet.DocumentEE).voiddoPost(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 voiddoPost(HttpServletRequest httpReq, HttpServletResponse resp) The main entry point forGETrequests.protected voiddoPostWithSearch(WebSiteRequest req, HttpServletResponse resp) Handles any search posts, sends everything else on todoPost(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse).booleanDetermines if this page equals another page.final booleanDetermines 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 booleangetAutonli(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 longGets 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 DoctypegetDoctype(WebSiteRequest req) Gets theDoctypeto use for this page.protected DocumentEEgetDocument(WebSiteRequest req, HttpServletResponse resp) Prepares for output and returns theDocumentEE.protected OutputStreamgetHtmlOutputStream(WebSiteRequest req, HttpServletResponse resp) Prepares for output and returns theOutputStream.protected booleangetIndent(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.longgetLastModified(WebSiteRequest req, HttpServletResponse resp) ThegetLastModifieddefaults to-1.protected final longgetLastModified(HttpServletRequest httpReq) The main entry point forgetLastModified()requests.final longRecursively gets the most recent modification time.static longgetLastModifiedRecursive(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 WebPagegetNextPage(WebSiteRequest req, HttpServletResponse resp) Gets theWebPagethat 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 intGets the index of this page in the parents list of children pages.abstract WebPageGets the parent of this page ornullfor none.Gets the preferred width of this content ornullfor no preference.final WebPagegetPreviousPage(WebSiteRequest req, HttpServletResponse resp) Gets theWebPagethat proceeds this one in the parents list of pages.intGets the redirect type, defaults to 302 (temporary).Gets the absolute or context-relative URL to direct to.final WebPageGets the root page in the web page hierarchy.longGets the last modified time for search indexing.protected SerializationGets theSerializationto 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 longGets 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 WebPagegetWebPage(ServletContext context, Class<? extends WebPage> clazz) Gets an instance ofWebPagegiven theClass.static WebPagegetWebPage(ServletContext context, Class<? extends WebPage> clazz, URIParameters params) Gets an instance ofWebPagegiven theClass.static WebPagegetWebPage(ServletContext context, Class<? extends WebPage> clazz, WebSiteRequest req) Gets an instance ofWebPagegiven theClass.longGets the most recent last modified time of this page and its immediate children.Gets the current layout for this page.protected abstract WebSiteRequestGets theWebSiteRequestthat handles authentication and other details of this site.inthashCode()The default hashcode for a page is the hashcode of its classname.booleanDetermine if the nav image for this page should remain visible, even when its children are displayed.booleanisHandler(URIParameters params) Determines if this page is the instance that represents a certain set of parameters.booleanisHandler(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.voidprintLoginForm(WebPage page, LoginException loginException, WebSiteRequest req, HttpServletResponse resp) Prints the form that is used to login.voidprintUnauthorizedPage(WebPage page, WebSiteRequest req, HttpServletResponse resp) Prints the unauthorized page message.voidsearch(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 aArrayListwith five elements per match.protected voidservice(HttpServletRequest req, HttpServletResponse resp) Stores the current response in a request attribute namedRESPONSE_REQUEST_ATTRIBUTE.voidsetHeaders(WebSiteRequest req, HttpServletResponse resp) Sets headers for this page.booleanDetermines if this page will be displayed in the location bar.final voidstandardSearch(String[] words, WebSiteRequest req, HttpServletResponse resp, List<SearchResult> results, CharArrayWriter buffer, Set<WebPage> finishedPages) The standard implementation of the search functionality.booleanDetermines whether or not to display the page in the left navigation.booleanDetermines if this page will be displayed in the standard site map.Methods inherited from class com.aoapps.web.resources.servlet.PageServlet
serviceMethods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTraceMethods 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 ofWebPageobjects 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:
ServletExceptionIOException
-
printUnauthorizedPage
public void printUnauthorizedPage(WebPage page, WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException Prints the unauthorized page message.- Throws:
ServletExceptionIOException
-
getLastModified
The main entry point forgetLastModified()requests. Prepares the request and performs initial actions:- Wraps the request in
WebSiteRequestviagetWebSiteRequest(javax.servlet.http.HttpServletRequest). - Resolves the current instance of
WebPageviagetWebPage(java.lang.Class, com.aoapps.web.framework.WebSiteRequest). - Handles any login request (parameter
WebSiteRequest.LOGIN_REQUESTED="true") by returning-1for unknown. - Resolves the current
WebSiteUserviaWebSiteRequest.getWebSiteUser(javax.servlet.http.HttpServletResponse)(if any). When login required and failed, returns-1for unknown. - Ensures the user can access the page,
returns
-1for unknown when not authorized. - If is a redirect,
returns
-1for unknown. - Finally, dispatches the request to
getLastModified(com.aoapps.web.framework.WebSiteRequest, javax.servlet.http.HttpServletResponse).
- Overrides:
getLastModifiedin classHttpServlet- See Also:
- Wraps the request in
-
getLastModified
ThegetLastModifieddefaults 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 togetLastModifiedwith nullWebSiteRequestandHttpServletResponse.- Throws:
ServletException
-
getSerialization
Gets theSerializationto use for this page.- Parameters:
req-nullduring search- See Also:
-
getDoctype
Gets theDoctypeto use for this page.- Parameters:
req-nullduring 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-nullduring search- See Also:
-
getIndent
Gets the indentation setting to use for this page. Defaults toDocumentEE.getIndent(javax.servlet.ServletContext, javax.servlet.ServletRequest).- Parameters:
req-nullduring 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
SerializationandDoctypemay have been set on the request, and these must be considered in the content type.- Throws:
ServletExceptionIOException- 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
SerializationandDoctypemay have been set on the request, and these must be considered in the content type.- Throws:
ServletExceptionIOException- 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:
servicein classHttpServlet- Throws:
ServletExceptionIOException
-
doGet
protected final void doGet(HttpServletRequest httpReq, HttpServletResponse resp) throws ServletException, IOException The main entry point forGETrequests. Prepares the request and performs initial actions:- Wraps the request in
WebSiteRequestviagetWebSiteRequest(javax.servlet.http.HttpServletRequest). - Resolves the current instance of
WebPageviagetWebPage(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
WebSiteUserviaWebSiteRequest.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:
doGetin classHttpServlet- Throws:
ServletExceptionIOException- 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:
ServletExceptionIOException- 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- theWebSiteRequestfor this request, ornullwhen searchingresp- theHttpServletResponsefor this request, ornullwhen searchingdocument- theDocumentEEto send output to- Throws:
ServletExceptionIOException- 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- theWebSiteRequestfor this request, ornullwhen searchingresp- theHttpServletResponsefor this request, ornullwhen searchinglayout- theWebPageLayoutthat has been appliedflow- theFlowContentto send output to- Throws:
ServletExceptionIOException- See Also:
-
doPost
protected final void doPost(HttpServletRequest httpReq, HttpServletResponse resp) throws ServletException, IOException The main entry point forGETrequests. Prepares the request and performs initial actions:- Wraps the request in
WebSiteRequestviagetWebSiteRequest(javax.servlet.http.HttpServletRequest). - Resolves the current instance of
WebPageviagetWebPage(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
WebSiteUserviaWebSiteRequest.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_USERNAMEandWebSiteRequest.LOGIN_PASSWORDparameters, 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:
doPostin classHttpServlet- Throws:
ServletExceptionIOException- 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_QUERYandWebSiteRequest.SEARCH_TARGET. Both these values must be present for a search to be performed. Search target may be eitherWebSiteRequest.SEARCH_THIS_AREAorWebSiteRequest.SEARCH_ENTIRE_SITE, defaulting toWebSiteRequest.SEARCH_THIS_AREAfor any other value.- Throws:
ServletExceptionIOException- 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:
ServletExceptionIOException- 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- theWebSiteRequestfor this request, ornullwhen searchingresp- theHttpServletResponsefor this request, ornullwhen searchingdocument- theDocumentEEto send output to- Throws:
ServletExceptionIOException- 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 currentWebSiteRequestresp- theHttpServletResponsefor this requestlayout- theWebPageLayoutthat has been appliedflow- theFlowContentto send output to- Throws:
ServletExceptionIOException- 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 ornullfor no preference. It is up to theWebPageLayoutto 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 theWebPageLayoutto 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, aClassfor one, aWebPagefor one, aObjectfor one viaObject.toString(), ornullfor 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 theWebPagethat follows this one in the parents list of pages.- Returns:
- the
WebPageornullif not found - Throws:
ServletException
-
getPreviousPage
public final WebPage getPreviousPage(WebSiteRequest req, HttpServletResponse resp) throws ServletException Gets theWebPagethat proceeds this one in the parents list of pages.- Returns:
- the
WebPageornullif 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 anullonload 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
Stringornullfor 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 ornullfor 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
nullfor 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
nullor 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 ofWebPagegiven theClass. Instances returned should never have theinitmethod 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
isHandlermethod.When creating a new instance of
WebPage, searches for constructors in the following order:- Single argument
WebSiteRequest, given the request. - Single argument
URIParameters, given aServletRequestParameterswrapper around request. - No-args constructor.
- Parameters:
context- the context the servlet will be run inclazz- theClassto get an instance ofreq- the request details are used to select the right instance- Returns:
- a
WebPageobject 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 ofWebPagegiven theClass. Instances returned should never have theinitmethod 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
isHandermethod.- 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
WebPageobject 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 ofWebPagegiven theClass. Instances returned should never have theinitmethod 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
isHandermethod.- Single argument
URIParameters, given empty parameters. - No-args constructor.
- Parameters:
context- the context the servlet will be run in- Returns:
- a
WebPageobject 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 returnSearchLayoutor equivalent.This default implementation returns
SearchLayout.getInstance()for a search request (req is null), or inherits the layout of the parent.- Parameters:
req- theWebSiteRequestfor this request, ornullwhen 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 bygetCachedWebPageswhen 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 theWebSiteRequestthat 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 aArrayListwith five elements per match.- A
Stringfor 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- theWebSiteRequestcontaining the users preferencesresults- theArrayListthat contains the resultsbuffer- theSearchOutputStreamto use for internal processing- Throws:
ServletExceptionIOException- 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:
ServletExceptionIOException- 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:
getServletContextin interfaceServletConfig- Overrides:
getServletContextin 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-levelWebPageof a site must implement this method.- Throws:
ServletException
-
getUrlPattern
Gets the URL pattern for this page as used inweb.xml.- Throws:
ServletException
-
