|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.utexas.beg.agi.servlet.DynamicHTMLPage
Abstract parent class of Objects representing HTML pages with dynamic content.
This class provides a default implementation of the streamPage() method, which is the main function of DynamicHTMLPages. The default implementation streams a static .prefix file, calls the streamDynamicContent() method, and then streams a static .suffix file. Subclasses can over-ride the streamDynamicContent() method to generate HTML code that includes, for example, values from the current UserParameters.
The AGIServlet has a List of DynamicHTMLPages which is established in its
createDynamicHTMLPages() method. When a page is requested, the Servlet searches
these page Objects to find one that canHandlePage()
, and then
calls its streamPage() method. Generally, each subclass of DynamicHTMLPage
will represent one page file, such as step1.html
.
Example: Suppose there is class Step1Page, which extends DynamicHTMLPage.
The class passes "step1.html" as itsfilePath
during construction, and it overrides the streamDynamicContent() method to generate an HTML form.
The static part of the HTML page (everything before the generated HTML) is created and placed in a file called/home/httpd/servlet/html/step1.html.prefix
. Everything after the generated HTML is placed in a file called/home/httpd/servlet/html/step1.html.suffix
.
An instance of this class is created and installed in the createDynamicHTMLPages() method of the AGIServlet.
At run-time, when a request for page "step1.html" is received, the AGIServlet searches it's DynamicHTMLPages, finding that this (Step1Page) Object can handle the request. The Servlet then calls its streamPage() method. The default implementation of that method streams thestep1.html.prefix
file, then calls the streamDynamicContent() method which generates the HTML form. Finally, thestep1.html.suffix
file is streamed back to the client browser.
AGIServlet.createDynamicHTMLPages()
Field Summary | |
private String |
filePath
The relative path of the URL that this page will support. |
private File |
rootFilePath
The root of all file paths, i.e. |
Constructor Summary | |
DynamicHTMLPage(String filePath)
Creates a dynamic HTML page for handling the given file path. |
Method Summary | |
boolean |
canHandlePage(String filePath)
Determines if the given file path can be serviced by this Object. |
protected abstract void |
streamDynamicContent(String page,
UserParameters parameters,
PrintWriter outStream)
Streams the actual dynamic content for this page. |
void |
streamPage(String page,
UserParameters parameters,
PrintWriter outStream)
Streams HTML content to the client browser. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private File rootFilePath
/home/httpd/servlet/html/
.
In particular, .prefix and .suffix files used by this class are found
within this root directory.private String filePath
mod1/index.html
, then requests for that page will be handled by
this Object. If this parameter is null
then the canHandlePage()
method must be over-ridden to properly handle pages.Constructor Detail |
public DynamicHTMLPage(String filePath)
filePath
- the relative path of the URL that this
page will support. For example, if this
value is mod1/index.html
, then
requests for that page will be handled by
this Object. If this parameter is
null
then the canHandlePage()
method must be over-ridden to properly
handle pages.Method Detail |
public boolean canHandlePage(String filePath)
If a filePath
was given when this Object was
constructed, then it is matched to the given path. If no
filePath
was used, then subclasses must provide
an implementation of this method, or it will always return
false
.
public void streamPage(String page, UserParameters parameters, PrintWriter outStream) throws IOException
This method looks for a page
.prefix and a page
.suffix
file. If a prefix file exists, then it is streamed statically. Then the
streamDynamicContent() method is called to stream the actual dynamic part of the
page. Then the suffix file is streamed statically, if it exists.
Subclasses probably will not need to implement this method. They can over-ride the streamDynamicContent() method, and create static .prefix and .suffix files if desired.
page
- the relative file path of the page to stream.parameters
- the current parameter values set by the human user.outStream
- the output stream to write the HTML content to. This
stream returns data to the client browser.protected abstract void streamDynamicContent(String page, UserParameters parameters, PrintWriter outStream) throws IOException
page
- the relative file path of the page to stream.parameters
- the current parameter values set by the human user.outStream
- the output stream to write the HTML content to. This
stream returns data to the client browser.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |