wicket
Class Localizer

java.lang.Object
  extended bywicket.Localizer

public class Localizer
extends java.lang.Object

Utility class that encapsulates all of the localization related functionality in a way that is can be accessed by all areas of the framework in a consistent way. A singleton instance of this class is available via the Application object.

Author:
Chris Turner
See Also:
Application.getLocalizer()

Constructor Summary
Localizer(Application application)
          Create the utils instance class backed by the configuration information contained within the supplied settings object.
 
Method Summary
 java.lang.String getString(java.lang.String key, Component component)
           
 java.lang.String getString(java.lang.String key, Component component, IModel model)
           
 java.lang.String getString(java.lang.String key, Component component, IModel model, java.util.Locale locale, java.lang.String style, java.lang.String defaultValue)
          Get the localized string using all of the supplied parameters.
 java.lang.String getString(java.lang.String key, Component component, IModel model, java.lang.String defaultValue)
          Get the localized string for the given component.
 java.lang.String getString(java.lang.String key, Component component, java.lang.String defaultValue)
          Get the localized string for the given component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Localizer

public Localizer(Application application)
Create the utils instance class backed by the configuration information contained within the supplied settings object.

Parameters:
application - The application to localize for
Method Detail

getString

public java.lang.String getString(java.lang.String key,
                                  Component component)
                           throws java.util.MissingResourceException
Parameters:
key - The key to obtain the resource for
component - The component to get the resource for (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown
See Also:
getString(String, Component, String)

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  IModel model)
                           throws java.util.MissingResourceException
Parameters:
key - The key to obtain the resource for
component - The component to get the resource for (optional)
model - The model to use for OGNL substitutions in the strings (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown
See Also:
getString(String, Component, IModel, String)

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  IModel model,
                                  java.util.Locale locale,
                                  java.lang.String style,
                                  java.lang.String defaultValue)
                           throws java.util.MissingResourceException
Get the localized string using all of the supplied parameters. This method is left public to allow developers full control over string resource loading. However, it is recommended that one of the other convenience methods in the class are used as they handle all of the work related to obtaining the current user locale and style information.

Parameters:
key - The key to obtain the resource for
component - The component to get the resource for (optional)
model - The model to use for OGNL substitutions in the strings (optional)
locale - The locale to get the resource for (optional)
style - The style to get the resource for (optional) (see Session)
defaultValue - The default value (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  IModel model,
                                  java.lang.String defaultValue)
                           throws java.util.MissingResourceException
Get the localized string for the given component. The component may be null in which case the component string resource loader will not be used. It the component is not null then it must be a component that has already been added to a page, either directly or via a parent container. The locale and style are obtained from the current user session. If the model is not null then OGNL substitution will be carried out on the string, using the object contained within the model.

Parameters:
key - The key to obtain the resource for
component - The component to get the resource for (optional)
model - The model to use for OGNL substitutions in the strings (optional)
defaultValue - The default value (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  java.lang.String defaultValue)
                           throws java.util.MissingResourceException
Get the localized string for the given component. The component may be null in which case the component string resource loader will not be used. It the component is not null then it must be a component that has already been added to a page, either directly or via a parent container. The locale and style are obtained from the current user session.

Parameters:
key - The key to obtain the resource for
component - The component to get the resource for (optional)
defaultValue - The default value (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown


Copyright © 2004-2005 Wicket developers. All Rights Reserved.