com.dotmarketing.viewtools
Class MessagesTools

java.lang.Object
  extended by MessageResourcesTool
      extended by com.dotmarketing.viewtools.MessagesTools

public class MessagesTools
extends MessageResourcesTool

View tool that provides methods to render Struts application resources for internationalized text.

 
  Template example(s):
    #if( $text.exists('greeting') )
      $text.greeting
    #end
 
  Toolbox configuration:
  <tool>
    <key>text</key>
    <scope>request</scope>
    <class>org.apache.velocity.tools.struts.MessageTool</class>
  </tool>
  
 

This tool should only be used in the request scope.

Since:
VelocityTools 1.0
Version:
$Id: MessagesTools.java,v 1.3 2005/02/08 15:28:07 will Exp $
Author:
Gabe Sidler

Constructor Summary
MessagesTools()
          Default constructor.
 
Method Summary
 boolean exists(java.lang.String key)
          Checks if a message string for a specified message key exists for the user's locale.
 boolean exists(java.lang.String key, java.lang.String bundle)
          Checks if a message string for a specified message key exists for the user's locale.
 java.lang.String get(java.lang.String key)
          Looks up and returns the localized message for the specified key.
 java.lang.String get(java.lang.String key, java.util.List args)
          Same as get(String key, Object[] args), but takes a java.util.List instead of an array.
 java.lang.String get(java.lang.String key, java.lang.Object[] args)
          Looks up and returns the localized message for the specified key.
 java.lang.String get(java.lang.String key, java.lang.String bundle)
          Looks up and returns the localized message for the specified key.
 java.lang.String get(java.lang.String key, java.lang.String bundle, java.util.List args)
          Same as get(String key, Object[] args), but takes a java.util.List instead of an array.
 java.lang.String get(java.lang.String key, java.lang.String bundle, java.lang.Object[] args)
          Looks up and returns the localized message for the specified key.
 java.util.Locale getLocale()
          Deprecated. This does not fit the purpose of MessageTool and will be removed in VelocityTools 1.2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessagesTools

public MessagesTools()
Default constructor. Tool must be initialized before use.

Method Detail

get

public java.lang.String get(java.lang.String key)
Looks up and returns the localized message for the specified key. The user's locale is consulted to determine the language of the message.

Parameters:
key - message key
Returns:
the localized message for the specified key or null if no such message exists

get

public java.lang.String get(java.lang.String key,
                            java.lang.String bundle)
Looks up and returns the localized message for the specified key. The user's locale is consulted to determine the language of the message.

Parameters:
key - message key
bundle - The bundle name to look for.
Returns:
the localized message for the specified key or null if no such message exists
Since:
VelocityTools 1.1

get

public java.lang.String get(java.lang.String key,
                            java.lang.Object[] args)
Looks up and returns the localized message for the specified key. Replacement parameters passed with args are inserted into the message. The user's locale is consulted to determine the language of the message.

Parameters:
key - message key
args - replacement parameters for this message
Returns:
the localized message for the specified key or null if no such message exists

get

public java.lang.String get(java.lang.String key,
                            java.lang.String bundle,
                            java.lang.Object[] args)
Looks up and returns the localized message for the specified key. Replacement parameters passed with args are inserted into the message. The user's locale is consulted to determine the language of the message.

Parameters:
key - message key
bundle - The bundle name to look for.
args - replacement parameters for this message
Returns:
the localized message for the specified key or null if no such message exists
Since:
VelocityTools 1.1

get

public java.lang.String get(java.lang.String key,
                            java.util.List args)
Same as get(String key, Object[] args), but takes a java.util.List instead of an array. This is more Velocity friendly.

Parameters:
key - message key
args - replacement parameters for this message
Returns:
the localized message for the specified key or null if no such message exists

get

public java.lang.String get(java.lang.String key,
                            java.lang.String bundle,
                            java.util.List args)
Same as get(String key, Object[] args), but takes a java.util.List instead of an array. This is more Velocity friendly.

Parameters:
key - message key
bundle - The bundle name to look for.
args - replacement parameters for this message
Returns:
the localized message for the specified key or null if no such message exists
Since:
VelocityTools 1.1

exists

public boolean exists(java.lang.String key)
Checks if a message string for a specified message key exists for the user's locale.

Parameters:
key - message key
Returns:
true if a message strings exists, false otherwise

exists

public boolean exists(java.lang.String key,
                      java.lang.String bundle)
Checks if a message string for a specified message key exists for the user's locale.

Parameters:
key - message key
bundle - The bundle name to look for.
Returns:
true if a message strings exists, false otherwise
Since:
VelocityTools 1.1

getLocale

public java.util.Locale getLocale()
Deprecated. This does not fit the purpose of MessageTool and will be removed in VelocityTools 1.2

Returns the user's locale. If a locale is not found, the default locale is returned.



Copyright © 2006 Dotmarketing, Inc. All Rights Reserved.