wt.htmlutil
Class HTMLTemplate

java.lang.Object
  extended bywt.util.LocalizedResource
      extended bywt.htmlutil.HTMLTemplate

public class HTMLTemplate
extends LocalizedResource

Deprecation Notice: This class is still valid for this release, however this serves as advance notice that it will be removed in the future. All user interfaces built using the Windchill HTML Template Processing client architecture will be rewritten using a different framework in an upcoming release. HTMLTemplate contains those methods needed to get and process a template for a given locale. It now supports a caching mechanism to lower the overhead of parsing a given template by saving the parse information between uses. Subsequent calls to the same page will use the cached parse information rather than re-parsing the old template.

  • To enable or disable caching, you will want to set wt.template.cache.enabled to true or false, respectively.
  • There is a configurable limit to the number of templates saved in the cache at any given time. The limit defaults to 25, but can be configured through wt.template.cache.size.
  • The caching mechanism will detect changes to the template files on disk and re-generate the new parse data automatically.

    Other useful properties are

  • wt.template.cache.verbose=(true|false) for verbose logging and
  • wt.template.cache.timed=(true|false) to enable timing of the processing of templates, cached or otherwise.

    Supported API: false
    Extendable: false


    Nested Class Summary
     
    Nested classes inherited from class wt.util.LocalizedResource
     
    Field Summary
    private static boolean CACHE_ENABLED
              Deprecated.  
    private static String FILE_SEPARATOR
              Deprecated.  
    private static int MAX_CACHE_SIZE
              Deprecated.  
    private static boolean PROCESS_TIMED
              Deprecated.  
    private static boolean TEMPLATE_VERBOSE
              Deprecated.  
    private static Cache templateCache
              Deprecated.  
    private static String WT_HOME
              Deprecated.  
     
    Fields inherited from class wt.util.LocalizedResource
     
    Constructor Summary
    HTMLTemplate(String resourceName)
              Deprecated. Construct an HTMLTemplate object with the given resourceName.
     
    Method Summary
     void closeInput()
              Deprecated. Supported API: true
     String getEncoding()
              Deprecated. Get character encoding that should be used when writing text to this templates output stream.
     void init()
              Deprecated. Search for the template best matching the server's Locale.
     void init(Locale locale)
              Deprecated. Search for the template best matching the given Locale.
     void init(Locale locale, boolean override)
              Deprecated. Search for the template best matching the given Locale.
     void init(Vector preferences)
              Deprecated. Search for the template best matching the given Locale preferences.
    static String[] listBaseTemplates(String resourcePath)
              Deprecated. Get a list of 'base' .html and .htm files in the directory specified by the given resourcePath.
    static void main(String[] args)
              Deprecated. Supported API: false
     void process(OutputStream out, Object context)
              Deprecated. Call processTemplate with the given OutputStream and context.
     
    Methods inherited from class wt.util.LocalizedResource
    closeInputStream, getInputStream, getLocale, getLocalizedResourceName, getLocalizedResourceName, getResourceName, openResource, openResource, openResource, setDebug, setLocale
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    WT_HOME

    private static final String WT_HOME
    Deprecated. 

    FILE_SEPARATOR

    private static final String FILE_SEPARATOR
    Deprecated. 

    MAX_CACHE_SIZE

    private static final int MAX_CACHE_SIZE
    Deprecated. 

    TEMPLATE_VERBOSE

    private static final boolean TEMPLATE_VERBOSE
    Deprecated. 

    CACHE_ENABLED

    private static final boolean CACHE_ENABLED
    Deprecated. 

    PROCESS_TIMED

    private static final boolean PROCESS_TIMED
    Deprecated. 

    templateCache

    private static Cache templateCache
    Deprecated. 
    Constructor Detail

    HTMLTemplate

    public HTMLTemplate(String resourceName)
    Deprecated. 
    Construct an HTMLTemplate object with the given resourceName. The resourceName is without an extension. When the best match is searched for, both .html and .htm extensions will be looked for.

    Supported API: true

    Parameters:
    resourceName - The template resource name (without an extension).
    Method Detail

    init

    public void init()
              throws WTException
    Deprecated. 
    Search for the template best matching the server's Locale.

    Supported API: true

    Overrides:
    init in class LocalizedResource
    Throws:
    WTException - Thrown if an IO exception occurs.

    init

    public void init(Locale locale)
              throws WTException
    Deprecated. 
    Search for the template best matching the given Locale.

    Supported API: true

    Overrides:
    init in class LocalizedResource
    Parameters:
    locale - The given Locale.
    Throws:
    WTException - Thrown if there is no file to open.

    init

    public void init(Locale locale,
                     boolean override)
              throws WTException
    Deprecated. 
    Search for the template best matching the given Locale. If a best match is not found, override the default locale with the one given.

    Supported API: true

    Parameters:
    locale - The given Locale.
    override - Boolean flag indicating if the given locale is to override the default locale.
    Throws:
    WTException - Thrown if there is no file to open.

    init

    public void init(Vector preferences)
              throws WTException
    Deprecated. 
    Search for the template best matching the given Locale preferences.

    Supported API: true

    Overrides:
    init in class LocalizedResource
    Parameters:
    preferences - Vector containing the locales to search on.
    Throws:
    WTException - Thrown if there is no file to open.

    getEncoding

    public String getEncoding()
    Deprecated. 
    Get character encoding that should be used when writing text to this templates output stream. The template must already be initialized to bind it to a locale.

    Supported API: true

    Returns:
    String character encoding

    process

    public void process(OutputStream out,
                        Object context)
                 throws WTException
    Deprecated. 
    Call processTemplate with the given OutputStream and context. The InputStream and Locale of the best match template is retrieved from this HTMLTemplate object.

    Supported API: true

    Parameters:
    out - The OutputStream to pass to processTemplate.
    context - The Object context to pass to processTemplate.
    Throws:
    WTException - Thrown if an IOException occurs.

    listBaseTemplates

    public static String[] listBaseTemplates(String resourcePath)
                                      throws WTException
    Deprecated. 
    Get a list of 'base' .html and .htm files in the directory specified by the given resourcePath. Names are returned as resource names minus the .html extension.

    Supported API: true

    Parameters:
    resourcePath - String containing the resource path that that is relative to root directories.
    Returns:
    String array containing the matching resource names.
    Throws:
    WTException - Thrown if an IO Exception occurs.

    closeInput

    public void closeInput()
    Deprecated. 
    Supported API: true


    main

    public static void main(String[] args)
    Deprecated. 
    Supported API: false