I am building a multilingual application and I am storing the value of the latest language used in a cookie.
When the user opens up the application, the sessionScope variable is not set and the code will look for the cookie value and reload the page if not in the proper Locale.
I am getting the "com.ibm.xsp.acl.RedirectSignal" warning each time the page is reloaded in the proper locale, and I'd lilke to avoid it.
My code is located in the beforeRenderResponse event of the ApplicationLayout control I am using in the application, and looks like this:
if(!sessionScope.lang) { //this only happens when the page is opened in browser for the first time
var lang = context.getUrlParameter("lang").toLowerCase();
if(!!lang) {
sessionScope.lang = lang.toUpperCase();
//set cookie for next time the site is opened by user
setCookie("lang", lang.toUpperCase(), 30);
context.setLocale(new Locale(lang.toLowerCase()));
} else {
//set language from cookie
var lang = getLangFromCookie();
if(!!lang) {
sessionScope.lang = lang;
context.setLocale(new Locale(lang.toLowerCase()));
} else {
sessionScope.lang = Appconfig.defaultLang;
context.setLocale(new Locale(Appconfig.defaultLang.toLowerCase()));
}
}
//need to trpa the redirect error thrown here, as it is just a warning - avoid filling log with this
//importPackage(com.ibm.xsp.acl.RedirectSignal);
importPackage(com.ibm.xsp.acl.RedirectSignal);
try {
//reload the page so Locale value kicks in
context.reloadPage();
} catch (RedirectSignal rs) {
//just ignore
}
}
Even though I added the importPackage line, I am still getting an error when saving the code (it is in a script Library):
Encountered " "rs"" at line...
How can I make this work?
Thanks :D