federico.cattozzi Posted November 9, 2009 Share Posted November 9, 2009 Hi,I would know if there is a way to print text of the query directly on the report to give to the user more info.I suppose that if I defined query outside the report, JS send to it only the JRResultSetDataSource without the query.Suggestions? Link to comment Share on other sites More sharing options...
sjongenelen Posted November 9, 2009 Share Posted November 9, 2009 load your query into a variable first? Link to comment Share on other sites More sharing options...
federico.cattozzi Posted November 9, 2009 Author Share Posted November 9, 2009 Thank you, I don't think about this solution.So I have defined a new parameter QUERY with default expression similar to the query which was in <queryString> tag and I have put "<![CDATA[$P!{QUERY}]]>" in <queryString>, and all works. If you work with iReport you lose some features of the "Report Query" window using this solution and all becomes less maintainable. Link to comment Share on other sites More sharing options...
sjongenelen Posted November 9, 2009 Share Posted November 9, 2009 agreed, perhaps you should do the both of them? use the query and use the variable, but only use the variable on the report? Link to comment Share on other sites More sharing options...
federico.cattozzi Posted November 9, 2009 Author Share Posted November 9, 2009 I use jEdit software and BeanShell scripting language built-in it to do multiple text replacements. It's useful also in this case to convert query from <queryString> format to java compliant format.The script below can be used as macro in jEdit, but you have to test it for your code.Code:// This is a recorded macro. First, check over the// commands to make sure this is what you intended. Then,// save this buffer, and the macro should appear in the// Macros menu..//add quotes before and after every line and carriage return "\n" for pretty printSearchAndReplace.setSearchString("^(.*)$");SearchAndReplace.setReplaceString("\"\\\"\" + _1 + \"\\\\n\\\"+\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.setSearchFileSet(new CurrentBufferSet());SearchAndReplace.replaceAll(view);//add necessary characters to un-comment every parameter (P and P! are converted differently)SearchAndReplace.setSearchString("\\$P(!?)\\{([\\w\\_]*)\\}");SearchAndReplace.setReplaceString("_1 != null && _1.equals(\"!\") ? \"\\\"+$P\" + \"{\" + _2 + \"}\" + \"+\\\"\" : \"\'\\\"+$P\" + \"{\" + _2 + \"}\" + \"+\\\"\'\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.setSearchFileSet(new CurrentBufferSet());SearchAndReplace.replaceAll(view);//remove last characters of the query added by last replacementSearchAndReplace.setSearchString("(.*)\\\\n\"\\+\\z");SearchAndReplace.setReplaceString("_1 + \"\\\"\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.replaceAll(view);//convert tabs to "\t" for pretty printSearchAndReplace.setSearchString("\\t");SearchAndReplace.setReplaceString("\"\\\\t\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.replaceAll(view); Link to comment Share on other sites More sharing options...
federico.cattozzi Posted November 9, 2009 Author Share Posted November 9, 2009 I thought to use both of them, but I wanted to print query on demand on the report to spare writing it in end-user's documentation.If I have two place to synchronize I return to the start of the problem.There is no solution :)Thank you 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