Class LanguageRedirectApp

java.lang.Object
sk.iway.iwcm.components.WebjetComponentAbstract
sk.iway.iwcm.components.langredirect.LanguageRedirectApp
All Implemented Interfaces:
WebjetComponentInterface

public class LanguageRedirectApp extends WebjetComponentAbstract

Application for redirecting the home page to a subdirectory based on browser language.

It detects the language from the HTTP Accept-Language header and redirects the user to the corresponding language folder.

Include example:

!INCLUDE(sk.iway.iwcm.components.langredirect.LanguageRedirectApp)! The @WebjetAppStore annotation ensures the application is displayed in the editor application list (AppStore)
  • Constructor Details

    • LanguageRedirectApp

      public LanguageRedirectApp()
  • Method Details

    • getAppOptions

      public Map<String,List<OptionDto>> getAppOptions(ComponentRequest componentRequest, jakarta.servlet.http.HttpServletRequest request)
      Dynamically gets language selection options from design template configuration. Uses LayoutService.getLanguages() the same way as template editing. Adds an empty option as the first item for all mapping fields.
      Specified by:
      getAppOptions in interface WebjetComponentInterface
      Overrides:
      getAppOptions in class WebjetComponentAbstract
      Parameters:
      componentRequest - Component request context
      request - HTTP request
      Returns:
      Map with options for defaultLanguage and all mapping fields
    • view

      public String view(jakarta.servlet.http.HttpServletRequest request)
      Default handler - redirects to the page language variant based on detected language. Checks all 8 configurable language-to-URL mappings first. If no mapping is found, falls back to defaultLanguage. If the lng cookie exists and respectCookie is true, its value is used.
      Parameters:
      request - HTTP request
      Returns:
      redirect URL to the language variant
    • getDefaultLanguage

      public String getDefaultLanguage()
      Default language if browser language detection fails or no mapping is found.
    • getRootOnly

      public Boolean getRootOnly()
      If true, redirect only on the root URL (for example, / or /index.html). If false, always redirect when entering the page.
    • getRespectCookie

      public Boolean getRespectCookie()
      If true, redirection is performed only when the user does not have a language cookie set. This allows users to change language manually without being redirected.
    • getMapping1Lang

      public String getMapping1Lang()
      Language-to-URL redirect mappings. Up to 8 configurable pairs. Each pair consists of a language selection and a redirect URL. Leave language empty to skip that mapping.
    • getMapping1Url

      public String getMapping1Url()
    • getMapping2Lang

      public String getMapping2Lang()
    • getMapping2Url

      public String getMapping2Url()
    • getMapping3Lang

      public String getMapping3Lang()
    • getMapping3Url

      public String getMapping3Url()
    • getMapping4Lang

      public String getMapping4Lang()
    • getMapping4Url

      public String getMapping4Url()
    • getMapping5Lang

      public String getMapping5Lang()
    • getMapping5Url

      public String getMapping5Url()
    • getMapping6Lang

      public String getMapping6Lang()
    • getMapping6Url

      public String getMapping6Url()
    • getMapping7Lang

      public String getMapping7Lang()
    • getMapping7Url

      public String getMapping7Url()
    • getMapping8Lang

      public String getMapping8Lang()
    • getMapping8Url

      public String getMapping8Url()
    • setDefaultLanguage

      public void setDefaultLanguage(String defaultLanguage)
      Default language if browser language detection fails or no mapping is found.
    • setRootOnly

      public void setRootOnly(Boolean rootOnly)
      If true, redirect only on the root URL (for example, / or /index.html). If false, always redirect when entering the page.
    • setRespectCookie

      public void setRespectCookie(Boolean respectCookie)
      If true, redirection is performed only when the user does not have a language cookie set. This allows users to change language manually without being redirected.
    • setMapping1Lang

      public void setMapping1Lang(String mapping1Lang)
      Language-to-URL redirect mappings. Up to 8 configurable pairs. Each pair consists of a language selection and a redirect URL. Leave language empty to skip that mapping.
    • setMapping1Url

      public void setMapping1Url(String mapping1Url)
    • setMapping2Lang

      public void setMapping2Lang(String mapping2Lang)
    • setMapping2Url

      public void setMapping2Url(String mapping2Url)
    • setMapping3Lang

      public void setMapping3Lang(String mapping3Lang)
    • setMapping3Url

      public void setMapping3Url(String mapping3Url)
    • setMapping4Lang

      public void setMapping4Lang(String mapping4Lang)
    • setMapping4Url

      public void setMapping4Url(String mapping4Url)
    • setMapping5Lang

      public void setMapping5Lang(String mapping5Lang)
    • setMapping5Url

      public void setMapping5Url(String mapping5Url)
    • setMapping6Lang

      public void setMapping6Lang(String mapping6Lang)
    • setMapping6Url

      public void setMapping6Url(String mapping6Url)
    • setMapping7Lang

      public void setMapping7Lang(String mapping7Lang)
    • setMapping7Url

      public void setMapping7Url(String mapping7Url)
    • setMapping8Lang

      public void setMapping8Lang(String mapping8Lang)
    • setMapping8Url

      public void setMapping8Url(String mapping8Url)