akossar Posted June 11, 2008 Share Posted June 11, 2008 Is there a possibility to localize input controls attributes (labels descriptions etc) in JasperServer? I looked at the source code and it seems that the model only supports one label and description per input control. Is there any ongoing developement for extension of the model or a workaround to by pass this limitation? Link to comment Share on other sites More sharing options...
lucianc Posted June 11, 2008 Share Posted June 11, 2008 JS 3.0 will include a mechanism to localize input controls labels (as shown in the report input controls form) that uses report message bundles. In JS 2.1, the only solution is to use custom input control JSPs that display localized messages instead of input control labels. Regards,Lucian Link to comment Share on other sites More sharing options...
akossar Posted June 11, 2008 Author Share Posted June 11, 2008 Thanks for your answer. I have just installed the release candidate of JS 3.0 but the input controls forms are still the same as 2.1. Is this a feature coming in the final version of 3.0? Regards, akossar Link to comment Share on other sites More sharing options...
lucianc Posted June 11, 2008 Share Posted June 11, 2008 Yes, this feature has been implemented after the 3.0 RC1 release, so you'll have to wait for the final 3.0 release to give try it. Regards,Lucian Link to comment Share on other sites More sharing options...
chiphi13 Posted March 12, 2009 Share Posted March 12, 2009 Has this been implemented yet? I am running version 3.1 and would like to know what the steps are from implementing localization for the input control labels. Link to comment Share on other sites More sharing options...
lucianc Posted March 17, 2009 Share Posted March 17, 2009 Localization of the Input control labels can be achieved via the report's resource bundle.For each report input control/parameter, an entry having net.sf.jasperreports.prompt.label.<name> as key is looked for in the report resource bundle, and if found the corresponding message is used instead of the input control label.In other words: The JRXML used as main report must specify a resourceBundle attribute. The resource bundles (*.properties files) to which the resourceBundle JRXML attribute resolves must include messages for net.sf.jasperreports.prompt.label.<name> keys, where <name> is the paramete/input control name.When the report is executed, a resource bundle will be used depending on the current locale, and input controls labels will be taken from the resource bundle.Regards,Lucian Link to comment Share on other sites More sharing options...
samvijay Posted March 25, 2009 Share Posted March 25, 2009 Continuing on this discussion Is there any way to support localization other than through resource bundle? For example reading localization data from database and passing that data to JasperServer during execution using scriptlet or some other mechanism? In a large enterprise application it can become nightmare to maintain hundreds of resource bundlesPost Edited by Sam Vijay at 03/25/09 13:21 Link to comment Share on other sites More sharing options...
swood Posted March 29, 2009 Share Posted March 29, 2009 You can replace the default Spring bundle management that we use in JasperServer with an alternate implementation. Have a look at this thread http://forum.springframework.org/showthread.php?t=15223 ShermanJaspersoft Link to comment Share on other sites More sharing options...
samvijay Posted March 30, 2009 Share Posted March 30, 2009 Thanks Sherman. I think it was a mistake on my part to ask this question in JasperServer forum, rather I should have asked this question in JasperReports forum, because my question was more to do with JasperReports than JasperServer :-) We upload the JRXML files along with related files like resource bundles, images etc…, when report is executed the resource bundles are loaded by JasperServer using the JasperReports method called loadResourceBundle(..) in the net.sf.jasperreports.engine.util.JRResourcesUtil class, I believe this is the default behavior of JasperServer The ReloadableResourceBundleMessageSource bean in applicationContext.xml reads the JasperServer properties not the Report resource bundle data! If my above understanding is correct, now my question is how do we tell the JasperServer/Reports to read property values (related to a report) from say database instead of resource bundle?Post Edited by Sam Vijay at 03/30/09 09:53 Link to comment Share on other sites More sharing options...
lucianc Posted March 30, 2009 Share Posted March 30, 2009 JasperReports uses the standard java.util.ResourceBundle class to load resource bundles for reports. If you want to read messages from a DB, you'll have to extend ResourceBundle (which is an abstract class) and implement the required DB lookup code. Then you can use the class name as the report resourceBundle attribute. See ResourceBundle's Javadoc, it has some hints on how to write and use custom implementations.Regards,Lucian Link to comment Share on other sites More sharing options...
samvijay Posted March 30, 2009 Share Posted March 30, 2009 Thanks Lucian,Actually I was looking for some magical approach!!!! which does not require modifying the core JasperReport code (like using scriptlet, or config changes etc…). If we extend ResourceBundle then we need to modify the JasperReports code like JRResourcesUtil.java and also we loose the flexibility of using ResourceBundle for few reports, which I want to avoid. Actually I have modified JRFillDataset.java file to read localization data from Database if resourceBundle attribute is not mentioned in JRXML, but I am looking for cleaner and less intrusive approach to get localization data from other than .prop file.--samvijayPost Edited by Sam Vijay at 03/30/09 13:55 Link to comment Share on other sites More sharing options...
lucianc Posted March 30, 2009 Share Posted March 30, 2009 samvijayWrote: If we extend ResourceBundle then we need to modify the JasperReports code like JRResourcesUtil.java and also we loose the flexibility of using ResourceBundle for few reports, which I want to avoid. Using a custom java.util.ResourceBundle implementation does not require any change to the JR code. JRResourcesUtil calls the ResourceBundle.getBundle method, which is able to load instances of ResourceBundle implementation classes. As I said in my previous post, all you need to do is to use your ResourceBundle implementation class name as the value of the report resourceBundle attribute.Regards,Lucian Link to comment Share on other sites More sharing options...
samvijay Posted March 31, 2009 Share Posted March 31, 2009 Thanks Lucian, My basic understating of ResourceBundle class was wrong; I was under the impression that we can pass only the .prop file name as resouceBundle. This indeed is an eye opener for me, this will solve my problem--samvijay Link to comment Share on other sites More sharing options...
simonx Posted May 26, 2009 Share Posted May 26, 2009 Hi Lucianc, I tried to follow your steps but is not working the jasperserver always display the label's value I defined in the input control form label and not from the resource bundle. i.e: My input control name is testProperty and the label is net.sf.jasperreports.prompt.label.testProperty. In the resource bundle file I defined a property net.sf.jasperreports.prompt.label.testProperty=InputName What I'm doing wrong? Thanks for your help Link to comment Share on other sites More sharing options...
lucianc Posted May 27, 2009 Share Posted May 27, 2009 simonxWrote: Hi Lucianc, I tried to follow your steps but is not working the jasperserver always display the label's value I defined in the input control form label and not from the resource bundle. i.e: My input control name is testProperty and the label is net.sf.jasperreports.prompt.label.testProperty. In the resource bundle file I defined a property net.sf.jasperreports.prompt.label.testProperty=InputName What I'm doing wrong? Thanks for your help Which JS version are you using? Do you have a testProperty parameter in the report JRXML?Regards,Lucian Link to comment Share on other sites More sharing options...
simonx Posted May 31, 2009 Share Posted May 31, 2009 Hi Lucian, Thanks, I added the testProperty parameter to the JRXML and now everything works :) Link to comment Share on other sites More sharing options...
federico.cattozzi Posted May 7, 2010 Share Posted May 7, 2010 If you have many reports and many input controls to translate, following query can be used on JS MySQL db to print all input control definitions:Code:mysql> SELECT DISTINCT -> concat('net.sf.jasperreports.prompt.label.', c1.name,'=',c1.label) as input_name -> FROM -> jasperserver.jireportunitinputcontrol a -> INNER JOIN jasperserver.jireportunit b -> ON a.report_unit_id = b.id -> INNER JOIN jasperserver.jiresource c -> ON c.id = b.mainReport -> INNER JOIN jiresourcefolder rf -> ON c.parent_folder = rf.id -> INNER JOIN jasperserver.jiresource c1 -> ON c1.id = A.input_control_id -> ORDER BY -> input_name asc;+-------------------------------------------------------------------------------------------------+| input_name |+-------------------------------------------------------------------------------------------------+ || net.sf.jasperreports.prompt.label.ASC_DESC=Ascending/Descending | | || net.sf.jasperreports.prompt.label.CONNECTION_TYPE=Connection Type || net.sf.jasperreports.prompt.label.CREATION_DATE_FROM=Creation Date from || net.sf.jasperreports.prompt.label.CREATION_DATE_TO=Creation Date to | || net.sf.jasperreports.prompt.label.DISPLAY_TYPE=Display Type | || net.sf.jasperreports.prompt.label.ERROR_CATEGORY=Error Category |... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now