Class LocalizationFilter

java.lang.Object
org.exoplatform.container.web.AbstractFilter
org.exoplatform.portal.application.localization.LocalizationFilter
All Implemented Interfaces:
jakarta.servlet.Filter

public class LocalizationFilter extends org.exoplatform.container.web.AbstractFilter
This filter provides ServletRequest.getLocale() and ServletRequest.getLocales() override for extra-portlet requests (i.e. unbridged .jsp). Thanks to it dynamic resources can be localized to keep in sync with the rest of the portal. This filter is re-entrant, and can safely be installed for INCLUDE, FORWARD, and ERROR dispatch methods.

A concrete example of re-entrant use is login/jsp/login.jsp used when authentication fails at portal login.

By default ServletRequest.getLocale() and ServletRequest.getLocales() reflect browser language preference. When using this filter these two calls employ the same Locale determination algorithm as LocalizationLifecycle does.

This filter can be activated / deactivated via portal module's web.xml

If default portal language is other than English, it can be configured for the filter by using PortalLocale init param:

 <filter>
   <filter-name>LocalizationFilter</filter-name>
   <filter-class>org.exoplatform.portal.application.localization.LocalizationFilter</filter-class>
   <init-param>
     <param-name>PortalLocale</param-name>
     <param-value>fr_FR</param-value>
   </init-param>
 </filter>
 
Author:
Marko Strukelj
  • Field Summary

    Fields inherited from class org.exoplatform.container.web.AbstractFilter

    config, servletContextName
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    afterInit(jakarta.servlet.FilterConfig config)
     
    void
     
    void
    doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain)
     
    static Locale
     

    Methods inherited from class org.exoplatform.container.web.AbstractFilter

    getContainer, getServletContext, init, requirePortalEnvironment

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LocalizationFilter

      public LocalizationFilter()
  • Method Details

    • afterInit

      protected void afterInit(jakarta.servlet.FilterConfig config) throws jakarta.servlet.ServletException
      Overrides:
      afterInit in class org.exoplatform.container.web.AbstractFilter
      Throws:
      jakarta.servlet.ServletException
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Throws:
      IOException
      jakarta.servlet.ServletException
    • destroy

      public void destroy()
    • getCurrentLocale

      public static Locale getCurrentLocale()