Home » cocoon-2.1.11-src » org.apache.cocoon.acting » [javadoc | source]
org.apache.cocoon.acting
public class: LocaleAction [javadoc | source]
java.lang.Object
   org.apache.avalon.framework.logger.AbstractLogEnabled
      org.apache.cocoon.acting.AbstractAction
         org.apache.cocoon.acting.ServiceableAction
            org.apache.cocoon.acting.LocaleAction

All Implemented Interfaces:
    org.apache.avalon.framework.thread.ThreadSafe, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.service.Serviceable, Action

An action that locates and provides to the pipeline locale information looked up in a range of ways.

Configuration

A sample configuration (given in the <map:matchers> section of the sitemap) is given below. This configuration shows default values.

<map:action name="locale" src="org.apache.cocoon.acting.LocaleAction">
<locale-attribute>locale</locale-attribute>
<use-locale>true</use-locale>
<default-locale language="en" country="US"/>
<store-in-request>false<store-in-request>
<create-session>false<create-session>
<store-in-session>false<store-in-session>
<store-in-cookie>false<store-in-cookie>
</map:action>

Above configuration parameters mean:

Usage

This action will be used in a pipeline like so:

<map:act type="locale">
<map:generate src="file_{language}_{country}_{variant}.xml"/>
...
</map:match>

or

<map:act type="locale">
<map:generate src="file_{locale}.xml"/>
...
</map:match>

Locale Identification

Locales will be tested in following order:

First found locale will be returned.

Sitemap Variables

Once locale has been found, the following sitemap variables will be available to sitemap elements contained within the action:

Field Summary
public static final  String LOCALE    Default locale attribute name. 
public static final  String LOCALE_ATTR    Configuration element name for locale attribute name. 
public static final  String STORE_REQUEST    Constant representing the request storage configuration attribute 
public static final  String CREATE_SESSION    Constant representing the session creation configuration attribute 
public static final  String STORE_SESSION    Constant representing the session storage configuration attribute 
public static final  String STORE_COOKIE    Constant representing the cookie storage configuration attribute 
Fields inherited from org.apache.cocoon.acting.ServiceableAction:
manager
Fields inherited from org.apache.cocoon.acting.AbstractAction:
EMPTY_MAP
Method from org.apache.cocoon.acting.LocaleAction Summary:
act,   configure,   getLocaleAttribute
Methods from org.apache.cocoon.acting.ServiceableAction:
service
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.cocoon.acting.LocaleAction Detail:
 public Map act(Redirector redirector,
    SourceResolver resolver,
    Map objectModel,
    String source,
    Parameters params) throws Exception 
    Action which obtains the current environments locale information, and places it in the objectModel (and optionally in a session/cookie).
 public  void configure(Configuration config) throws ConfigurationException 
    Configure this action.
 public static String getLocaleAttribute(Map objectModel,
    String localeAttrName) 
Deprecated! See - I18nUtils.findLocale

    Helper method to retreive the attribute value containing locale information. See class documentation for locale determination algorythm.