Jump to content
We've recently updated our Privacy Statement, available here ×

therrick_1

Members
  • Posts

    16
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by therrick_1

  1. Same where getting "java.lang.ClassNotFoundException: com.jss.SayHello" trying to use Scriptlet in Jasper Studio 6.1. I've added the jar to the Java Build Path Library and also put the .class and .jar files in the bin folder and added that as a Source and added those files to the same folder as the .jrxml. I've added the .jar and .class files in 3 different locations for Jaspersoft to find them, but why can't it?
  2. UPDATE: After closing and re-opening the report, now the Scriptlet_1_SCRIPTLET parameter is set as a class of com.jss.SayHello. So that is progress I guess. However, now I get the error "java.lang.ClassNotFoundException: com.jss.SayHello". I've added the jar to the Java Build Path Library and also put the .class and .jar files in the bin folder and added that as a Source and added those files to the same folder as the .jrxml. I've added the .jar and .class files in 3 different locations for Jaspersoft to find them, but why can't it?
  3. Created public java class using Eclipse that has a public static method getHello() that returns a String. Created jar file and added as external jar to Jaspersoft Studio report Java Build Path. Set report properties Scriptlet Class to com.jss.SayHello. Created Scriptlet in report and set Class to fully qualified package class as com.jss.SayHello where SayHello is the name of my class. That automatically created a Parameter called Scriptlet_1_SCRIPTLET. I tried to set the parameter Scriptlet_1_SCRIPTLET properties to class of com.jss.SayHello, but it won't let me. It keeps reverting back to net.sf.jasperreports.engine.JRDefaultScriptlet. I put the parameter scriptlet on my report and set the expression to $P{Scriptlet_1_SCRIPTLET].getHello(). When I run the report, I get a compile error that reads "The method getHello() is undefined for the type JRDefaultScriptlet. My Java code and jrxml code is below, any ideas how to fix this: Java code: package com.jss;import net.sf.jasperreports.engine.JRDefaultScriptlet;public class SayHello extends JRDefaultScriptlet { public static String getHello(){String str = "My Scriptlet Hello";return str;} public static void main(String[] args) {}}jrxml code: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0 --><!-- 2015-08-25T09:45:22 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="JSSJava1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" scriptletClass="com.jss.SayHello" uuid="3ef02621-d7e5-4a11-8b8d-9b1b3182cc8b"><property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/><scriptlet name="Scriptlet_1" class="com.jss.SayHello"/><queryString><![CDATA[]]></queryString><background><band splitType="Stretch"/></background><title><band height="79" splitType="Stretch"/></title><pageHeader><band height="35" splitType="Stretch"/></pageHeader><columnHeader><band height="61" splitType="Stretch"/></columnHeader><detail><band height="125" splitType="Stretch"><textField><reportElement x="278" y="57" width="100" height="30" uuid="b378a8e1-f235-4d45-aa71-8fd86b201824"/><textFieldExpression><![CDATA[$P{Scriptlet_1_SCRIPTLET}.getHello()]]></textFieldExpression></textField></band></detail><columnFooter><band height="45" splitType="Stretch"/></columnFooter><pageFooter><band height="54" splitType="Stretch"/></pageFooter><summary><band height="42" splitType="Stretch"/></summary></jasperReport>
  4. Still not able to get it to work. Set it up like anbalagan said, but not working. Tried various settings of the "path" Field, but get various errors like: Unknown Column name path in result set. GetFileLoc (wrong name: com/jasper1/GetFileLoc com.jasper1.GetFileLoc cannot be resolved to a type I guess I'll try the Scriptlet approach. Created jar file and put in Jaspersoft Build path. Java code is: package com.jasper1; import java.io.File; import java.util.HashMap; import java.util.Map; import net.sf.jasperreports.engine.JREmptyDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperFillManager; public class GetFileLoc { public static Map getLoc(){ File currentDir = new File(""); String filePath = currentDir.getAbsolutePath(); Map parameters=new HashMap(); parameters.put("path",filePath); String jsFileName = "C:\Users\user1\JaspersoftWorkspace\JSSJava\JSSJava1.jrxml"; try { JasperFillManager.fillReport(jsFileName, parameters, new JREmptyDataSource()); } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); } //String loc = currentDir.toString(); return parameters; } public static void mcomain(String[] args){ // String loc = GetFileLoc.getLoc(); // System.out.println(loc); } }// close class
  5. Still not able to get it to work. Set it up like anbalagan said, but not working. Tried various settings of the "path" Field, but get various errors like: Unknown Column name path in result set. GetFileLoc (wrong name: com/jasper1/GetFileLoc com.jasper1.GetFileLoc cannot be resolved to a type I guess I'll try the Scriptlet approach. Java code is: package com.jasper1; import java.io.File; import java.util.HashMap; import java.util.Map; import net.sf.jasperreports.engine.JREmptyDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperFillManager; public class GetFileLoc { public static Map getLoc(){ File currentDir = new File(""); String filePath = currentDir.getAbsolutePath(); Map parameters=new HashMap(); parameters.put("path",filePath); String jsFileName = "C:\Users\user1\JaspersoftWorkspace\JSSJava\JSSJava1.jrxml"; try { JasperFillManager.fillReport(jsFileName, parameters, new JREmptyDataSource()); } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); } //String loc = currentDir.toString(); return parameters; } public static void mcomain(String[] args){ // String loc = GetFileLoc.getLoc(); // System.out.println(loc); } }// close class
  6. I get compile error "GetFileLoc.getLoc cannot be resolved to a type" and "Errors were encountered when compiling report expressions class file". Java is this: package testJSS;import java.io.File;public class GetFileLoc {public static String getLoc(){File currentDir = new File("").getAbsoluteFile();String loc = currentDir.toString();return loc;} public static void main(String[] args){// String loc = GetFileLoc.getLoc();// System.out.println(loc);}}// close classText Field expression in Report is this: (new GetFileLoc.getLoc()) Went into Project > Properties > Java Build Path > Libraries and added the External Jar. Any ideas?
  7. Thanks for the quick reply! Where does the java code go? I expect it gets compiled into a .class file, right? Then what, do I put the .class file in the Jaspersoft Project's > Java Build Path > bin folder? And how does the Report instantiate the .class file? Does it call a java Constructor or a static method? I've seen videos for how to create Jasper Reports by using java code as the driver, but not how to get data using java code with Jasper Report as the driver.
  8. I want to print the file location of where it's stored on hard disk in the footer of each page. This java code prints the directory location, but how do I incorporate this into Jaspersoft Studio 6.1 to get to print in page footer?: import java.io.File;File currentDir = new File("").getAbsoluteFile();System.out.println(currentDir.toString());
  9. The Expression doesn't go in the Salary field. Create a generic Style and then create Conditional Styles under it. Conditional Styles are where the expressions and setting the colors goes. In the Salary field, you just set it to use the generic Style you created. See similar post: http://community.jaspersoft.com/questions/911946/conditional-formatting-studio
  10. That worked, thanks. I created a Style and then created 3 Conditional Styles under it. Each Conditional Style had a test and set the color. Then I applied the main Style to my field in the report. Had much trouble comparing BigDecimals, so I changed them to Doubles instead.
  11. I'm using Studio 6.1 and trying to do conditional formatting with a product Weight field. I want to set a range such as 50-75. If the Weight is between that range it's colored yellow, if Weight above that range it's colored red, and if Weight below that range it's colored green. I'm not sure where to put the Condition and how to Apply it. Has anyone done something similar and can help me?
  12. Using Jasper Studio 6.1 and have a Style called "RedLetters" with red forecolor, and a Field called "Salary". If Salary is above 50,000 then I want to apply "RedLetters" style. This way anyone making more than 50,000 will show up with red letters in my report. But I can't find anywhere in the "Salary" Field to put the expression "IF Salary > 50000 THEN apply RedLetters Style". Any ideas?
  13. I didn't try using squirrel sql client and searching for the hsql database. I talked to a Jasper Rep and they weren't sure of how to find the data defn. So I'll go with the MySql and use hozawa's ddl.
  14. figured it out, used com.microsoft.sqlserver.jdbc.SQLServerDriver driver and had to use the URL of jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks2012; and that worked.
  15. My Data Adapter Test says "Successful" when connecting to SQL database AdventureWorks2012_Data.mdf. But when I choose it as a Source in my Studio report, none of the tables show. Tried other drivers, but only the org.hsqldb.jdbcDriver gives a succesful Test. Any ideas?
  16. I'm working thru the Jaspersoft Studio and JasperReports Server tutorials using the sample data sources. I've tried to look at the data to find Primary/Foreign Keys and also data types such as VarChar, Integer, etc... How do I find that info with the sample data provided?
×
×
  • Create New...