Class LocaleMessage
LocaleMessage objects are typically encountered when working with valueMap configurations that contain localized values using <fmt:message> tags. In server-side code such as DMI methods, these objects allow access to the underlying message keys and localized content.
Common Usage Pattern:
When a field has a valueMap with localized values, the valueMap entries may be LocaleMessage objects rather than simple strings. To safely extract the display value:
Map valueMap = field.getMapProperty("valueMap"); Object value = valueMap.get(someKey); String displayValue; if (value instanceof String) { displayValue = (String) value; } else if (value instanceof LocaleMessage) { // Get the message key - this is the supported approach displayValue = ((LocaleMessage) value).getKey(); }
Important Note: There is no other valid way to use LocaleMessage objects in server-side code. The only supported public API is getKey()
to retrieve the underlying message key. Other methods and internal details of LocaleMessage should not be used directly.
-
Method Summary
Modifier and TypeMethodDescriptiongetKey()
Returns the message key for this LocaleMessage.getMessage
(Locale locale) Returns the localized message for the specified locale.
-
Method Details
-
getMessage
Returns the localized message for the specified locale.Note: For most server-side use cases involving valueMap processing,
getKey()
is the preferred method. This method is intended for internal framework use and specific internationalization scenarios.This method resolves the actual localized text from resource bundles based on the provided locale.
- Parameters:
locale
- the locale for which to retrieve the message- Returns:
- the localized message text, or a fallback representation if the message cannot be resolved
-
getKey
Returns the message key for this LocaleMessage.This is the primary supported method for accessing LocaleMessage content in server-side code. The key represents the identifier used in the <fmt:message> tag or properties file to identify this localized message.
Usage in valueMap processing:
When working with valueMap configurations that contain localized values, this method provides the safe way to extract the message key for further processing:
Object localeMessage = valueMap.get(key.toString()); if (localeMessage != null) { String displayValue = localeMessage instanceof String ? (String) localeMessage : ((LocaleMessage) localeMessage).getKey(); }
- Returns:
- the message key string
-