-
1. Re: How can I set the language for all portlets in the porta
antoine_h Sep 7, 2006 5:17 PM (in response to rkiesi)may be have a look at the CMSPortlet, to see how it manage with the locale.
The locale is also defined in the user preferences (if logged in).
if you want to manage the session locale (decided by the user, that ask for a different locale, even if not logged in), you may use a parameter stored in the session, at the Application scope (for all portlets to read it). you may search on the web, there are some articles that explain how to use parameters in the session.
I don't use a parameter in the session, but a Inter Portlet Communication (IPC) that is based on messages exchanged between portlets.
As the IPC store and provide the messages at a session level, it provide me with a storing this parameter (as a message) at the session level.
that avoid to put many things in the session, that is not recommended for heavy load management. -
2. Re: How can I set the language for all portlets in the porta
redeagle Sep 20, 2006 10:12 AM (in response to rkiesi)Hi @ all,
i have a similiar problem like rkiesi.
I want to change the localization of the whole portal without userlogin!
I have build up a jsf portlet which contains a combo box where you can select your language and i store the selected language in the session:
Code inside my managed bean:session.setAttribute("locale", selectedLanguage, PortletSession.APPLICATION_SCOPE);
After that i wrote a new ServerInterceptor which will be called after the LocalInterceptor of the portal:public class LocaleInterceptor extends ServerInterceptor { private static Logger logger = LoggerFactory .getLogger(LocaleInterceptor.class); protected void invoke(ServerInvocation invocation) throws Exception, InvocationException { ServerRequest req = invocation.getRequest(); HttpSession session = req.getContext() .getClientRequest().getSession(false); if(session!=null){ String locale = (String) session.getAttribute("locale"); logger.info("locale "+locale); logger.info("id: "+session.getId()); } invocation.invokeNext(); } }
Everything is working fine. The ServerInterceptor is called but i only get a null- value out of the session.
Both session that one i access in my jsf page and that one i access in my Interceptor have the same ids!
Another point i have to mention is the project- structure:
- the portlet where i want to change the locale is a web- project
- the interceptor is in a separated project because the classloader needs the interceptor first.
Anyone knows why i cannot get the value out of the session?
(is it possible that i'm accessing this attribute)
or is there another way to change the locale for the whole portlet?
regards,
Red -
3. Re: How can I set the language for all portlets in the porta
halversp Sep 21, 2006 10:27 AM (in response to rkiesi)"Red Eagle" wrote:
Another point i have to mention is the project- structure:
- the portlet where i want to change the locale is a web- project
- the interceptor is in a separated project because the classloader needs the interceptor first.
Anyone knows why i cannot get the value out of the session?
(is it possible that i'm accessing this attribute)
or is there another way to change the locale for the whole portlet?
regards,
Red
Probably because the portlet and the interceptor are accessing different sessions (your portlet.war's and the portal-core.war, respectively).
p -
4. Re: How can I set the language for all portlets in the porta
redeagle Sep 21, 2006 11:27 AM (in response to rkiesi)But why i have the same session ids?
Red