org.apache.beehive.netui.tags.databinding.bundle
Class DeclareBundle

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
              extended by DeclareBundle
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, TryCatchFinally, INetuiTag

public class DeclareBundle
extends AbstractClassicTag
implements TryCatchFinally

A tag used to declare a ResourceBundle that can be used inside of the declaring page as a source for displaying internationalized messages. The declared resource bundle is accessible using the bundle databinding context. The required name attribute specifies the identifier via which to refer to the ResourceBundle in an expression. For example:

 <netui-data:declareBundle name="someMessages" bundlePath="com/foobar/resources/WebAppMessages"/>
 

This tag declares a bundle that is referenced in a data binding expression as {bundle.someMessages}.

The bundle that is referenced depends on the Locale specified, see below. The resource bundle properties files that are accessed are located in the package com/foobar/resources with the root properties file name of WebAppMessages. The naming conventions for properties can be found in ResourceBundle.getBundle(String, Locale, ClassLoader). These files must be located in a classpath that is available to the web application. Often, they are stored in WEB-INF/classes. If the properties file contains a key called helloWorld, then the expression {bundle.someMessages.helloWorld} would be look-up the message matching the Locale specified on the tag. Bundle binding expressions can be used in any expression bindable NetUI tag attribute.

Note, the name default is a bundle identifier that is reserved for use by the DeclareBundle tag. If this value is used for the name attribute on a DeclareBundle tag, an error will be reported in the page. The default bundle is reserved for use when accessing internationalized messages from the "current" Struts module's default properties file.

This tag provides a high level of customizability for rendering internationalized messages. Specifically, the Locale for which to look-up messages can be specified on the DeclareBundle tag. By default, the Locale for the current request is used, but this Locale can be overridden by setting the language, country, and variant tag attributes as necessary. See Locale for more information on the possible values for these attributes.

The Locale can be overridden by setting these attributes in three combinations:

Any other combinations will throw an exception.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
DeclareBundle()
           
 
Method Summary
 void doCatch(Throwable t)
           
 int doEndTag()
          Register a ResourceBundle that is available for the scope of this page.
 void doFinally()
           
 int doStartTag()
          Start the JSP rendering lifecycle for this tag; it skips its body.
 String getTagName()
          Get the name of this tag.
protected  void localRelease()
          Reset all of the fields of this tag.
 void setBundlePath(String bundlePath)
          Set the path to the resource bundle's properties files.
 void setCountry(String country)
          Set the country to use when looking-up resource bundle messages.
 void setLanguage(String language)
          Set the language to use when looking-up resource bundle messages.
 void setName(String name)
          Set the name via which this bundle can be accessed using the bundle databinding context.
 void setVariant(String variant)
          Set the vendor / browser specific code that further parameterizes the .properties file messages will be read from.
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getIdForTagId, getNamingChain, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Constructor Detail

DeclareBundle

public DeclareBundle()
Method Detail

getTagName

public String getTagName()
Get the name of this tag. This is used to identify the type of this tag for reporting tag errors.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractClassicTag
Returns:
a constant String representing the name of this tag.

setLanguage

public void setLanguage(String language)
Set the language to use when looking-up resource bundle messages. This value is used to further specify the name of the .properties file message keys will be read from.

Parameters:
language - the two-letter lowercase ISO-639 code for a language.

setCountry

public void setCountry(String country)
Set the country to use when looking-up resource bundle messages. This value is used to further specify the name of the .properties file message keys will be read from.

Parameters:
country - the two-letter uppercase ISO-3166 code for a country

setVariant

public void setVariant(String variant)
Set the vendor / browser specific code that further parameterizes the .properties file messages will be read from.

Parameters:
variant - the variant

setName

public void setName(String name)
Set the name via which this bundle can be accessed using the bundle databinding context. The identifier default is an illegal value for this attribute and is reserved for use by this tag.

Parameters:
name - the name of the bundle

setBundlePath

public void setBundlePath(String bundlePath)
Set the path to the resource bundle's properties files. This can be a slash or dot delimited classpath. Valid values might be: These are treated as equivalent values. The ResourceBundle class will handle appending the .properties file type and locale information as necessary. See ResourceBundle.getBundle(String, Locale, ClassLoader) for the .properties file naming conventions. These files must be available in classpath for the webapp in order to be successfully located.

Parameters:
bundlePath - the path to the bundle's properties files.

doStartTag

public int doStartTag()
Start the JSP rendering lifecycle for this tag; it skips its body.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Returns:
Tag.SKIP_BODY

doEndTag

public int doEndTag()
             throws JspException
Register a ResourceBundle that is available for the scope of this page. Errors raised during the execution of this tag will be reported in the page, which will continue rendering.

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Returns:
Tag.EVAL_PAGE
Throws:
JspException - if error conditions are encountered during this method which can not be reported in the page.

doFinally

public void doFinally()
Specified by:
doFinally in interface TryCatchFinally

doCatch

public void doCatch(Throwable t)
             throws Throwable
Specified by:
doCatch in interface TryCatchFinally
Throws:
Throwable

localRelease

protected void localRelease()
Reset all of the fields of this tag.

Overrides:
localRelease in class AbstractClassicTag