org.displaytag.localization
Class I18nJstlAdapter

java.lang.Object
  extended byorg.displaytag.localization.I18nJstlAdapter
All Implemented Interfaces:
I18nResourceProvider, LocaleResolver

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

JSTL implementation of a resource provider and locale resolver. It will make the titleKey attribute of column tag works the same as fmt:message's key property. This tag must be the descendant of a fmt:bundle tag in order to use the titleKey. This is just a shortcut, which makes

 <display:column titleKey="bar"/>
 
behave the same as
 <c:set var="foo">
   <fmt:message key="bar"/>
 </c:set>
 <display:column title="${foo}"/>
 
If you don't define either titleKey or titleKey property on your column, first the tag will attempt to look up the property property in your ResourceBundle. Failing that, it will fall back to the parent class's behavior of just using the property name.

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

Field Summary
static java.lang.String UNDEFINED_KEY
          prefix/suffix for missing entries.
 
Constructor Summary
I18nJstlAdapter()
          Instantiates a new I18nJstlAdapter.
 
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

I18nJstlAdapter

public I18nJstlAdapter()
Instantiates a new I18nJstlAdapter. Throw a NoClassDefFound error if BundleSupport is not available.

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-2005 the Displaytag team. All Rights Reserved.