DeclareBundle Class
- public class DeclareBundle
extends AbstractBaseTag
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 java.util.Locale
specified. 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 Sun's Java documentation at 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 look-up the message
matching the Locale specified on the tag. Bundle binding expressions can be
used in any data bindable <netui...> tag attribute.
It is possible to have keys that contain multiple words separated by spaces,
commas, or periods. If this is the case, then you must use slightly different
syntax to reference those keys in your data binding statement. The following
list illustrates three ways to access the key My helloWorld
from the someMessages
property file:
<netui:label value="{bundle.someMessages['My helloWorld']}"/>
<netui:label value='{bundle.someMessages["My helloWorld"]}'/>
<netui:label value="{bundle.someMessages[\"My helloWorld\"]}"/>
WebLogic Workshop automatically generates the last example listed above when
you set the label control in the property editor to bundle.someMessages["My
helloWorld"]
. In all three cases, you WebLogic Workshop can successfully
retrieve the multi-word key.
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:
- country, language, variant
- country, language
- country
Any other combinations will throw an exception.
Attribute Descriptions |
Attribute | Required | Runtime Expression Evaluation | Data Bindable |
bundlePath | No | No | No |
The path to a package in classpath that contains a set of
ResourceBundle properties files. This can be a slash or dot delimited classpath.
Valid values might be:
com/foobar/resources/WebAppProperties
com.foobar.resources.WebAppProperties
These are treated as equivalent values. The ResourceBundle class
will handle appending the .properties file type and locale information
as necessary. For details about the .properties file naming conventions,
see ResourceBundle.getBundle(String, Locale, ClassLoader) . These files must be
available in classpath for the webapp in order to be successfully located. |
country | No | No | Yes |
The two-letter uppercase ISO-3166 country / region code for the Locale
from which to look-up resource bundle messages. This value is used to further specify the name
of the .properties file from which message keys will be read. |
language | No | No | Yes |
The two-letter lowercase ISO-639 language code for the Locale from which
to look-up resource bundle messages. This value is used to further specify the name of
the .properties file from which message keys will be read. |
name | No | No | No |
The name inside of the bundle databinding context under which
the properties in this bundle are available. The identifier default is an illegal value
for this attribute and is reserved for use by this tag. |
variant | No | No | Yes |
A vendor / browser specific code for further parameterizign the Locale
from which to look-up resource bundle messages. |
Related Topics
ResourceBundle
Locale
-
Hierarchy
-
Object
TagSupport
BodyTagSupport
AbstractBaseTag
DeclareBundle
-
All Implemented Interfaces
-
BodyTag
, IterationTag
, Serializable
, Tag
Fields from com.bea.wlw.netui.tags.AbstractBaseTag |
ATTR_GENERAL , ATTR_GENERAL_EXPRESSION , ATTR_JAVASCRIPT , ATTR_STYLE , CLASS , ID , JAVASCRIPT_STATUS , NAME , NETUI_UNIQUE_CNT , ONCLICK , ONDBLCLICK , ONKEYDOWN , ONKEYPRESS , ONKEYUP , ONMOUSEDOWN , ONMOUSEMOVE , ONMOUSEOUT , ONMOUSEOVER , ONMOUSEUP , STYLE , TABINDEX
|
public int |
-
doEndTag ()
- Register a ResourceBundle that is available for the scope of this page.
|
public int |
-
doStartTag ()
- Start the JSP rendering lifecycle for this tag; it skips its body.
|
public String |
-
getBundlePath ()
- Get the path to the resource bundle's properties files.
|
public String |
-
getCountry ()
- Get the country to use when looking-up resource bundle messages.
|
public String |
-
getLanguage ()
- Get the language to use when looking-up resource bundle messages.
|
public String |
-
getName ()
- Get the name via which this bundles messages can be accessed using the
bundle databinding context.
|
public String |
-
getTagName ()
- Get the name of this tag.
|
public String |
-
getVariant ()
- Get the variant to use when looking-up resource bundle messages.
|
protected void |
-
localRelease ()
- Reset all of the fields of this tag.
|
public void |
-
setBundlePath (String bundlePath)
- Set the path to the resource bundle's properties files.
|
public void |
-
setCountry (String country)
- Set the country to use when looking-up resource bundle messages.
|
public void |
-
setLanguage (String language)
- Set the language to use when looking-up resource bundle messages.
|
public void |
-
setName (String name)
- Set the name via which this bundle can be accessed using the
bundle
databinding context.
|
public void |
-
setVariant (String variant)
- Set the vendor / browser specific code that further parameterizes the
.properties file messages will be read from.
|
Methods from com.bea.wlw.netui.tags.AbstractBaseTag |
addTagIdMapping , evaluateAttributeToString , filter , filter , getJavaScriptUtils , getNearestForm , getScriptReporter , getUserLocale , registerTagError , release , renderAttribute , rewriteName , write
|
Methods from javax.servlet.jsp.tagext.TagSupport |
doAfterBody, doEndTag, doStartTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue |
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DeclareBundle
public DeclareBundle()
doEndTag() Method
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.
-
Overrides
-
BodyTagSupport.doEndTag()
Returns
-
Tag.EVAL_PAGE
Exceptions
-
JspException
- if error conditions are encountered during this method which can not
be reported in the page.
doStartTag() Method
public int doStartTag()
Start the JSP rendering lifecycle for this tag; it skips its body.
-
Overrides
-
BodyTagSupport.doStartTag()
Returns
-
Tag.SKIP_BODY
getBundlePath() Method
public String
getBundlePath()
Get the path to the resource bundle's properties files.
Returns
- the bundle path
getCountry() Method
public String
getCountry()
Get the country to use when looking-up resource bundle messages.
Returns
- the country code
getLanguage() Method
public String
getLanguage()
Get the language to use when looking-up resource bundle messages.
Returns
- the language code
getName() Method
public String
getName()
Get the name via which this bundles messages can be accessed using the
bundle
databinding context.
Returns
- String the name of the bundle
getTagName() Method
public String
getTagName()
Get the name of this tag. This is used to identify the type of this tag
for reporting tag errors.
-
Overrides
-
AbstractBaseTag.getTagName()
Returns
- a constant String representing the name of this tag.
getVariant() Method
public String
getVariant()
Get the variant to use when looking-up resource bundle messages.
Returns
- the variant
localRelease() Method
protected void localRelease()
Reset all of the fields of this tag.
-
Overrides
-
AbstractBaseTag.localRelease()
setBundlePath(String) Method
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:
- com/foobar/resources/WebAppProperties
- com.foobar.resources.WebAppProperties
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.
setCountry(String) Method
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
setLanguage(String) Method
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.
setName(String) Method
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
setVariant(String) Method
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