|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfc.web.page.PageImpl
public class PageImpl
A superclass for generated pages. All pages derive from this class.
| Field Summary | |
|---|---|
Log |
log
|
| Fields inherited from interface fc.web.page.Page |
|---|
DEFAULT_BUFFER_SIZE, DEFAULT_CONTENT_TYPE, DEFAULT_ENCODING, DEFAULT_MIME_TYPE, PACKAGE_NAME |
| Constructor Summary | |
|---|---|
PageImpl()
|
|
| Method Summary | |
|---|---|
void |
bug(java.io.Writer writer,
java.lang.Object str1)
Prints a debug statement if debugging is turned on for this page. |
void |
bug(java.io.Writer writer,
java.lang.Object str1,
java.lang.Object str2)
|
void |
bug(java.io.Writer writer,
java.lang.Object str1,
java.lang.Object str2,
java.lang.Object str3)
|
void |
bug(java.io.Writer writer,
java.lang.Object str1,
java.lang.Object str2,
java.lang.Object str3,
java.lang.Object... args)
|
void |
clientRedirect(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String newLocation)
Redirects the client to the new page location. |
void |
dbg(boolean val)
Starts/stop debugging with no dbg_prefix/dbg_suffix. |
void |
dbgPrefix(java.lang.String dbg_prefix)
Sets the prefix for debugging output. |
void |
dbgSuffix(java.lang.String dbg_suffix)
Sets the suffix for debugging output. |
void |
destroy()
This method is invoked whenever a page is destoryed/unloaded |
java.lang.String |
getPagePath(javax.servlet.http.HttpServletRequest req)
Returns the path to this page from the web servers document root. |
java.lang.String |
getRealPath(javax.servlet.http.HttpServletRequest req)
Returns the real absolute directory path for the PagePath. |
java.io.CharArrayWriter |
getThreadLocalWriter()
Returns a thread specific CharArrayWriter that can be passed to this method as various points in the page. |
long |
getTime()
Returns the time elapsed after invoking startTime method. |
void |
init(PageServlet servlet,
java.lang.String contextRelativePagePath)
This method is invoked whenever a page is created and before it is run. |
void |
render(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
|
void |
startTimer()
If set to true, a timer to calculate page render time is started after this method call. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Log log
| Constructor Detail |
|---|
public PageImpl()
| Method Detail |
|---|
public void render(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws java.lang.Exception
render in interface Pagejava.lang.Exception
public void init(PageServlet servlet,
java.lang.String contextRelativePagePath)
PagePages should override this method to instantiate/set-up page variables as needed. (pages have no-arg constructors so like most of the servlet API, setup is done in a init method instead).
When overriding this class, you must remember to call: super.init
The page class is reloaded if the page is modified. Variables
should therefore be cleaned up in the destory method
as needed.
init in interface Pagepublic void destroy()
Page
destroy in interface Pagepublic java.lang.String getPagePath(javax.servlet.http.HttpServletRequest req)
PageSo for example, if the page is at foo/bar.mp and is running
under the webapp context of context1, then the page path
will be: /context1/foo/bar.mp. If there is no specific
web app (i.e., the most common case of a default "" webapp), then the page
path will be /foo/bar.mp
This page path is essentially what needs to be typed in the browsers URL window to invoke the page. It's also useful as form action parameters. For example, in a molly page:
This will submit the form to the same page where the form is defined. This can be hard coded of course but by using.. <form action="[=getPagePath(req)]" method="post"> .. </form>
getPagePath, the html
does not have to be changed if the name of the page changes on disk.
getPagePath in interface Pagepublic java.lang.String getRealPath(javax.servlet.http.HttpServletRequest req)
PagePagePath.
So, for example, for a webserver document root at
/web/sites/default/ and a page located in
foo/bar.mp, the real path will be:
/web/sites/default/foo/bar.mp
getRealPath in interface Page
public void clientRedirect(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String newLocation)
throws java.io.IOException
PageHttpServletResponse.sendRedirect method (possibly
easier to remember).
clientRedirect in interface Pagereq - the current requestres - the current response
java.io.IOExceptionpublic java.io.CharArrayWriter getThreadLocalWriter()
Page
Note: The writer is not reset or flushed when it is retrieved. It
must be reset manually via calling the CharArrayWriter.reset() method. This design-decision allows request
threads to collect debugging data across multiple pages.
The suggested usage idiom is:
dbg(true);
CharArrayWriter cw = getThreadLocalWriter():
bug(cw, "some message");
...
bug(cw, "other message");
...
pw.writeTo(out);
pw.reset();
getThreadLocalWriter in interface Pagepublic final void startTimer()
getTime()
method.
public final long getTime()
startTime method.
public final void dbg(boolean val)
val - true to enable debugging, false to disable.public final void dbgPrefix(java.lang.String dbg_prefix)
dbg_prefix - some html/text (such as public final void dbgSuffix(java.lang.String dbg_suffix)
dbg_suffix - some html/text (such as
public final void bug(java.io.Writer writer,
java.lang.Object str1)
throws java.io.IOException
Typically the implicit page printwriter (the out
variable) will be passed to this method and debug statements will be
printed at the point where they are lexically invoked at the page.
However, each page request thread can collect debugging information
and print the output at some arbitrary location, such as the bottom
of the page. The method #getThreadLocalOutput exists for
this reason and can be used to collect thread-local output during
page execution.
java.io.IOException
public final void bug(java.io.Writer writer,
java.lang.Object str1,
java.lang.Object str2)
throws java.io.IOException
java.io.IOException
public final void bug(java.io.Writer writer,
java.lang.Object str1,
java.lang.Object str2,
java.lang.Object str3)
throws java.io.IOException
java.io.IOException
public final void bug(java.io.Writer writer,
java.lang.Object str1,
java.lang.Object str2,
java.lang.Object str3,
java.lang.Object... args)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||