Class ChangedTemplate

java.lang.Object
sunlabs.brazil.template.Template
sunlabs.brazil.template.ChangedTemplate
All Implemented Interfaces:
Serializable, TemplateInterface

public class ChangedTemplate extends Template implements Serializable
This Template adds an icon to HREFs to indicate when the file being referred to is new, changed, or unchanged with respect to the user's session.

In order for the ChangedTemplate to work, the following must happen.

  • All files whose HREFs should be rewritten must pass through the ChangedTemplate. All HREFs seen between <changed> and </changed> tags will be rewritten so that an appropriate icon appears next to the HREF.
  • All files whose last-accessed time is being tracked must also pass through this ChangedTemplate. Whenever the ChangedTemplate sees a file that was named in some previously seen <changed> section, that file's last-accessed time will be updated. Only the files named in a <changed> section are tracked.
Warning: The ChangedTemplate may have to keep track of a lot of data per session, specifically, the names of all the files being tracked and the last time the user accessed them.

The ChangedTemplate examines the property "fileName", set (for example) by the FileHandler, in order to update the last-accessed time of a file as it passes by. If the "fileName" property is not set, the last-accessed time will not be updated.

The ChangedTemplate also assumes that all local HREFs it sees can be directly translated into the corresponding file name based on the "root" property and the URL of the current file. Getting that file name is necessary so its last-modified time (on disk) can be compared to its last-accessed time (per session).

The ChangedTemplate uses the following properties:

fileName
A request property containing the full path name of the current file, used to keep track of the last time that file was accessed by the current user. A Handler or other code may set this property if it wishes the file to be tracked.
root
The root of the document hierarchy. An HREF must resolve to a file in this hierarchy so its last-modified time can be checked. If the file does not exist, the HREF will not be rewritten.
always
If this property is present, the ChangedTemplate always rewrites the HREFs, instead of just when they appear within the <changed> and </changed> tags.
new
The HTML to substitute into the document if the HREF refers to a file that has never been accessed by the user. If absent, the HREF for new files will not be rewritten.
changed
The HTML to substitute into the document if the HREF refers to a file that has changed since the last time it was accessed by the user. If absent, the HREF for changed files will not be rewritten.
unchanged
The HTML to substitute into the document if the HREF refers to a file that has not changed since the last time it was accessed by the user. If absent, the HREF for unchanged files will not be rewritten.
Version:
@(#)ChangedTemplate.java 2.1
Author:
Colin Stevens (colin.stevens@sun.com)
See Also: