Icarus_project Posted November 15, 2007 Share Posted November 15, 2007 hello everybody this is my first post on this forum and it is about a little probem i have when i use scriptlets (i bet you didnt see that one coming :) ) The problem is that my report fails to fill. i get the following error: ** start of error i get** Error retrieving field value from bean : $P{REPORT_SCRIPTLET}.hello() and a bit further, i get this: Caused by: java.lang.NoSuchMethodException: Unknown property '$P{REPORT_SCRIPTLET}'** end of the error ** My scriptlet is extending JRAbstractScriptlet, and the method hello looks like this: ** java code **public String hello(){ return "hello world!"; }** end of java code** In my report i have a simple textfield with the following expression: ** expression of field**$P{REPORT_SCRIPTLET}.hello() also tried: (reports.Test_script)$P{REPORT_SCRIPTLET}.hello() (and Test_script is the name of the scriptlet) and also this((reports.Test_script)$P{REPORT_SCRIPTLET}).hello() ** end of expression of field** As you can see, this is all very basic. i was following the "scriptlet" sample that comes with jasperreports. i have searched a lot already, try numerous things, and a forum is always my last resort. Any help or comments are very much appreciated. thanks in advance, Icarus_Project Link to comment Share on other sites More sharing options...
svenn Posted November 15, 2007 Share Posted November 15, 2007 To call your scriplet the syntax is $P{REPORT_SCRIPTLET}.nameofmethod(passed parameters) In your case $P{REPORT_SCRIPTLET}.hello() is correct. In the report properties are you pointing to your scriptlet class? To set this got to Report properties -> Scriplet Class Set to "Use this scriplet class" Now put your scriplet class in the text area. Link to comment Share on other sites More sharing options...
marcosmalfatti Posted November 16, 2007 Share Posted November 16, 2007 Hello! I have problems with scriptlets, if I use the Scriptlet Editor, when compile I get the error: CausedÂby:Âjava.lang.ClassNotFoundException:Âcom.sun.tools.javac.Main.If I set "Use This Scriptlet Class", in report properties, I get the error: java.lang.ClassNotFoundException:ÂTesteScriptlet.The class name is correctly. The .java and .jrxml files are attached. Any help is welcome. [file name=TesteScriptlet.zip size=1792]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/TesteScriptlet.zip[/file] Link to comment Share on other sites More sharing options...
Icarus_project Posted November 19, 2007 Author Share Posted November 19, 2007 Hello! Thanks svenn for your post. The property field was filled in though, but i entered the name of the scriplet again, rebuilt the jrxml and then it worked. thanks for your reply. As for marcosmalfatti, are you aware that the name of your scriptlet class is TesteScriptletScriptlet instead of TesteScriptlet as you stated? Also i have noticed that your scriptlet extends IReportScriptlet. I am sure i should work as well, but you could try to extend JRAbstractScriptlet. It worked for me. I started with a JRDefaultScriptlet extension, and it didnt work. Just a suggestion. Normally it shouldnt matter, but you never know, right? thanks again for the replies Link to comment Share on other sites More sharing options...
svenn Posted November 20, 2007 Share Posted November 20, 2007 You can extend JRAbstractScriptlet or JRDefaultScriptlet. The only difference is that JRAbstractScriptlet gives you access to additional methods. To learn more you can refer to the Jasper API http://jasperreports.sourceforge.net/api/index.html Link to comment Share on other sites More sharing options...
marcosmalfatti Posted November 20, 2007 Share Posted November 20, 2007 I changed the report parameter, but doesn´t work. I think that missed configurations in the PATH or CLASSPATH environment variables. What I need set in this variables?? 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