All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.openly.dt.JSText

com.openly.dt.EncodingDynamicTag   |   +----com.openly.dt.JSText

public class JSText
extends com.openly.dt.EncodingDynamicTag
JSText is sort of a light-weight version of JSP. Instances of this object load the page denoted by the URI parameter of the constructor. Notice the toString Method that takes a Param table as a parameter. To use this object,
  1. you first have to make a JSText object initialized with a template. There are several ways to do this.
    1. pass a template name through the constructor. the name will be resolved considering templateRoot and root
    2. call loadTemplate(templateName) before use. the name will be resolved considering templateRoot and root
    3. call loadTemplateURI(templateURI) before use. the URI will be resolved without considering templateRoot and root
    4. call setTemplate(template) before use. the template will be set directly
    5. use the dynamic tag methods, getValue or writeValue. the param passed in these methods will be used as the template name. the name will be resolved considering templateRoot and root
  2. Pass a URI for the template through the constructor.
  3. Call the getValue method with a Params object which includes the incoming params
syntax of the JSText:

WARNING JSText looks for templates in a place set using the static method setTemplateRoot. Since this is static, multiple programs using JSText on a machine must use the same root directory. To avoid this snag, use Params objects that implement Rooted

Changes

Check out Java and Linking related books at Openly.com!

See Also:
com.openly.dt.DynamicTag, com.openly.dt.ConditionalText, com.openly.dt.Comment, com.openly.dt.Rooted, com.openly.dt.Repeat

Variable Index

 o CLOSE
 o OPEN
 o PARAMCLOSE
 o PARAMOPEN

Constructor Index

 o JSText()
 o JSText(String)

Method Index

 o flush()
flush templates in the cache
 o getValue(Params)
 o loadTemplate(String)
decides on a URI of a template to open, then calls loadTemplateURI This is done as follows: if root is not null, then root is prepended to temp if root is null, and templateRoot is not null, then templateRoot is prepended to temp if both templateRoot and root are null temp is used as is
 o loadTemplate(String, Params)
this takes a file as param, opens,
 o loadTemplateURI(String)
this takes a file as param, opens,
 o main(String[])
 o setRoot(String)
controls where this JSText object looks for templates inside template root.
 o setTemplate(String)
Set the template with a String
 o setTemplateRoot(String)
controls where raw JSText objects look for templates if Root is not set.
 o toString(Params)
same as getValue(params)
 o writeValue(Params, OutputStream)
calls writeValue(params, writer)
 o writeValue(String, Params, OutputStream)
implements the DynamicTag interface! Use this method WHENEVER the result is expected to be large

Variables

 o OPEN
 public static final java.lang.String OPEN
 o CLOSE
 public static final java.lang.String CLOSE
 o PARAMOPEN
 public static final java.lang.String PARAMOPEN
 o PARAMCLOSE
 public static final java.lang.String PARAMCLOSE

Constructors

 o JSText
 public JSText(java.lang.String templateLocation)
Parameters:
templateLocation - path relative to root to retrieve the template
 o JSText
 public JSText()

Methods

 o setRoot
 public void setRoot(java.lang.String root)
controls where this JSText object looks for templates inside template root.

 o setTemplateRoot
 public static void setTemplateRoot(java.lang.String root)
controls where raw JSText objects look for templates if Root is not set. it's really a default.

WARNINGcan only be set once; be careful about multiple projects using this.

 o setTemplate
 public void setTemplate(java.lang.String t)
Set the template with a String

Parameters:
t - the template string
 o loadTemplateURI
 public void loadTemplateURI(java.lang.String tempURI)
this takes a file as param, opens,

Parameters:
temp - file to open (as a string)
 o loadTemplate
 public void loadTemplate(java.lang.String temp)
decides on a URI of a template to open, then calls loadTemplateURI This is done as follows: if root is not null, then root is prepended to temp if root is null, and templateRoot is not null, then templateRoot is prepended to temp if both templateRoot and root are null temp is used as is

Parameters:
temp - file name to open (as a string)
 o loadTemplate
 public void loadTemplate(java.lang.String temp,                          com.openly.util.Params params)
this takes a file as param, opens,

Parameters:
temp - file to open (as a string)
params - if it's a Rooted, sets root before calling loadTemplate
 o getValue
 public java.lang.String getValue(com.openly.util.Params params)
 o writeValue
 public void writeValue(java.lang.String temp,                        com.openly.util.Params values,                        java.io.OutputStream writer) throws java.io.IOException
implements the DynamicTag interface! Use this method WHENEVER the result is expected to be large

Overrides:
writeValue in class com.openly.dt.EncodingDynamicTag
 o flush
 public void flush()
flush templates in the cache

 o writeValue
 public void writeValue(com.openly.util.Params params,                        java.io.OutputStream writer) throws java.io.IOException
calls writeValue(params, writer)

 o toString
 public java.lang.String toString(com.openly.util.Params values)
same as getValue(params)

 o main
 public static void main(java.lang.String params[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index