<i18n:getMessage> Tag

This tag is used in conjunction with the <i18n:localize> tag to retrieve localized static text or messages from a JspMessageBundle for display on a page or in a Portlet.

Setting the default locale: To avoid server errors, make sure that a default locale is set on each machine running WebLogic Server.

Syntax

<tagName attribute="value" />

Attributes

id

Optional (String) - Holds the value of the label (or message) in the JSP. If set, this attribute is the name of the variable to hold the message as a String. If not set, the message is output to the JSP.

messageName

Required (String) - The key for the message bundle.

messageArgs

Optional (Object arguments) - The arguments to the message bundle. If no arguments are provided, it is assumed that static text (not a message) is to be returned.

For example, {"Wednesday", "78"}; might be used to construct the message “Today is Wednesday, and the temperature is 78 degrees Fahrenheit.”

bundleName

Optional (String) - If properly initialized in the <i18n:localize> tag, there is no need to pass this tag attribute unless you want to use a different bundle for a particular tag invocation. For more information on this attribute, see <i18n:localize>.

language

Optional (String) - If properly initialized in the <i18n:localize> tag, there is no need to pass this tag attribute, unless you want to use a different language for a particular tag invocation.

country

Optional (String) - If properly initialized in the <i18n:localize> tag, there is no need to pass this tag attribute, unless you want to use a different country for a particular tag invocation.

variant

Optional (String) - If properly initialized in the <i18n:localize> tag, there is no need to pass this tag attribute, unless you want to use a different variant for a particular tag invocation. The variant is used when localization demands a more specific locale than can be denoted by having just language and a country. For example, two variants for English are U.S. English and U.K. English.

locale

Optional (java.util.Locale) - If properly initialized in the <i18n:localize> tag, there is no need to pass this tag attribute, unless you want to use a different locale (language, country, and variant) for a particular tag invocation.

Example

This example uses two messages ("greeting" and "message") in a resource bundle file called i18nExampleResourceBundle to produce this output:

"Welcome To This Page! 14 out of 100 files have been saved."

<% 
// Definition of a single language preference 
String language = "en"; 
// Creation of message arguments 
Object[] args = new Object[] 
{ 
new Integer(14), 
new Integer(100) 
}; 
%> 
<i18n:localize language="<%=language%>" bundleName="Messages"/>        
<html> 
<body> 
<i18n:getMessage messageName="greeting"/> 
<i18n:getMessage messageName="message" messageArgs="<%=args%>"/>        
</body> 
</html> 

The following code shows the entries in the property file named i18nExampleResourceBundle. properties:

greeting=Welcome To This Page!
message={0} out of {1} files have been saved.

Related Topics

<i18n:localize> Tag

<l10n:forward> Tag

<l10n:include> Tag

<l10n:resolve> Tag