| 
 |   | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
  |
  +--sunlabs.brazil.template.Template
        |
        +--sunlabs.brazil.tcl.TclServerTemplate
The TclServerTemplate looks for each
 <server language="tcl">
 (or <"tcl">)
 tag in an HTML page and treats the following data up to the next
 </server> tag as a Tcl script to evaluate.
 If the optional attribute eval is present,
 the all ${...} constructs are replaced using
 Format.subst(java.util.Dictionary, java.lang.String)
 before being passed to the Tcl interpreter.
 
 The reason that Tcl scripts are included in an HTML page is usually
 to generate dynamic, server-side content.  After running this template,
 everything between and including the <server> and
 </server> tags is replaced with the result of
 evaluating the Tcl script as follows: 
puts "hello").
 return "bob").
 puts and a final return can both be
 used within a single Tcl fragment.
 
 All Tcl fragments within a given page are evaluated in the same Tcl
 interpreter.  The Tcl interpreter actually lives for the entire duration
 of this Template object, so the user can implement
 persistence across requests.
 
The following configuration parameters are used to initialize this template.
prefix and
	server are set before this file is evaluated, and
	are references to the parameters passed to a handler
	init method.
 <server> and
	</server> tags with comments, so the user
	can keep track of where the dynamically generated content is coming
	from by examining the comments in the resultant HTML document.
	By default, the <server> and
	</server> are completely eliminated from the
	HTML document rather than changed into comments.
 Before evaluating each HTML document, this class variables in the Tcl interpreter, which can be used to interact back with Java to do things like set the response headers:
Request Java object.  
	It is set anew at each request.
 Server object.
 
| Field Summary | 
| Fields inherited from class sunlabs.brazil.template.Template | 
| debug | 
| Constructor Summary | |
| TclServerTemplate() | |
| Method Summary | |
|  boolean | done(RewriteContext hr)Called after the HTML document has been processed. | 
|  boolean | init(RewriteContext hr)Defer setting up the interpreter until its first use. | 
|  boolean | setup(RewriteContext hr)Called at the first tcl code in the document TclServerTemplateis asked to process. | 
|  void | tag_server(RewriteContext hr)Processes the <server>tag. | 
|  void | tag_tcl(RewriteContext hr)Processes the <tcl>tag. | 
| Methods inherited from class java.lang.Object | 
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
public TclServerTemplate()
| Method Detail | 
public boolean init(RewriteContext hr)
init in interface TemplateInterfaceinit in class Templatepublic boolean setup(RewriteContext hr)
TclServerTemplate is asked to process.
 
 Redirects the standard output of the Tcl interpreter to the
 resultant HTML document and exposes the Request
 object as a Tcl variable.
 
 The first time this method is called, the initialization script is
 sourced into the interpreter, based on the configuration properties
 in the Request
hr - The request and associated HTML document that will be
		processed.
true interpreter was successfully initialized
		false otherwise.  About the only way that the
		initialization could fail would be request
		     or server as array variables.
		false is returned, an error message is logged.public boolean done(RewriteContext hr)
 Releases the resources allocated by init.  This method
 should be called to ensure that the HtmlRewriter and
 all its attendant data structures are not preserved indefinitely
 (until the next request).
done in interface TemplateInterfacedone in class Templatehr - The request and associated HTML document that was processed.
true always, indicating that this document was
		successfully processed to completion.public void tag_server(RewriteContext hr)
<server> tag.  Substitues the
 result of evaluating the following Tcl script into the resultant
 HTML document.
 
 Note: Currently, there is no mechanism for other language interpreters
 to share the same server tag.  Use the
 <tcl> tag instead.
hr - The request and associated HTML document that will be
		processed.public void tag_tcl(RewriteContext hr)
<tcl> tag.  Substitues the
 result of evaluating the following Tcl script into the resultant
 HTML document.
hr - The request and associated HTML document that will be
		processed.| 
 | Version 2.1, Generated 12/30/04 Copyright (c) 2001-2004, Sun Microsystems. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||