|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.http.serve.Component
simple.http.load.Service
simple.template.Controller
simple.template.View
public abstract class View
The View
object provides a service controller
implementation for providing a document view. It is used
to implement controllers that ultimately render a view for a
template. Typically the execute
methods are
implemented to populate a template document with the objects
that are used by the template to render the dynamic content.
lookup
and resolve
methods are
used to acquire the desired template document. This must then
be returned for the view to be rendered. If at any stage
during processing and error occurs then an exception may be
thrown to the calling method to indicate the problem.
Field Summary |
---|
Fields inherited from class simple.template.Controller |
---|
data, system |
Fields inherited from class simple.http.load.Service |
---|
engine |
Fields inherited from class simple.http.serve.Component |
---|
context |
Constructor Summary | |
---|---|
View(Context context)
Constructor for the View object. |
Method Summary | |
---|---|
Document |
execute(Request req,
Response resp)
The execute method is used to perform various
operations before a template is rendered. |
Document |
execute(Request req,
Response resp,
Document doc)
The execute method is used to perform various
operations before a template is rendered. |
Document |
lookup(java.lang.String target)
This method is used to retrieve templates using the name or path for that template. |
protected void |
process(Request req,
Response resp)
This process method is used to drive the
execute methods. |
Document |
resolve(java.lang.String target)
This method is used to retrieve templates using a specific URI. |
Methods inherited from class simple.template.Controller |
---|
prepare, prepare |
Methods inherited from class simple.http.load.Service |
---|
prepare |
Methods inherited from class simple.http.serve.Component |
---|
handle, handle, handle, process, process |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public View(Context context)
View
object. This is used
to create an View
implementation that can be
used as a controller service. Any subclass of this can
initialize itself using the prepare
method.
context
- the context this controller is rooted atMethod Detail |
---|
protected void process(Request req, Response resp) throws java.lang.Exception
process
method is used to drive the
execute
methods. This will simply invoke the
method and write the resulting Document
to the
responses output. This also sets the HTTP "Content-Type"
header using the name of the target. This will is only set
is it has not already been done so. However, this should
not be relied upon and each implementation should set its
own MIME type in order for the charset to be correct.
process
in class Component
req
- the HTTP request object representing the clientresp
- the HTTP response object to send a reply with
java.lang.Exception
- thrown if there is a problem processingpublic Document execute(Request req, Response resp) throws java.lang.Exception
execute
method is used to perform various
operations before a template is rendered. This typically
collects data that is used to render the template with the
information. This encourages the Model View Controller (MVC)
architecture to be used, and avoids dealing with the view.
req
- the HTTP request object representing the clientresp
- the HTTP response object to send a reply with
java.lang.Exception
- thrown if there is a problem processingpublic Document execute(Request req, Response resp, Document doc) throws java.lang.Exception
execute
method is used to perform various
operations before a template is rendered. This typically
collects data that is used to render the template with the
information. This encourages the Model View Controller (MVC)
architecture to be used, and avoids dealing with the view.
This method is useful when a layout or other such embedding
is required. This also avoids having to deal directly with
the resolve
and lookup
methods.
req
- the HTTP request object representing the clientresp
- the HTTP response object to send a reply withdoc
- the document object suggested for processing
java.lang.Exception
- thrown if there is a problem processingpublic Document lookup(java.lang.String target) throws java.lang.Exception
Environment
object's lookup
.
However, if desired, extra functionality can be introduced
to provide more useful names for templates, like "failure".
target
- the name or path referencing the template
Document
for the template
java.lang.Exception
public Document resolve(java.lang.String target) throws java.lang.Exception
http://www.domain.com/path?query /path;param=value?query /path/fileLike the
lookup
method this will typically
map directly to its counterpart Environment
method. However, extra functionality can be introduced to
map URI strings to the desired template documents.
target
- the URI string referencing the template
Document
for the template
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |