Class LanguageRedirectApp
java.lang.Object
sk.iway.iwcm.components.WebjetComponentAbstract
sk.iway.iwcm.components.langredirect.LanguageRedirectApp
- All Implemented Interfaces:
WebjetComponentInterface
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)-
Field Summary
Fields inherited from class sk.iway.iwcm.components.WebjetComponentAbstract
appHideFields, cacheMinutes, device, EMPTY_PAGE, showForLoggedUser, wrapperAriaLabel, wrapperClass, wrapperId, wrapperTitle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAppOptions(ComponentRequest componentRequest, jakarta.servlet.http.HttpServletRequest request) Dynamically gets language selection options from design template configuration.Default language if browser language detection fails or no mapping is found.Language-to-URL redirect mappings.If true, redirection is performed only when the user does not have a language cookie set.If true, redirect only on the root URL (for example, / or /index.html).voidsetDefaultLanguage(String defaultLanguage) Default language if browser language detection fails or no mapping is found.voidsetMapping1Lang(String mapping1Lang) Language-to-URL redirect mappings.voidsetMapping1Url(String mapping1Url) voidsetMapping2Lang(String mapping2Lang) voidsetMapping2Url(String mapping2Url) voidsetMapping3Lang(String mapping3Lang) voidsetMapping3Url(String mapping3Url) voidsetMapping4Lang(String mapping4Lang) voidsetMapping4Url(String mapping4Url) voidsetMapping5Lang(String mapping5Lang) voidsetMapping5Url(String mapping5Url) voidsetMapping6Lang(String mapping6Lang) voidsetMapping6Url(String mapping6Url) voidsetMapping7Lang(String mapping7Lang) voidsetMapping7Url(String mapping7Url) voidsetMapping8Lang(String mapping8Lang) voidsetMapping8Url(String mapping8Url) voidsetRespectCookie(Boolean respectCookie) If true, redirection is performed only when the user does not have a language cookie set.voidsetRootOnly(Boolean rootOnly) If true, redirect only on the root URL (for example, / or /index.html).view(jakarta.servlet.http.HttpServletRequest request) Default handler - redirects to the page language variant based on detected language.Methods inherited from class sk.iway.iwcm.components.WebjetComponentAbstract
addCurrentValueToOptions, addCurrentValueToOptions, addOptions, buildWrapperDiv, getAppHideFields, getBaseAppOptions, getCacheMinutes, getDevice, getShowForLoggedUser, getViewFolder, getWrapperAriaLabel, getWrapperClass, getWrapperId, getWrapperTitle, init, init, initAppEditor, isEditorPreview, parseOptionsFromConfig, setAppHideFields, setCacheMinutes, setDevice, setShowForLoggedUser, setViewFolder, setWrapperAriaLabel, setWrapperClass, setWrapperId, setWrapperTitle
-
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:
getAppOptionsin interfaceWebjetComponentInterface- Overrides:
getAppOptionsin classWebjetComponentAbstract- Parameters:
componentRequest- Component request contextrequest- HTTP request- Returns:
- Map with options for defaultLanguage and all mapping fields
-
view
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
Default language if browser language detection fails or no mapping is found. -
getRootOnly
If true, redirect only on the root URL (for example, / or /index.html). If false, always redirect when entering the page. -
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
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
-
getMapping2Lang
-
getMapping2Url
-
getMapping3Lang
-
getMapping3Url
-
getMapping4Lang
-
getMapping4Url
-
getMapping5Lang
-
getMapping5Url
-
getMapping6Lang
-
getMapping6Url
-
getMapping7Lang
-
getMapping7Url
-
getMapping8Lang
-
getMapping8Url
-
setDefaultLanguage
Default language if browser language detection fails or no mapping is found. -
setRootOnly
If true, redirect only on the root URL (for example, / or /index.html). If false, always redirect when entering the page. -
setRespectCookie
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
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
-
setMapping2Lang
-
setMapping2Url
-
setMapping3Lang
-
setMapping3Url
-
setMapping4Lang
-
setMapping4Url
-
setMapping5Lang
-
setMapping5Url
-
setMapping6Lang
-
setMapping6Url
-
setMapping7Lang
-
setMapping7Url
-
setMapping8Lang
-
setMapping8Url
-