Jump to content
Changes to the Jaspersoft community edition download ×

Passing REPORT_LOCALE doesn't work in Jasper-Serve


mgruner

Recommended Posts

Hello,

I'm currently working on making my reports multi-lingual. I would like my users to choose the language on starting point of the report. Therefore I created a Input-Control in my Report with the Name "REPORT_LOCALE" hoping that it would pass the given locale to the report.

When starting the report via "Run report unit" from IReport everything works like a charm: The locale gets recognized and uses the right resource bundles for that. When I use the Jaspersoft Jasperserver web interface the report ignores my parameter and uses the locale which the user did chose to login to the web interface.

Are there any ideas around how I may change that behavior?

Cheers, micha

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

No, I am wrong.

 

If you have an input control that has the same name as a JasperReports internal parameter, the input control value will override any defaults JasperServer puts in.

 

From Teodor: "this would not work for REPORT_LOCALE as you cannot create an input control that would deliver java.util.Locale objects as values".

 

iReport is doing something special for REPORT_LOCALE to make it work.

 

Let me ask about some more details with my folks.

 

Sherman

Jaspersoft

Link to comment
Share on other sites

  • 1 month later...

mlabonte
Wrote:
 

I'm facing the exact same problem with REPORT_LOCALE. Any news? Will it be fixed, is there any workaround?

Thanks

Well, the official answer is given by Sherman.

If you like to you may download the community edition source code and look for occurences of "REPORT_LOCALE" within the code (there are only 5 pieces as far as I remember). Then you could adapt the IReport code to the JAsper-Server Web-frontend. (In IReport they look if the REPORT_LOCALE variable is set. If it is set they create a REPORT_LOCALE object from the string given if not they default to the system locale.)

As Sherman noted this is rather a hack than a straight forward approach. Unfortunately I did never implement this as I left the project where this thing was needed and had not enough time to do it as a private project. ;)

Good luck!

Michael

Link to comment
Share on other sites

I made the following code change to make this work:

 

jasperserver-ce\jasperserver\jasperserver-war-jar\src\main\java\com\jaspersoft\jasperserver\war\action\ViewReportAction.java
 

Code:
	protected void setReportLocaleParameter(RequestContext context, Map parameterValues) {//		 Locale locale = (Locale) context.getFlowScope().get(getAttributeReportLocale(), Locale.class);		Locale locale = null;		String myLocale = null;		if(parameterValues.containsKey("reportLocale")){			myLocale = (String) parameterValues.get("reportLocale");					}		if (myLocale != null){			locale = LocaleHelper.getInstance().getLocale(myLocale);							}else{						locale = (Locale) context.getFlowScope().get(getAttributeReportLocale(), Locale.class);		}						if (locale != null) {			parameterValues.put(JRParameter.REPORT_LOCALE, locale);		}	}
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...