org.displaytag.localization
Class I18nStrutsAdapter

java.lang.Object
  extended by org.displaytag.localization.I18nStrutsAdapter
All Implemented Interfaces:
I18nResourceProvider, LocaleResolver

public class I18nStrutsAdapter
extends java.lang.Object
implements I18nResourceProvider, LocaleResolver

Struts implementation of a resource provider and locale resolver. Uses Struts RequestUtils.getUserLocale() and TagUtils.message() for the lookup.

Version:
$Revision: 1081 $ ($Author: fgiust $)
Author:
Fabrizio Giustina

Field Summary
static java.lang.String UNDEFINED_KEY
          prefix/suffix for missing entries.
 
Constructor Summary
I18nStrutsAdapter()
           
 
Method Summary
 java.lang.String getResource(java.lang.String resourceKey, java.lang.String defaultValue, javax.servlet.jsp.tagext.Tag tag, javax.servlet.jsp.PageContext pageContext)
          Returns a localized String.
 java.util.Locale resolveLocale(javax.servlet.http.HttpServletRequest request)
          Returns the Locale choosen for the given request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED_KEY

public static final java.lang.String UNDEFINED_KEY
prefix/suffix for missing entries.

See Also:
Constant Field Values
Constructor Detail

I18nStrutsAdapter

public I18nStrutsAdapter()
Method Detail

resolveLocale

public java.util.Locale resolveLocale(javax.servlet.http.HttpServletRequest request)
Description copied from interface: LocaleResolver
Returns the Locale choosen for the given request.

Specified by:
resolveLocale in interface LocaleResolver
Parameters:
request - HttpServletRequest
Returns:
a valid Locale (null should never be returned)
See Also:
LocaleResolver.resolveLocale(HttpServletRequest)

getResource

public java.lang.String getResource(java.lang.String resourceKey,
                                    java.lang.String defaultValue,
                                    javax.servlet.jsp.tagext.Tag tag,
                                    javax.servlet.jsp.PageContext pageContext)
Description copied from interface: I18nResourceProvider
Returns a localized String. A resource provider is free to use both resourceKey or defaultValue for the lookup. For example in column titles defaultValue is the value of the property attribute and can be used as a default if titleKey is not specified.

Specified by:
getResource in interface I18nResourceProvider
Parameters:
resourceKey - used-specified resource key
defaultValue - default or fallback value
tag - calling tag (TableTag), which can be used to find needed ancestor tags
pageContext - jsp page context
Returns:
localized String.
See Also:
I18nResourceProvider.getResource(String, String, Tag, PageContext)


Copyright © 2002-2007 the Displaytag team. All Rights Reserved.