Forward Computing and Control Pty. Ltd.
WebStringTemplate V1.5.0

2004/1/7

au.com.forward.webstringtemplate
Class WebStringTemplateServer

java.lang.Object
  extended byau.com.forward.webstringtemplate.WebStringTemplateServer

public class WebStringTemplateServer
extends java.lang.Object

This class provides a set of useful server side WebStringTemplate routines.
These are in a separate class so that RunWST does not need any javax.servlet.* classes in order to run.

Author:
matthew ford

Field Summary
static java.util.logging.Logger logger
          The Java logger for this class
 
Constructor Summary
WebStringTemplateServer()
           
 
Method Summary
static WebStringTemplate getInstanceOf(javax.servlet.ServletContext application, java.lang.String groupName, java.lang.String groupRootDir, java.lang.String templateName)
          Get a template loaded with default data, using cache if possiable.
static WebStringTemplate getInstanceOf(javax.servlet.ServletContext application, java.lang.String groupName, java.lang.String groupRootDir, java.lang.String templateName, java.lang.String dataFileName)
          Get a template loaded with default data, using cache if possiable.
static WebStringTemplateGroup getInstanceOfGroup(javax.servlet.ServletContext application, java.lang.String groupName, java.lang.String groupRootDir)
          Get a group from this ServletContext.
static WebStringTemplate setJSPAttributes(WebStringTemplate wst, java.lang.Object scopeObject)
          Adds any attributes defined in the given scope to the template.
static void setRefreshInterval(javax.servlet.ServletContext application, java.lang.String groupName, int refreshInterval)
          Set the refresh interval for this application group.
static void writePageTemplate(WebStringTemplate wst, javax.servlet.jsp.PageContext pageContext)
          Write out this template using the attributes in the pageContext.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static final java.util.logging.Logger logger
The Java logger for this class

Constructor Detail

WebStringTemplateServer

public WebStringTemplateServer()
Method Detail

writePageTemplate

public static void writePageTemplate(WebStringTemplate wst,
                                     javax.servlet.jsp.PageContext pageContext)
                              throws java.io.IOException
Write out this template using the attributes in the pageContext.

Parameters:
wst - the template to write
pageContext - the JSP page context containing the attributes to be inserted in the template
Throws:
java.io.IOException - Description of the Exception

getInstanceOf

public static WebStringTemplate getInstanceOf(javax.servlet.ServletContext application,
                                              java.lang.String groupName,
                                              java.lang.String groupRootDir,
                                              java.lang.String templateName)
Get a template loaded with default data, using cache if possiable.
This method looks for a default data file by adding .data to the templateName and loads the data if found.

Parameters:
application - the JSP application object
groupName - the name of the group, used to look for an existing group.
groupRootDir - the rootDir of the group, only used in a new group is created.
templateName - the template to load (without any extension)
Returns:
the template, loaded with data from template.data if the data file was found.

setRefreshInterval

public static void setRefreshInterval(javax.servlet.ServletContext application,
                                      java.lang.String groupName,
                                      int refreshInterval)
Set the refresh interval for this application group.
If this group name does not exist in the application cache an exception is thrown.

Parameters:
application - the JSP application object
groupName - the name of the group, used to look for an existing group.
refreshInterval - the refresh interval (Sec), if < 0 set to 0, 0 means no caching.
Throws:
java.lang.IllegalStateException - if group does not already exists in this application.

getInstanceOf

public static WebStringTemplate getInstanceOf(javax.servlet.ServletContext application,
                                              java.lang.String groupName,
                                              java.lang.String groupRootDir,
                                              java.lang.String templateName,
                                              java.lang.String dataFileName)
Get a template loaded with default data, using cache if possiable.
This method looks for the specified default data file and loads the data if found.

Parameters:
application - the JSP application object
groupName - the name of the group, used to look for an existing group.
groupRootDir - the rootDir of the group, only used in a new group is created.
templateName - the template to load (without any extension)
dataFileName - the dataFile to load (with extension) or null if no dataFile to be loaded
Returns:
the template, loaded with data, if the data file was found.

getInstanceOfGroup

public static WebStringTemplateGroup getInstanceOfGroup(javax.servlet.ServletContext application,
                                                        java.lang.String groupName,
                                                        java.lang.String groupRootDir)
Get a group from this ServletContext.
Creates a new group in this application if none found.

Parameters:
application - the JSP application object
groupName - the name of the group, used to look for an existing group.
groupRootDir - the rootDir of the group, only used in a new group is created.
Returns:
the existing group or a new group if none existed.

setJSPAttributes

public static WebStringTemplate setJSPAttributes(WebStringTemplate wst,
                                                 java.lang.Object scopeObject)
Adds any attributes defined in the given scope to the template.
The scopeObject can be any of the predefined JSP objects
pageContext, session, application, response or config, or one of those objects' classes
OR
an object of class java.util.Map

Any existing attributes of the same name are overwritten.

Parameters:
wst - the template to load with the JSP attributes
scopeObject - the scope object to load from or a Map object
Returns:
the template loaded with these attributes

Forward Computing and Control Pty. Ltd.
WebStringTemplate V1.5.0

2004/1/7

Copyright ©2003, Forward Computing and Control Pty. Ltd
ACN 003 669 994   NSW Australia,   All Rights Reserved.
WebStringTemplate and associated code is released under licence. See the source.
WebStringTemplate uses code from StringTemplates and Antlr, under licence.
See the WebStringTemplate licence file for details.