com.aoindustries.website
Class LocaleAction

java.lang.Object
  extended by Action
      extended by com.aoindustries.website.SiteSettingsAction
          extended by com.aoindustries.website.LocaleAction
Direct Known Subclasses:
SkinAction

public class LocaleAction
extends SiteSettingsAction

Resolves the current locale, optionally changing it with any language parameters, sets the request param locale, and calls subclass implementation.

Author:
Dan Armstrong <dan@aoindustries.com>

Constructor Summary
LocaleAction()
           
 
Method Summary
 ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, SiteSettings siteSettings)
          Selects the Locale, sets the request attribute "locale", then the subclass execute method is invoked.
 ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, SiteSettings siteSettings, java.util.Locale locale)
          Once the locale is selected, this version of the execute method is invoked.
static java.util.Locale getDefaultLocale(SiteSettings siteSettings, javax.servlet.http.HttpServletRequest request)
          Gets the default locale for the provided request.
static java.util.Locale getEffectiveLocale(SiteSettings siteSettings, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           Gets the effective locale for the request.
 
Methods inherited from class com.aoindustries.website.SiteSettingsAction
execute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocaleAction

public LocaleAction()
Method Detail

execute

public final ActionForward execute(ActionMapping mapping,
                                   ActionForm form,
                                   javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response,
                                   SiteSettings siteSettings)
                            throws java.lang.Exception
Selects the Locale, sets the request attribute "locale", then the subclass execute method is invoked.

Overrides:
execute in class SiteSettingsAction
Throws:
java.lang.Exception
See Also:
#execute(ActionMapping,ActionForm,HttpServletRequest,HttpServletResponse,Locale)

getEffectiveLocale

public static java.util.Locale getEffectiveLocale(SiteSettings siteSettings,
                                                  javax.servlet.http.HttpServletRequest request,
                                                  javax.servlet.http.HttpServletResponse response)
                                           throws javax.servlet.jsp.JspException,
                                                  java.io.IOException,
                                                  java.sql.SQLException

Gets the effective locale for the request. If the requested language is not one of the enabled languages for this site, will set to the default language (the first in the language list).

Also allows the parameter "language" to override the current settings.

This also sets the struts, JSTL, and response locales to the same value.

Throws:
javax.servlet.jsp.JspException
java.io.IOException
java.sql.SQLException

getDefaultLocale

public static java.util.Locale getDefaultLocale(SiteSettings siteSettings,
                                                javax.servlet.http.HttpServletRequest request)
                                         throws javax.servlet.jsp.JspException,
                                                java.io.IOException,
                                                java.sql.SQLException
Gets the default locale for the provided request. The session is not set.

Throws:
javax.servlet.jsp.JspException
java.io.IOException
java.sql.SQLException

execute

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             SiteSettings siteSettings,
                             java.util.Locale locale)
                      throws java.lang.Exception
Once the locale is selected, this version of the execute method is invoked. The default implementation of this method simply returns the mapping of "success".

Throws:
java.lang.Exception