org.apache.turbine.util.template
Class TemplatePageAttributes

java.lang.Object
  |
  +--org.apache.turbine.util.template.TemplatePageAttributes
All Implemented Interfaces:
ApplicationTool

public class TemplatePageAttributes
extends java.lang.Object
implements ApplicationTool

Template context tool that will set various attributes of the HTML page. It is automatically placed in the Template context as '$page'. Here's an example of some uses:

$page.setBgColor("#ffffff"); $page.setBgColor("white"); $page.setBackground("/images/standardbg.jpeg"); $page.setTitle("This is the title!"); $page.setKeywords("turbine, cool, servlet framework"); $page.setStyleSheet("/style.css");

Version:
$Id: TemplatePageAttributes.java,v 1.3 2002/07/11 16:53:19 mpoeschl Exp $
Author:
Sean Legassick

Constructor Summary
TemplatePageAttributes()
          Default constructor.
TemplatePageAttributes(RunData data)
          Construct a new instance with the given RunData object.
 
Method Summary
 TemplatePageAttributes addAttribute(java.lang.String name, java.lang.String value)
          Adds an attribute to the BODY tag.
 java.lang.String getTitle()
          Get the title in the page.
 void init(java.lang.Object data)
          Initialise this instance with the given RunData object.
 void refresh()
          Refresh method - does nothing
 TemplatePageAttributes setBackground(java.lang.String url)
          Set the background image for the BODY tag.
 TemplatePageAttributes setBgColor(java.lang.String color)
          Set the background color for the BODY tag.
 TemplatePageAttributes setDescription(java.lang.String description)
          Add a description META tag to the HEAD of the page.
 TemplatePageAttributes setHttpEquiv(java.lang.String httpEquiv, java.lang.String content)
          Sets a HttpEquiv META tag in the HEAD of the page, usage:
setHttpEquiv("refresh", "5; URL=http://localhost/nextpage.html")
setHttpEquiv("Expires", "Tue, 20 Aug 1996 14:25:27 GMT")
 TemplatePageAttributes setKeywords(java.lang.String keywords)
          Set a keywords META tag in the HEAD of the page.
 TemplatePageAttributes setLinkColor(java.lang.String color)
          Set the link color for the BODY tag.
 TemplatePageAttributes setStyleSheet(java.lang.String url)
          Adds a LINK to a CSS styleshet to the HEAD of the page.
 TemplatePageAttributes setTextColor(java.lang.String color)
          Set the text color for the BODY tag.
 TemplatePageAttributes setTitle(java.lang.String intitle)
          Set the title in the page.
 TemplatePageAttributes setVlinkColor(java.lang.String color)
          Set the visited link color for the BODY tag.
 java.lang.String toString()
          A dummy toString method that returns an empty string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TemplatePageAttributes

public TemplatePageAttributes()
Default constructor. The init method must be called before use

TemplatePageAttributes

public TemplatePageAttributes(RunData data)
Construct a new instance with the given RunData object.
Parameters:
data - a RunData instance
Method Detail

init

public void init(java.lang.Object data)
Initialise this instance with the given RunData object. (ApplicationTool method)
Specified by:
init in interface ApplicationTool
Parameters:
data - Assumed to be a RunData instance

refresh

public void refresh()
Refresh method - does nothing
Specified by:
refresh in interface ApplicationTool

setTitle

public TemplatePageAttributes setTitle(java.lang.String intitle)
Set the title in the page. This returns an empty String so that the template doesn't complain about getting a null return value.
Parameters:
intitle - A String with the title.

getTitle

public java.lang.String getTitle()
Get the title in the page. This returns an empty String if empty so that the template doesn't complain about getting a null return value.
Returns:
A String with the title.

setStyleSheet

public TemplatePageAttributes setStyleSheet(java.lang.String url)
Adds a LINK to a CSS styleshet to the HEAD of the page.
Parameters:
url - A String.
Returns:
A TemplatePageAttributes (self).

setKeywords

public TemplatePageAttributes setKeywords(java.lang.String keywords)
Set a keywords META tag in the HEAD of the page.
Parameters:
keywords - A String.
Returns:
A TemplatePageAttributes (self).

setHttpEquiv

public TemplatePageAttributes setHttpEquiv(java.lang.String httpEquiv,
                                           java.lang.String content)
Sets a HttpEquiv META tag in the HEAD of the page, usage:
setHttpEquiv("refresh", "5; URL=http://localhost/nextpage.html")
setHttpEquiv("Expires", "Tue, 20 Aug 1996 14:25:27 GMT")
Parameters:
httpEquiv - The value to use for the http-equiv attribute.
content - The text for the content attribute of the meta tag.
Returns:
A TemplatePageAttributes (self).

setDescription

public TemplatePageAttributes setDescription(java.lang.String description)
Add a description META tag to the HEAD of the page.
Parameters:
description - A String.
Returns:
A TemplatePageAttributes (self).

setBackground

public TemplatePageAttributes setBackground(java.lang.String url)
Set the background image for the BODY tag.
Parameters:
url - A String.
Returns:
A TemplatePageAttributes (self).

setBgColor

public TemplatePageAttributes setBgColor(java.lang.String color)
Set the background color for the BODY tag. You can use either color names or color values (e.g. "white" or "#ffffff" or "ffffff").
Parameters:
color - A String.
Returns:
A TemplatePageAttributes (self).

setTextColor

public TemplatePageAttributes setTextColor(java.lang.String color)
Set the text color for the BODY tag. You can use either color names or color values (e.g. "white" or "#ffffff" or "ffffff").
Parameters:
color - A String.
Returns:
A TemplatePageAttributes (self).

setLinkColor

public TemplatePageAttributes setLinkColor(java.lang.String color)
Set the link color for the BODY tag. You can use either color names or color values (e.g. "white" or "#ffffff" or "ffffff").
Parameters:
color - A String.
Returns:
A TemplatePageAttributes (self).

setVlinkColor

public TemplatePageAttributes setVlinkColor(java.lang.String color)
Set the visited link color for the BODY tag.
Parameters:
color - A String.
Returns:
A TemplatePageAttributes (self).

addAttribute

public TemplatePageAttributes addAttribute(java.lang.String name,
                                           java.lang.String value)
Adds an attribute to the BODY tag.
Parameters:
name - A String.
value - A String.
Returns:
A TemplatePageAttributes (self).

toString

public java.lang.String toString()
A dummy toString method that returns an empty string.
Overrides:
toString in class java.lang.Object
Returns:
An empty String ("").


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.