com.ivata.mask.web.struts.util
Class MessageResourcesHandling

java.lang.Object
  extended bycom.ivata.mask.web.struts.util.MessageResourcesHandling

public final class MessageResourcesHandling
extends java.lang.Object

Methods in this class wrap/extend the message resource system of Struts.

Since:
ivata masks 0.5 (2005-01-20)
Version:
$Revision: 1.3 $
Author:
Colin MacLeod colin.macleod@ivata.com

Field Summary
static java.lang.String FIELD_PREFIX
          This is prepended to fields to get their message resource string.
static java.lang.String SUBMIT_PREFIX
          This is prepended to submit buttons to get their message resource string.
static java.lang.String TITLE_SUFFIX
          This string is appended to field names to find their titles in the message resource bundle.
static java.lang.String VALUE_SUFFIX
          This string is appended to field names to find their values in the message resource bundle.
 
Method Summary
static java.lang.String getDefaultLabel(java.util.Locale locale, java.lang.String bundle, java.lang.String fieldName, java.lang.String labelKey, java.util.List labelArgs, java.lang.String resourceFieldPath, java.lang.String labelKeySuffix, boolean button, boolean mandatory)
          Get the default label for this field.
static java.lang.String getDefaultTitle(java.util.Locale locale, java.lang.String bundle, java.lang.String fieldName, java.lang.String titleKey, java.util.List titleArgs, java.lang.String resourceFieldPath, boolean button, boolean mandatory)
          Get the default title for this field.
static java.lang.String getDefaultValue(java.util.Locale locale, java.lang.String bundle, java.lang.String fieldName, java.lang.String valueKey, java.util.List valueArgs, java.lang.String resourceFieldPath, boolean button, boolean mandatory)
          Get the default value for this field.
static java.lang.String getMessage(java.lang.String bundle, java.util.Locale locale, java.lang.String key, java.util.List argsList)
          This first tries using the bundle you provided.
static java.lang.String getMessage(java.lang.String bundle, java.util.Locale locale, java.lang.String key, java.lang.Object[] args)
          This first tries using the bundle you provided.
static java.lang.String getMessage(java.lang.String bundle, java.lang.String locale, java.lang.String key, java.util.List args)
          This first tries using the bundle you provided.
static java.lang.String getMessage(java.lang.String bundle, java.lang.String locale, java.lang.String key, java.lang.Object[] args)
          This first tries using the bundle you provided.
static org.apache.struts.util.MessageResources getMessages(java.lang.String bundle)
          Get a bundle with the given name.
static boolean isGuessLabel()
           
static void registerMessages(java.lang.String bundle, java.lang.String fullPath)
          Register resources for a given bundle.
static void setGuessLabel(boolean guessLabelParam)
          Refer to #getguessLabel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIELD_PREFIX

public static java.lang.String FIELD_PREFIX
This is prepended to fields to get their message resource string.


SUBMIT_PREFIX

public static java.lang.String SUBMIT_PREFIX
This is prepended to submit buttons to get their message resource string.


TITLE_SUFFIX

public static java.lang.String TITLE_SUFFIX
This string is appended to field names to find their titles in the message resource bundle.


VALUE_SUFFIX

public static java.lang.String VALUE_SUFFIX
This string is appended to field names to find their values in the message resource bundle.

Method Detail

getDefaultLabel

public static java.lang.String getDefaultLabel(java.util.Locale locale,
                                               java.lang.String bundle,
                                               java.lang.String fieldName,
                                               java.lang.String labelKey,
                                               java.util.List labelArgs,
                                               java.lang.String resourceFieldPath,
                                               java.lang.String labelKeySuffix,
                                               boolean button,
                                               boolean mandatory)
                                        throws com.ivata.mask.util.SystemException
Get the default label for this field. If no label key is specifically set, the combination of labelFieldPath + ".label" is tried in the application resources. Failing that, the same is attempted using the default path (defaultPath + ".label").

