sunlabs.brazil.template
Class ChangedTemplate

java.lang.Object
  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.template.ChangedTemplate (view source)
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.

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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class sunlabs.brazil.template.Template
debug
 
Constructor Summary
ChangedTemplate()
           
 
Method Summary
 boolean done(RewriteContext hr)
          Called after all tags have been processed, one final chance.
 boolean init(RewriteContext hr)
          Records that this file has just been accessed.
 void tag_a(RewriteContext hr)
           
 void tag_changed(RewriteContext hr)
           
 void tag_slash_changed(RewriteContext hr)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangedTemplate

public ChangedTemplate()
Method Detail

init

public boolean init(RewriteContext hr)
Records that this file has just been accessed.

Specified by:
init in interface TemplateInterface
Overrides:
init in class Template

done

public boolean done(RewriteContext hr)
Description copied from class: Template
Called after all tags have been processed, one final chance.

Specified by:
done in interface TemplateInterface
Overrides:
done in class Template

tag_changed

public void tag_changed(RewriteContext hr)

tag_slash_changed

public void tag_slash_changed(RewriteContext hr)

tag_a

public void tag_a(RewriteContext hr)

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.