|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Page
A page is a cool and sane replacement for JSP's with much better syntax.
Server side pages implement this interface via the concrete
PageImpl class. This class has some additional utility
methods as well that page authors may find useful.
| Field Summary | |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
|
static java.lang.String |
DEFAULT_CONTENT_TYPE
|
static java.lang.String |
DEFAULT_ENCODING
The default encoding of the page, specified in the header sent back to the client. |
static java.lang.String |
DEFAULT_MIME_TYPE
The default mime-type for each page. |
static java.lang.String |
PACKAGE_NAME
|
| Method Summary | |
|---|---|
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 |
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. |
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)
|
| Field Detail |
|---|
static final java.lang.String PACKAGE_NAME
static final int DEFAULT_BUFFER_SIZE
static final java.lang.String DEFAULT_MIME_TYPE
javax.servlet.ServletResponse.setContentType method.
static final java.lang.String DEFAULT_ENCODING
<head><meta http-equiv=content-type content='text/html; charset=UTF-8'></head>Encodings can be tricky. We are first compiling a page into a java source file, then running the source file and sending it's output to the browser. Read the page encoding and charsets if you are using any non-us-ascii or non- ISO-8859-1 characters in your molly source page.
static final java.lang.String DEFAULT_CONTENT_TYPE
| Method Detail |
|---|
void render(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws java.lang.Exception
java.lang.Exception
void init(PageServlet servlet,
java.lang.String contextRelativePagePath)
Pages 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.
void destroy()
java.lang.String getPagePath(javax.servlet.http.HttpServletRequest req)
So 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.
java.lang.String getRealPath(javax.servlet.http.HttpServletRequest req)
PagePath.
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
void clientRedirect(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String newLocation)
throws java.io.IOException
HttpServletResponse.sendRedirect method (possibly
easier to remember).
req - the current requestres - the current responselocation - See
javax.servlet.http.HttpResponse#sendRedirect.
Essentially, the location can be relative to the
specified request's URI or relative to the
context root if it contains a leading '/'
java.io.IOExceptionjava.io.CharArrayWriter getThreadLocalWriter()
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();
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||