com.ibm.portal.portlet.service.model
Interface PortletLocalizedContextHome

All Superinterfaces:
LocaleCapable, LocalizedContextHome, PortletService

public interface PortletLocalizedContextHome
extends LocalizedContextHome, PortletService

A home interface for lookups to LocalizedContext instances. To obtain the home instance, a portlet service lookup needs to be performed, e.g.: PortletServiceHome psh;
javax.naming.Context ctx = new javax.naming.InitialContext();
boolean serviceAvailable = false;

try {
psh = (PortletServiceHome) ctx.lookup(PortletLocalizedContextHome.JNDI_NAME);
serviceAvailable = true;
} catch(javax.naming.NameNotFoundException ex) {
... error handling ...
}
...
if (serviceAvailable) {
PortletLocalizedContextHome home = (PortletLocalizedContextHome) psh.getPortletService(PortletLocalizedContextHome.class);
LocalizedContext ctx = home.getLocalizedContext(aRequest);
...
}
Since JNDI lookups may be expensive, it is recommended to store the home instance for reuse, if the service is used repeatedly.

Since:
6.1.0

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ibm.portal.model.LocalizedContextHome
LocalizedContextHome.BASE_TEXT_DIRECTION, LocalizedContextHome.ComparatorFactory
 
Field Summary
static java.lang.String JNDI_NAME
          JNDI name under which the home instance is bound
 
Method Summary
 PortletLocalizedContext getLocalizedContext(javax.portlet.PortletRequest aRequest)
          Returns a context instance which uses the language ranges specified in the given locale enumeration.
 PortletLocalizedContext getLocalizedContext(javax.portlet.PortletRequest aRequest, javax.portlet.MimeResponse aResponse)
          Returns a context instance which uses the language ranges specified in the given locale enumeration.
 ResourceBundleProvider getResourceBundleProvider(javax.portlet.PortletConfig config)
          Loads the ResourceBundleProvider for the given PortletConfig.
 
Methods inherited from interface com.ibm.portal.model.LocalizedContextHome
getAvailableLocales, getBaseTextDirection, getDefaultCollators, getDefaultLocale, getExpandedLocales, getExpandedSupportedLocales, getLocalizedContext, getLocalizedContext, getLocalizedContext, getResourceBundleProvider, getSupportedLocales
 

Field Detail

JNDI_NAME

static final java.lang.String JNDI_NAME
JNDI name under which the home instance is bound

See Also:
Constant Field Values
Method Detail

getLocalizedContext

PortletLocalizedContext getLocalizedContext(javax.portlet.PortletRequest aRequest)
Returns a context instance which uses the language ranges specified in the given locale enumeration.

Parameters:
aRequest - the request for which to return the context instance; the language preference is obtained via the PortletRequest.getLocales() method.
Returns:
a localized context instance working on the language ranges exposed by the request

getLocalizedContext

PortletLocalizedContext getLocalizedContext(javax.portlet.PortletRequest aRequest,
                                            javax.portlet.MimeResponse aResponse)
Returns a context instance which uses the language ranges specified in the given locale enumeration.

Parameters:
aRequest - the request for which to return the context instance; the language preference is obtained via the PortletRequest.getLocales() method.
aResponse - the request for which to return the context instance; the language preference is obtained via the MimeResponse.getLocale() method.
Returns:
a localized context instance working on the language ranges exposed by the request
Since:
6.1.0.3

getResourceBundleProvider

ResourceBundleProvider getResourceBundleProvider(javax.portlet.PortletConfig config)
                                                 throws javax.portlet.UnavailableException
Loads the ResourceBundleProvider for the given PortletConfig. This method can be used inside the Portlet.init(PortletConfig) method to preload resource bundles and to find out about the set of supported locales for the bundle. Refer to LocalizedContextHome.getResourceBundleProvider(String, ClassLoader) for more information.

Parameters:
config - the config to load the provider for
Returns:
the resource bundle provider, not null
Throws:
javax.portlet.UnavailableException - if the portlet it not available