java.lang.Object
com.aoindustries.web.struts.LocaleFilter
- All Implemented Interfaces:
Filter
Resolves the current
Locale, optionally changing it with any language parameters, and sets the request param
Constants.LOCALE, and sets the thread locale.- Author:
- AO Industries, Inc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voiddoFilter(ServletRequest request, ServletResponse response, FilterChain chain) static LocalegetDefaultLocale(SiteSettings siteSettings, ServletRequest request) Gets the default locale for the provided request.static LocalegetEffectiveLocale(SiteSettings siteSettings, ServletRequest request, ServletResponse response) Gets the effective locale for the request.voidinit(FilterConfig fc)
-
Constructor Details
-
LocaleFilter
public LocaleFilter()
-
-
Method Details
-
init
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException - Specified by:
doFilterin interfaceFilter- Throws:
IOExceptionServletException
-
destroy
public void destroy() -
getEffectiveLocale
public static Locale getEffectiveLocale(SiteSettings siteSettings, ServletRequest request, ServletResponse response) throws IOException, 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
Constants.LANGUAGEto override the current settings.This also sets the struts, JSTL, and response locales to the same value.
The thread locale is not set.
- Throws:
IOExceptionSQLException
-
getDefaultLocale
public static Locale getDefaultLocale(SiteSettings siteSettings, ServletRequest request) throws IOException, SQLException Gets the default locale for the provided request. The session and thread locale are not set.- Throws:
IOExceptionSQLException
-