Parameters:
locale - Refer to MessageResources.getMessage(java.lang.String).
bundle - Refer to MessageResources.getMessage(java.lang.String).
fieldName - name of the field for which to return the title.
labelKey - key used to access the title in the resources. If this is null, a default key is tried.
labelArgs - arguments used in conjunction with the key, in the message resources.
resourceFieldPath - this is the root of the message resource path searched. This is usually specific to an input mask, or a value object.
labelKeySuffix - Some fields have multiple label keys. This suffix is appended to the key when retrieving the localized text from the application resources file.
button - buttons have a different default path to field. true if this field represents a button.
mandatory - if true an exception is thrown if no value is found for this combination.
Returns:
title, if this tag has one, otherwise null.
Throws:
com.ivata.mask.util.SystemException - if the text cannot be retrieved because of a system failure, or if the field is mandatory and cannot be found.

getDefaultTitle

public static java.lang.String getDefaultTitle(java.util.Locale locale,
                                               java.lang.String bundle,
                                               java.lang.String fieldName,
                                               java.lang.String titleKey,
                                               java.util.List titleArgs,
                                               java.lang.String resourceFieldPath,
                                               boolean button,
                                               boolean mandatory)
                                        throws com.ivata.mask.util.SystemException
Get the default title for this field. If no title key is specifically set, the combination of labelFieldPath + ".title" is tried in the application resources. Failing that, the same is attempted using the default path (defaultPath + ".title").

Parameters:
locale - Refer to MessageResources.getMessage(java.lang.String).
bundle - Refer to MessageResources.getMessage(java.lang.String).
fieldName - name of the field for which to return the title.
titleKey - key used to access the title in the resources. If this is null, a default key is tried.
titleArgs - arguments used in conjunction with the key, in the message resources.
resourceFieldPath - this is the root of the message resource path searched. This is usually specific to an input mask, or a value object.
button - buttons have a different default path to field. true if this field represents a button.
mandatory - if true an exception is thrown if no value is found for this combination.
Returns:
title, if this tag has one, otherwise null.
Throws:
com.ivata.mask.util.SystemException - if the text cannot be retrieved because of a system failure, or if the field is mandatory and cannot be found.

getDefaultValue

public static java.lang.String getDefaultValue(java.util.Locale locale,
                                               java.lang.String bundle,
                                               java.lang.String fieldName,
                                               java.lang.String valueKey,
                                               java.util.List valueArgs,
                                               java.lang.String resourceFieldPath,
                                               boolean button,
                                               boolean mandatory)
                                        throws com.ivata.mask.util.SystemException
Get the default value for this field. If no value key is specifically set, the combination of labelFieldPath + ".value" is tried in the application resources. Failing that, the same is attempted using the default path (defaultPath + ".value").

Parameters:
locale - Refer to MessageResources.getMessage(java.lang.String).
bundle - Refer to MessageResources.getMessage(java.lang.String).
fieldName - name of the field for which to return the title.
valueKey - key used to access the title in the resources. If this is null, a default key is tried.
valueArgs - arguments used in conjunction with the key, in the message resources.
resourceFieldPath - this is the root of the message resource path searched. This is usually specific to an input mask, or a value object.
button - buttons have a different default path to field. true if this field represents a button.
mandatory - if true an exception is thrown if no value is found for this combination.
Returns:
title, if this tag has one, otherwise null.
Throws:
com.ivata.mask.util.SystemException - if the text cannot be retrieved because of a system failure, or if the field is mandatory and cannot be found.

getMessage

public static java.lang.String getMessage(java.lang.String bundle,
                                          java.util.Locale locale,
                                          java.lang.String key,
                                          java.util.List argsList)
                                   throws com.ivata.mask.util.SystemException
This first tries using the bundle you provided. If that returns null, it tries again without a bundle.

