|
SimpleServlets v5.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.simpleservlets.pageprocessor.HTMLObjectsPageHandler
public abstract class HTMLObjectsPageHandler
This class bridges the world of HTML Objects and PageProcessor.
It implements the PageHandler interface and creates a
generic HTMLElement container to be filled in by the subclass.
When the page is ready, the sendPage(PageContext, HTMLElement)
method is called to send the content to the browser.
Pages that are permitted to be directly requested by a browser will
want to override the processRequest(PageContext, HTMLElement)
method.
Pages that want to specify a header for the top of the page will
want to override the createHeader(PageContext, HTMLElement)
method.
Pages that want to specify a footer for the bottom of the page will
want to override the createFooter(PageContext, HTMLElement)
method.
| Field Summary | |
|---|---|
protected HTMLColor |
defaultPageBackgroundColor
|
protected String |
defaultTitle
|
| Constructor Summary | |
|---|---|
protected |
HTMLObjectsPageHandler()
Sets the default title to "Untitled" and the default page background color to white. |
protected |
HTMLObjectsPageHandler(String defaultTitle)
Sets the specified default title and the sets the default page background color to white. |
protected |
HTMLObjectsPageHandler(String defaultTitle,
HTMLColor defaultPageBackgroundColor)
Sets the specified default title and the specified default page background color. |
| Method Summary | |
|---|---|
protected void |
createFooter(PageContext pc,
HTMLElement con)
Subclasses override this method to provide a "footer" that should be at the bottom of the page. |
protected void |
createHeader(PageContext pc,
HTMLElement con)
Subclasses override this method to provide a "header" that should be at the top of the page. |
protected HTMLColor |
getPageBackgroundColor(PageContext pc)
Returns the background color that should be currently used for this page. |
protected String |
getTitle(PageContext pc)
Returns the HTML page title that should be currently used for this page. |
void |
processRequest(PageContext pc)
This implementation of the PageHandler method creates an
HTML element container and then calls
processRequest(PageContext, HTMLElement) to
fill up the container. |
protected void |
processRequest(PageContext pc,
HTMLElement con)
This method is called whenever there is a request aimed at this page. |
protected void |
sendPage(PageContext pc,
HTMLElement con)
This method is called from the subclass to indicate that this page should be delivered to the browser. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final String defaultTitle
protected final HTMLColor defaultPageBackgroundColor
| Constructor Detail |
|---|
protected HTMLObjectsPageHandler(String defaultTitle,
HTMLColor defaultPageBackgroundColor)
getTitle(PageContext) method can
be overridden in subclasses to return a title that overrides this
default title.
The getPageBackgroundColor(PageContext) method can
be overridden in subclasses to return a color that overrides this
default background color.
protected HTMLObjectsPageHandler(String defaultTitle)
protected HTMLObjectsPageHandler()
| Method Detail |
|---|
public final void processRequest(PageContext pc)
throws PageProcessorException
PageHandler method creates an
HTML element container and then calls
processRequest(PageContext, HTMLElement) to
fill up the container. This method can not be overridden in subclass (if
you have a need to directly handle processRequest then you
can implement PageHandler directly).
processRequest in interface PageHandlerPageProcessorException
protected void processRequest(PageContext pc,
HTMLElement con)
throws PageProcessorException
sendPage(PageContext, HTMLElement) to deliver
this page to the browser.
This class' implementation (when not overridden) always throws a PageProcessorException to indicate that the page is not permitted to be accessed directly. Subclasses override this method to allow a page to be directly requested.
pc - the context of the request/response cyclecon - the container to fill up with the page's content
PageProcessorException - can be optionally thrown to indicate
that the page could not be created.
protected void sendPage(PageContext pc,
HTMLElement con)
throws PageProcessorException
getTitle(PageContext)getPageBackgroundColor(PageContext)createHeader(PageContext, HTMLElement)createFooter(PageContext, HTMLElement)If classes other than the subclass should be allowed to call this method, then the subclass can override this method enlarging the access scope from protected to public like this:
public void sendPage(PageContext pc, HTMLElement con)
throws PageProcessorException {
super.sendPage(pc, con);
}
pc - the context to use for sending the pagecon - the container that forms the main content of the page.
PageProcessorException - if there is trouble generating the
header or footer, or sending the page.
protected HTMLColor getPageBackgroundColor(PageContext pc)
throws PageProcessorException
pc - the context is made available in case it is needed to
determine the value to return.
PageProcessorException - can be optionally thrown by a
subclass so signal that there was an unexpected problem determining
the value to return.
protected String getTitle(PageContext pc)
throws PageProcessorException
pc - the context is made available in case it is needed to
determine the value to return.
PageProcessorException - can be optionally thrown by a
subclass so signal that there was an unexpected problem determining
the value to return.
protected void createHeader(PageContext pc,
HTMLElement con)
throws PageProcessorException
pc - the context is made available in case it is needed to
determine elements of the header.con - the container that the header element(s) should be added to.
PageProcessorException - can be optionally thrown by a
subclass so signal that there was an unexpected problem
generating the header.
protected void createFooter(PageContext pc,
HTMLElement con)
throws PageProcessorException
pc - the context is made available in case it is needed to
determine elements of the footer.con - the container that the footer element(s) should be added to.
PageProcessorException - can be optionally thrown by a
subclass so signal that there was an unexpected problem
generating the footer.
|
SimpleServlets v5.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||