yadavillisridhar Posted January 3, 2007 Share Posted January 3, 2007 Dear frnds, I am getting a calculated value in my variable. And I need to get that value into a parameter which will be handled by servlet. I need to get this value at the end of the report. I tried all the settings of "Reset Type" values like report, column..etc. But I am just getting the "null" value into that. Please help me in getting a solution. With RegardsSridhar Yadavilli Link to comment Share on other sites More sharing options...
jmurray Posted January 4, 2007 Share Posted January 4, 2007 You need scriptlet magic.First create a scriptlet to do the value passing. This example takes an Integer variable and sets a String parameter, then returns the String contents of the parameter so it can be displayed in a text field:import net.sf.jasperreports.engine.*;public class myScriptlet extends it.businesslogic.ireport.IReportScriptlet { /* Creates a new instance of JRIreportDefaultScriptlet */ public myScriptlet() { } public String CopyVarToPar(Integer v) throws JRScriptletException { parametersMap.put("myParameter", v.intValue()); Integer p = (Integer)parametersMap.get("myParameter"); return (String)p.toString(); }}[/code]In the LastPageFooter or Summary band you need to define a Text Field with the Textfield Expression set to $P{REPORT_SCRIPTLET}.CopyVarToPar($V{myVariable})The example above will display the contents of the parameter (which will contain the contents of the variable). If you don't want to display anything then your scriplet need not return anything :import net.sf.jasperreports.engine.*;public class myScriptlet extends it.businesslogic.ireport.IReportScriptlet { /** Creates a new instance of JRIreportDefaultScriptlet */ public myScriptlet() { } String CopyVarToPar(Integer v) throws JRScriptletException { parametersMap.put("myParameter", v.intValue()); return (java.lang.String)(null); }}[/code]You can then set the Text Field to Blank When Null and Remove Line When BlankPost edited by: jmurray, at: 2007/01/04 04:17 Link to comment Share on other sites More sharing options...
jmurray Posted January 4, 2007 Share Posted January 4, 2007 BTW, you will receive a compilation warning like this: 4537029 [Thread-57] INFO design.JRJdk13Compiler - Note: myScriptlet.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Â because the scriptlet directly manipulates the parametersMap hashmap. Unfortunately there is no setParametervalue() method available, so the direct manipulation of the hashmap is the only way to get the job done.Post edited by: jmurray, at: 2007/01/03 23:21 Link to comment Share on other sites More sharing options...
yadavillisridhar Posted January 4, 2007 Author Share Posted January 4, 2007 Thanks alot for the help. I have done as you said and I got com.sun.javac.Main CassnotFound Exception. I have set the Classpath[Added the path of tools.jar]... Then I recompiled, Now I got the java.lang.reflect.InvocationTargetException. I googled the error. But couldnt able to find a solution. Can anyone help me in this.. Link to comment Share on other sites More sharing options...
jmurray Posted January 4, 2007 Share Posted January 4, 2007 Information about the InvocationTargetException can be found in the Exception Summary section of this page: http://java.sun.com/j2se/1.3/docs/api/java/lang/reflect/package-summary.html I am unable to generate the error so cannot offer any help resolving this issue other than suggesting you make sure these files all exist in the lib directory: ireport.jaritext.jarjasperreports.jarjcommon.jarjfreechart.jartools.jarxalan.jar and that there is only one version of each of them in the lib directory and any other directories specified in the classpath. .Post edited by: jmurray, at: 2007/01/04 04:20 Link to comment Share on other sites More sharing options...
yadavillisridhar Posted January 4, 2007 Author Share Posted January 4, 2007 Anyhow I will try for that Murray. Thanks alot for your help. I got an another issue. I am using crosstab in my report. Can I limit the number of records printed in the each page of the report? Thanking you in anticipation. Link to comment Share on other sites More sharing options...
jmurray Posted January 5, 2007 Share Posted January 5, 2007 I don't know. Best post you crosstab question in the main forum. Link to comment Share on other sites More sharing options...
jmurray Posted January 8, 2007 Share Posted January 8, 2007 I managed to generate a InvocationTargetException by creating a duplicate field definition. When the compiler fails with this type of exception (wrapper) you need to scroll down through the exception log to find the root cause. In my case it was very clear: net.sf.jasperreports.engine.JRException: Duplicate declaration of field : ReceiptNum Link to comment Share on other sites More sharing options...
yadavillisridhar Posted January 8, 2007 Author Share Posted January 8, 2007 Hi.......I am getting java.lang.reflect.InvocationTargetException while compiling my report which is having a scriplet. How to avoid that. The log file is as below :Compiling scriptlet source file... C:iReport-1.2.5SL43Scriptlet.javaError compiling the Scriptlet java source!java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.sf.jasperreports.engine.design.JRJdk13Compiler.compileClasses(JRJdk13Compiler.java:88) at net.sf.jasperreports.engine.design.JRAbstractMultiClassCompiler.compileClass(JRAbstractMultiClassCompiler.java:45) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:286) at java.lang.Thread.run(Unknown Source)Caused by:java.lang.VerifyError: class com.sun.tools.javac.jvm.Target overrides final method at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at com.sun.tools.javac.Main.compile(Main.java:52) ... 8 moreNESTED BY: net.sf.jasperreports.engine.JRException: Error compiling report java source files : C: iReport-1.2.5SL43Scriptlet.java at net.sf.jasperreports.engine.design.JRJdk13Compiler.compileClasses(JRJdk13Compiler.java:119) at net.sf.jasperreports.engine.design.JRAbstractMultiClassCompiler.compileClass(JRAbstractMultiClassCompiler.java:45) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:286) at java.lang.Thread.run(Unknown Source)Caused by:java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.sf.jasperreports.engine.design.JRJdk13Compiler.compileClasses(JRJdk13Compiler.java:88) ... 3 moreCaused by:java.lang.VerifyError: class com.sun.tools.javac.jvm.Target overrides final method at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknowxan Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at com.sun.tools.javac.Main.compile(Main.java:52) ... 8 moreCompilation running time : 47Please help me in getting solution........Thanking you,Sridhar Yadavilli 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