|
© 2002 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.ResourceBundle | +--java.util.PropertyResourceBundle | +--com.bea.p13n.taglib.i18n.JspMessageBundle
Class to help with retrieving locale-specific messages from within a JSP.
It is rarely necessary to use this class directly, as two JSP tags are provided that page developers will probably find more convenient. See the documentation for <i18n:localize> and <i18n:getMessage>.
Given a JSP's and language, country and variant settings, JspMessageBundle
will follow the search order from ResourceBundle to look for a
properties file containing messages used by the JSP, the only difference
being that it will search for the file as a resource relative to the
JSP's document root. This means you'd specify the
baseBundleName
using "/" instead of ".". For example,
"/jspPages/appPages/mainPageText
" instead of
"jspPages.appPages.mainPageText
". Also, the properties
files serving as resource bundles are relative to the documents they support
or at least on the document root, not on the CLASSPATH
as
with traditional resource bundles. If no baseBundleName
is
provided, it will default to the same name as the calling page.
These differences from traditional resource bundles were done
for convenience in JSP programming.
For example, for a JSP /pages/something.jsp
, language code
"en", country code "US", JspMessageBundle will look for the
properties file in the following order:
/pages/something_en_US.properties
/pages/<repositoryDir>/something_en_US.properties
/pages/something_en.properties
/pages/<repositoryDir>/something_en.properties
/pages/something.properties
/pages/<repositoryDir>/something.properties
/pages/something<default locale>.properties
/pages/<repositoryDir>/something<default locale>.properties
where repositoryDir is a "repository" directory -
a place where common files exist - and "default locale" is "_en_US".
If none of these are found, a
MissingResourceException
will be thrown.
A class-wide cache is kept of all bundle names, languages, countries, variant combinations so that the property file search will not be repeated each time a request is made.
LocalizeTag
,
GetMessageTag
Inner Class Summary | |
protected static class |
JspMessageBundle.MessageBundleKey
Deprecated. Protected internal class used as a key in the JspMessageBundle cache |
Field Summary | |
protected java.lang.String |
baseBundleName
Deprecated. |
Fields inherited from class java.util.ResourceBundle |
parent |
Constructor Summary | |
JspMessageBundle(java.io.InputStream stream,
java.util.Locale theLocale)
Deprecated. |
Method Summary | |
protected static void |
addToCache(java.lang.String uri,
java.lang.String baseBundleName,
java.lang.String language,
java.lang.String country,
java.lang.String variant,
java.util.ResourceBundle bundle)
Deprecated. Add a JspMessageBundle to the cache, keyed by its URI, language, country, and variant. |
protected static java.util.ResourceBundle |
findInCache(java.lang.String uri,
java.lang.String baseBundleName,
java.lang.String language,
java.lang.String country,
java.lang.String variant)
Deprecated. Look for a message bundle for this URI, language, country, variant in the cache. |
static java.util.ResourceBundle |
getBundle(javax.servlet.jsp.PageContext pageContext,
java.lang.String baseBundleName,
java.lang.String language,
java.lang.String country,
java.lang.String variant)
Deprecated. Return a ResourceBundle for this base bundle name, request, language, country, and variant. |
static java.util.ResourceBundle |
getBundle(javax.servlet.jsp.PageContext pageContext,
java.lang.String baseBundleName,
java.lang.String language,
java.lang.String country,
java.lang.String variant,
java.lang.String propCharset)
Deprecated. it is advisable instead to use unicode escaped characters in your ISO-8859-1 encoded property files. Use the version of getBundle() that does not specify a propCharset |
java.util.Locale |
getLocale()
Deprecated. Returns the Locale for this bundle. |
protected static java.lang.String |
getRealURI(javax.servlet.jsp.PageContext pageContext)
Deprecated. Returns the URI for a page correctly, regardless of whether it's being dynamically included in a parent page. |
boolean |
isExpired()
Deprecated. This method returns whether or not this resource bundle has expired or not. |
Methods inherited from class java.util.PropertyResourceBundle |
getKeys,
handleGetObject |
Methods inherited from class java.util.ResourceBundle |
getBundle,
getBundle,
getBundle,
getObject,
getString,
getStringArray,
setParent |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.lang.String baseBundleName
Constructor Detail |
public JspMessageBundle(java.io.InputStream stream, java.util.Locale theLocale) throws java.io.IOException
Method Detail |
public boolean isExpired()
public static java.util.ResourceBundle getBundle(javax.servlet.jsp.PageContext pageContext, java.lang.String baseBundleName, java.lang.String language, java.lang.String country, java.lang.String variant) throws java.util.MissingResourceException
pageContext
- the JSP PageContext
baseBundleName
- a String containing the base name of the message bundle - defaults
to the servlet name in the page context's URIlanguage
- a String containing the desired language of the message bundlecountry
- a String containing the desired country of the message bundlevariant
- a String containing the desired variant of the message bundlepublic static java.util.ResourceBundle getBundle(javax.servlet.jsp.PageContext pageContext, java.lang.String baseBundleName, java.lang.String language, java.lang.String country, java.lang.String variant, java.lang.String propCharset) throws java.util.MissingResourceException
pageContext
- the JSP PageContext
baseBundleName
- a String containing the base name of the message bundle - defaults
to the servlet name in the page context's URIlanguage
- a String containing the desired language of the message bundlecountry
- a String containing the desired country of the message bundlevariant
- a String containing the desired variant of the message bundlepropCharset
- a String containing the character encoding to be
used for reading the property file. For example
"UTF8", "ISO-8859-1", etc. Passing null is
acceptable and causes the ISO-8859-1 encoding to
be used.protected static java.util.ResourceBundle findInCache(java.lang.String uri, java.lang.String baseBundleName, java.lang.String language, java.lang.String country, java.lang.String variant)
protected static void addToCache(java.lang.String uri, java.lang.String baseBundleName, java.lang.String language, java.lang.String country, java.lang.String variant, java.util.ResourceBundle bundle)
public java.util.Locale getLocale()
Locale
for this bundle.
Locale
for this bundleprotected static java.lang.String getRealURI(javax.servlet.jsp.PageContext pageContext)
|
© 2002 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |