How to get selected locale in JasperReports Server?

Hi 

I am using JasperReports Server 5, and I am new to it. My requirement is to customize UI based on selected locale for e.g. if user wants to show/hide some of the links(in jasperserver) only for french locale not for english locale.

If anybody knows how to get selected locale inside jasperserver then share details with me. I am also simultaneously going through documentation and web help to acheive the same.

prasad.basutkar's picture
Joined: Nov 27 2012 - 10:36pm
Last seen: 10 years 8 months ago
In general, locales are not used like that. You set the locale, then the UI and the reports etc. are rendered using that locale. But I suppose you could achieve it with a little bit of JavaScript. You should update your question with a more precise example of a link you want to conditionally hide.
mdahlman - 10 years 9 months ago
thanks for quick response , i wanted to know whether jasperserver is keeping any variable in session or context for selected locale so that i can use to conditionally hide/show not only links other UI stuffs also , i am just thinking in one direction to address this problem , there may be easy ways to achieve this.
prasad.basutkar - 10 years 9 months ago

2 Answers:

I found a way to get the locale in a JSP page

You need to import a class first: 

<%@ page import="com.jaspersoft.jasperserver.war.common.JasperServerConstImpl" %>

Then you have access to the Locale:

 <%=session.getAttribute(JasperServerConstImpl.getUserLocaleSessionAttr())%>

I tried this in the "about" box and once logged in was able to see en_US

ernestoo's picture
18938
Joined: Nov 29 2010 - 11:59am
Last seen: 5 years 11 months ago

Thanks for the quick response , i am able to get selected locale using the same in jsp

prasad.basutkar - 10 years 9 months ago

Thank You Sir! It is working!

prabuddha.kulatunga - 3 years 10 months ago

Sounds like something along the lines of  creating variable with:

(LocaleEnglish != english) ? LocaleFrenche : LocaleEnglish

But that limits it to EN and FR

sjoerd.jump's picture
Joined: Oct 29 2012 - 2:39pm
Last seen: 2 years 2 weeks ago

thanks for quick response , i wanted to know whether jasperserver is keeping any variable in session or context for selected locale so that i can use to conditionally hide/show not only links other UI stuffs also , i am just thinking in one direction to address this problem , there may be easy ways to achieve this

prasad.basutkar - 10 years 9 months ago
Feedback
randomness