org.apache.taglibs.i18n
Class BundleTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by org.apache.taglibs.i18n.BundleTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag

public class BundleTag
extends javax.servlet.jsp.tagext.TagSupport

This class implements an empty tag that allows you to use a resource bundle to internationalize content in a web page. If a specific locale is not provided, the user's locale (language and country) are determined based on the browser settings. The response content-type is automatically set based on the locale.
This tag must be used very early in the page, prior to any html output.

Examples

  <i18n:bundle basename="test"/>
  etc...
  

Author:
Tim Dawson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
BundleTag()
           
 
Method Summary
 int doEndTag()
          Sets the response locale if changeResponseLocale attribute is true
 int doStartTag()
          Called upon invocation of the tag.
protected  java.util.ResourceBundle getBundle()
          Get the bundle created by this bundle tag, used by nested tags.
 void release()
           
 void setBaseName(java.lang.String value)
          Sets the baseName of the bundle that the MessageTags will use when retrieving keys for this page.
 void setChangeResponseLocale(boolean value)
          Specifies whether or not the response locale should be changed to match the locale used by this tag.
 void setDebug(boolean value)
          Set to true to enable debug logging.
 void setLocale(java.util.Locale value)
          Sets the locale of the bundle that the MessageTags will use when retrieving keys for this page.
 void setLocaleAttribute(java.lang.String value)
          Deprecated.  
 void setLocaleRef(java.lang.String value)
          Provides a key to search the page context for in order to get the locale of the bundle that the MessageTags will use when retrieving keys for this page.
 void setScope(java.lang.String value)
          Sets the scope that the bundle will be available to message tags.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BundleTag

public BundleTag()
Method Detail

setBaseName

public final void setBaseName(java.lang.String value)
Sets the baseName of the bundle that the MessageTags will use when retrieving keys for this page.


setDebug

public final void setDebug(boolean value)
Set to true to enable debug logging.


setLocale

public void setLocale(java.util.Locale value)
Sets the locale of the bundle that the MessageTags will use when retrieving keys for this page.


setLocaleAttribute

public void setLocaleAttribute(java.lang.String value)
Deprecated. 

Provides a key to search the page context for in order to get the locale of the bundle that the MessageTags will use when retrieving keys for this page.


setLocaleRef

public void setLocaleRef(java.lang.String value)
Provides a key to search the page context for in order to get the locale of the bundle that the MessageTags will use when retrieving keys for this page.


setScope

public void setScope(java.lang.String value)
              throws javax.servlet.jsp.JspException
Sets the scope that the bundle will be available to message tags. By default page scope is used.

Throws:
javax.servlet.jsp.JspException

setChangeResponseLocale

public void setChangeResponseLocale(boolean value)
Specifies whether or not the response locale should be changed to match the locale used by this tag.


release

public void release()
Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport

getBundle

protected final java.util.ResourceBundle getBundle()
Get the bundle created by this bundle tag, used by nested tags.

Returns:
ResourceBundle bundle

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Called upon invocation of the tag. If an id is specified, sets the bundle into the page context.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Sets the response locale if changeResponseLocale attribute is true

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException


Copyright ? 2000-2004 The Apache Software Foundation. All Rights Reserved.