Parameters:
bundle - Refer to MessageResources.getMessage(java.lang.String).
locale - Refer to MessageResources.getMessage(java.lang.String).
key - Refer to MessageResources.getMessage(java.lang.String).
argsList - Will be converted to an array of objects. Refer to MessageResources.getMessage(java.lang.String).
Returns:
Refer to MessageResources.getMessage(java.lang.String).
Throws:
com.ivata.mask.util.SystemException - Refer to MessageResources.getMessage(java.lang.String).
See Also:
TagUtils.getInstance()

getMessage

public static java.lang.String getMessage(java.lang.String bundle,
                                          java.util.Locale locale,
                                          java.lang.String key,
                                          java.lang.Object[] args)
                                   throws com.ivata.mask.util.SystemException
This first tries using the bundle you provided. If that returns null, it tries again without a bundle.

Parameters:
bundle - Refer to MessageResources.getMessage(java.lang.String).
locale - Refer to MessageResources.getMessage(java.lang.String).
key - Refer to MessageResources.getMessage(java.lang.String).
args - Refer to MessageResources.getMessage(java.lang.String).
Returns:
Refer to MessageResources.getMessage(java.lang.String).
Throws:
com.ivata.mask.util.SystemException - Refer to MessageResources.getMessage(java.lang.String).
See Also:
TagUtils.getInstance()

getMessage

public static java.lang.String getMessage(java.lang.String bundle,
                                          java.lang.String locale,
                                          java.lang.String key,
                                          java.util.List args)
                                   throws com.ivata.mask.util.SystemException
This first tries using the bundle you provided. If that returns null, it tries again without a bundle.

Parameters:
bundle - Refer to MessageResources.getMessage(java.lang.String).
locale - Refer to MessageResources.getMessage(java.lang.String).
key - Refer to MessageResources.getMessage(java.lang.String).
args - Will be converted to an array of objects. Refer to MessageResources.getMessage(java.lang.String).
Returns:
Refer to MessageResources.getMessage(java.lang.String).
Throws:
com.ivata.mask.util.SystemException - Refer to MessageResources.getMessage(java.lang.String).
See Also:
TagUtils.getInstance()

getMessage

public static java.lang.String getMessage(java.lang.String bundle,
                                          java.lang.String locale,
                                          java.lang.String key,
                                          java.lang.Object[] args)
                                   throws com.ivata.mask.util.SystemException
This first tries using the bundle you provided. If that returns null, it tries again without a bundle.

Parameters:
bundle - Refer to MessageResources.getMessage(java.lang.String).
locale - Refer to MessageResources.getMessage(java.lang.String).
key - Refer to MessageResources.getMessage(java.lang.String).
args - Refer to MessageResources.getMessage(java.lang.String).
Returns:
Refer to MessageResources.getMessage(java.lang.String).
Throws:
com.ivata.mask.util.SystemException - Refer to MessageResources.getMessage(java.lang.String).
See Also:
TagUtils.getInstance()

getMessages

public static org.apache.struts.util.MessageResources getMessages(java.lang.String bundle)
                                                           throws com.ivata.mask.util.SystemException
Get a bundle with the given name.

Parameters:
bundle - message resources identifier - see Struts docu.
Returns:
resources message resources instance.
Throws:
com.ivata.mask.util.SystemException - if the message resources are undefined.

isGuessLabel

public static boolean isGuessLabel()
Returns:
Returns the guessLabel.

registerMessages

public static void registerMessages(java.lang.String bundle,
                                    java.lang.String fullPath)
Register resources for a given bundle.

Parameters:
bundle - message resources identifier - see Struts docu.
fullPath - full path to the resources

setGuessLabel

public static void setGuessLabel(boolean guessLabelParam)
Refer to #getguessLabel.

Parameters:
guessLabelParam - Refer to #getguessLabel.


Copyright © 2001-2005 ivata limited. All Rights Reserved.