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

2006 IR Open Dicussion

Members
  • Posts

    1,900
  • Joined

  • Last visited

  • Days Won

    1

2006 IR Open Dicussion last won the day on May 29

2006 IR Open Dicussion had the most liked content!

2006 IR Open Dicussion's Achievements

Grand Master

Grand Master (14/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

1

Reputation

  1. By: Thierry Thomas - tthierry iReport 1.2.6 hangs 2006-09-07 13:35 iReport launches the splash screen, and hangs at "Loading available font family names". With a verbose output, it stops at: [Loaded org.flexdock.docking.props.BasicDockingPortPropertySet from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.docking.props.ScopedDockingPortPropertySet from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.docking.props.RootDockingPortPropertySet from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.docking.defaults.DefaultRegionChecker from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.dockbar.event.DockablePropertyChangeHandler from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.docking.defaults.DockablePropertyChangeHandler from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.util.DockingUtility from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.util.SwingUtility from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.plaf.theme.ButtonUI$ToggleListener from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.view.model.ViewButtonModel from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded it.businesslogic.ireport.gui.MainFrame$228 from file:/usr/local/share/java/classes/iReport.jar] [Loaded org.flexdock.view.actions.DefaultPinAction$PinButtonModel from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded javax.swing.JApplet from /usr/local/jdk1.5.0/jre/lib/rt.jar] [Loaded javax.swing.JWindow from /usr/local/jdk1.5.0/jre/lib/rt.jar] [Loaded org.flexdock.docking.event.hierarchy.RootDockingPortInfo from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.docking.defaults.DefaultDockingStrategy$DockingResults from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.docking.floating.frames.DockingFrame from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.perspective.DockingStateListener$1 from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] [Loaded org.flexdock.util.SwingUtility$2 from file:/usr/local/share/java/classes/flexdock-0.4.1.jar] I have tried to increase -Xms and -Xmx, but that does not help. I'm using the following JRE: java version "1.5.0-p3" Java 2 Runtime Environment, Standard Edition (build 1.5.0-p3-root_03_aug_2006_23_01) Java HotSpot Client VM (build 1.5.0-p3-root_03_aug_2006_23_01, mixed mode) (FreeBSD native) Regards, -- Th. Thomas.
  2. By: Rackam94 - rackam94 How to run a report 2006-09-07 06:25 Hello I have created a jasper report with ireport and I would like to run it without web server. I am looking for a simple tool where I could specify the report to run and then enter the parameters of the report, choose the export type (pdf, csv...) and vizualize the report. Do you a tool to do that?
  3. By: E-Nature - enature SQL query within a query-loop? 2006-07-17 07:51 I want to execute a second SQL query within another SQL query-loop. the first query looks like this (simplified): select id as QUESTIONID, question from questions; the query which should be executed within the loop of the first query looks like this (simplified): select score, count(score) as howmany from scores where question_id = QUESTIONID group by howmany, score; each question with its scores comes on the same line. the scores are between 1 and x. so the number of columns has to be dynamic. can anybody tell me how I can do this with iReport? thanks for any help in advance dominik
  4. By: Ali - adurmus Charting 2006-07-17 07:18 I have bought ireports manuel. But it is very overview. It should be more detailed. When I tried to create XY charting, i got below error. I didn't use grouping. thanks java.lang.NullPointerException at net.sf.jasperreports.charts.fill.JRFillCategoryDataset.customIncrement(JRFillCategoryDataset.java:136) at net.sf.jasperreports.engine.fill.JRFillElementDataset.increment(JRFillElementDataset.java:144) at net.sf.jasperreports.engine.fill.JRFillChartDataset.getDataset(JRFillChartDataset.java:57) at net.sf.jasperreports.engine.fill.JRFillChart.evaluateLineImage(JRFillChart.java:1029) at net.sf.jasperreports.engine.fill.JRFillChart.evaluateImage(JRFillChart.java:580) at net.sf.jasperreports.engine.fill.JRFillChart.evaluate(JRFillChart.java:546) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:279) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:220) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:750) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:647) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:716) at java.lang.Thread.run(Unknown Source) Print not filled. Try to use an EmptyDataSource...!
  5. By: F. Harasleben - friedrichh Nested parameters 2006-07-17 00:40 I tried to use nested parameters in my query (suggestion from jasper forum) but now get the following error (I am using iReports 0.5.0 to create/compile my reports) when creating the query based on the reports: "General problem: Source file: inline evaluation of: ....." What I did is: create a string parameter P_ACC_YEAR and a second parameter P_AM_CY_FROM based on the first one default expr = "01.01.".concat($P{P_ACC_YEAR}) when I use "01.01.".concat("2006") instead it works. Whats wrong friedrich
  6. By: Sebb - sdirat Blank Chart 2006-07-16 23:45 Hi, I used iReport to make a chart and everything seems to work but the chart appears like a blank picture. There is just white color! I don't understand because my database is not empty. I used: $F{Name} as key expression $V{SUM_Minutes_Spent_1} as value expression $F{Name} as label expression I try to show how long every name works. Thanks for the help
  7. By: Tony - tt_linux suppressing leading zeroes ... 2006-07-16 07:01 hi, I have a field (string) that has leading zeroes. How can i suppress the leading zeroes ? Eg. "0001" should be just "1" Help most appreciated. Thanks Tony By: Javy Dreamer - javydreamercsw RE: suppressing leading zeroes ... 2006-07-16 18:04 Try something like: new Integer().valueof($F{field_name}) in the field expression. make sure to make the Field of the integer type. I'm not really sure if it works. I don't have iReport in my laptop. I'll try it when I get at work on monday and let you know. If you try it befor let me know. By: Tony - tt_linux RE: suppressing leading zeroes ... 2006-07-16 19:06 hi Javy, i did: 1. set the field type to java.lang.integer 2. type in the above syntax. compile error. By: Tony - tt_linux RE: suppressing leading zeroes ... 2006-07-16 19:10 hi, BTW, the database field is in String, incase if you are wondering ... Only the report field $F{} is changed to Integer type in the above post.
  8. By: Andreas - andhjo Deploy in my own package iReport 0.5.2 2006-07-16 14:45 Hello, I have developed some reports successfully with iReport and all my .java files and files in have been located in the default package. Now I'm in the process of adding my reports to an application and I would like to know how to add my iReport files to my own package. package mypackage; If I add the above definition to my .java file, iReport will not notice this and just write over it at the next save with an empty line. Can I define in iReport that all my files should be in a package? When it comes to scriptlet it won´t find it, even if I write the following mypackage.myScriptlet in the report properties Regards /Andreas
  9. By: Tide - lovetide Can I manual select JRE to startup iReport ? 2006-07-15 04:48 I've installed jdk1.5.0_07 to C:jdk1.5.0_07, and installed public JRE of it, and then set JAVA_HOME =C:jdk1.5.0_07, and then add %JAVA_HOME%bin to PATH environment variable. Then I installed jdk1.6.0 to C:jdk1.6.0, no public JRE installed of it. Open any DOS console and type java -version, it report the right version I wanted: java version "1.5.0_07". But when I started iReport, click "Help"->"About iReport" -> "System properties", it shows me that all properties related JRE/JDK is 1.6.0, not 1.5.0_07, how can iReport so "intelligent" and how to manual choose JRE to startup it ?
  10. By: ts_chung - ts_chung combine 2 report into one 2006-06-30 18:20 i had created 2 reports and they works fine individually along. now the problem is i need to print two reports with only one click and i cannot figure a way to do it. thus, i try to create a new report with the 2 reports as the subreport. i works. however, the spaces in between had been ommited and thus the report format is different. for example some data should only show on page footer but it shows right after details. all the spaces in between disappear but if run that report along the format is correct. i am using ireport 0.5.3 currently. By: ts_chung - ts_chung RE: combine 2 report into one 2006-07-03 19:25 i had try to see if ireport v1.2.4 can solve this problem. apparently it still having the same problem. please help me on it. thank you. By: ts_chung - ts_chung RE: combine 2 report into one 2006-07-07 18:32 can anyone help me on this???? By: Dennis M - dennis2681 RE: combine 2 report into one 2006-07-10 12:22 check out this example -- it might help you. you can generate both the reports as byte[] and then combine them... works for me. https://sourceforge.net/forum/message.php?msg_id=2220337 By: ts_chung - ts_chung RE: combine 2 report into one 2006-07-10 18:08 thank dennis for your help. that is done using programatic way. is there a possible solution using ireport itself using the subreport? By: Dennis M - dennis2681 RE: combine 2 report into one 2006-07-11 11:44 not that i am aware of, no. if you are able to find something please post it here, because I (and others) would be interested. By: nat - nnogina RE: combine 2 report into one 2006-07-11 12:32 I usually don't have a problem with formatting. I use one report as a main report and second report as a subreport. make sure that subreport page margins are set to 0. I locate subreport usually in the header or footer of the fake group. But I am not sure what is your design requirements, so it may not work for you. By: ts_chung - ts_chung RE: combine 2 report into one 2006-07-14 19:24 nat, ur suggestion is not what i required. anyway, thanks for your suggestion. i got 2 reports that can work individually. this means my web application can print neither one of the report. there is one situation that need to print both report the same time. i create another report that use previous 2 reports as the subreport. the compilation is ok and runs ok. the only problem is that some space in between band of the subreport alignment lost. it is not the header, footer or margin thing.
  11. By: asumoto - asumoto UNABLE TO VIEW REPORT IN MY JAVA APP (URGENT) 2006-07-12 00:32 Currently i am using J2SDK1.4.2_07 for my java compiler and J2RE1.4.2_07 for my java runtime and MySql 3.23.55. I am also using IReport 0.1.0 version and everything work fine. I can successfully generate report from my java application by put the *.jasper file generate by IReport into my java program directory and i can call and view the report successfully. The jasper file is generated by IReport 0.1.0 To link the my java program with the report i need to copy few *.jar files from ireport library folder into my java runtime library folder. What i can say is everything works fine and i can successfully filter and generate my report from my java application. Problem occured when i upgrade IReport from 0.1.0 into 1.2.2. The IReport 1.2.2 generate jasper file also and i did the same thing by copy the jasper file into my java application. But when i run my java application to view the report I can not view the report at all and my java program generate an exception. The exception message below : java.lang.ClassCastException at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:288) at dori.jasper.engine.JasperManager.fillReport(JasperManager.java:810) at pos.PosReport.ReportFilter.goView(ReportFilter.java:581) i dont understand because this is happen only when my java program call the jasper file generated by IReport 1.2.2 but there is no problem when my java program call the jasper file generated by IReport 0.1.0 and i can see the report perfectly. I already copy the whole jar file under library folder from IReport 1.2.2 into my J2RE1.4.2_07 library folder, the same way i did to IReport 0.1.0 Is there something i need to change under my java coding? Can anybody pls write a sample java coding for me to call the report from java program? What are the classes that i need to import into my coding? Below is my currently java coding to filter and view the report. Its work with IReport 0.1.0 import dori.jasper.engine.*; import dori.jasper.view.*; import dori.jasper.engine.export.*; public class ReportFilter implements ActionListener { public ReportFilter { // all the source code for gui come to here JButton runButton = new JButton ("Run Report"); runButton.addActionListener(this); } public actionPerformed(ActionEvent e) { if(e.getSource().equals(runButton)) { goView(); } } //below is the code when user press run report button and it will call the jasper file and generate report to view private void goView() { // few GUI coding generate from here for generate the dialog box // below is the code to use jasper engine to call report // The error message above is generate from this code try { //System.out.println("1 - "+new java.util.Date()); JasperPrint jasperPrint = JasperManager.fillReport(file, parameters, getDataSource()); //System.out.println("4 - "+new java.util.Date()); //jasperPrint = JasperManager.fillReport(file, parameters, conn); JRViewer jrv = new JRViewer(jasperPrint); //System.out.println("5 - "+new java.util.Date()); dialog.getContentPane().add(jrv,BorderLayout.CENTER); } catch (Exception ex) { ex.printStackTrace(); } }} can anyone tell me what is wrong with the code above? The code above is work fine with jasper file generated by IReport 0.1.0 but it is failed when work with jasper file generated by IReport 1.2.2 Please help me it is very urgent. Does i need to copy jar file from ireport library into my java runtime library? If need which jar file i need to copy? By: Giulio Toffoli - gt78 RE: UNABLE TO VIEW REPORT IN MY JAVA APP (URGENT) 2006-07-13 01:05 Be sure you are using in your app the same JasperReports.jar version used with iReport: iReport 1.2.2 uses jasperreports-1.2.2.jar iReport 1.1.0 uses jasperreports-1.1.0.jar Giulio By: asumoto - asumoto RE: UNABLE TO VIEW REPORT IN MY JAVA APP (URGENT) 2006-07-13 19:24 hi Giulio currently my java program run for ireport ver 0.1.0 so i just copy all the *.jar files under ireport 0.1.0 lib folder into my J2RE1.4.2_07libext because my java application report all using ireport ver 0.1.0 and i got few report done use ireport 1.2.2 so i also copy all the *.jar files under ireport 1.2.2 into my J2RE1.4.2_07libext so there are a mixing *.jar files from ireport ver 0.1.0 library and ireport ver 1.2.2 library. Is it possible for me to do that because i have mixing jasper files version done by ireport 0.1.0 and ireport 1.2.2? Do i need to recompile all the jasper report i done under 0.1.0 with the ireport 1.2.2? I mix this *.jar files library from ireport 0.1.0 and ireport 1.2.2 because i still need report from my ireport 0.1.0 and after I MIXED all the *.jar files from both version, I still can view the jasper report done by version 0.1.0 perfectly but the jasper report done by version 1.2.2 can not be seen and it gave me error message like above. Please help me ......... Below is the *.jar files taken from ireport 0.1.0 library and ireport 1.2.2 library into my J2RE1.4.2_07libext : From ireport 0.1.0 library: ant.jar commons-beanutils.jar commons-collections.jar commons-digester.jar commons-logging.jar commons-logging-api.jar hsqldb.jar itext-0.96.jar jakarta-poi-1.5.1-final-20020615.jar jasperreports-0.4.6.jar xercesImpl.jar xmlParserAPIs.jar From IReport ver 1.2.2 lib: xml-apis.jar xercesImpl.jar --> currently this one i am using replace the ver 0.1.0 xalan.jar tools.jar --> this tools.jar taken from J2SDK1.4.2_07lib toniclf.jar tinylaf.jar poi-2.0-final-20040126.jar png-encoder-1.5.jar nsisant-1.1.jar mysql_comp.jar --> this mysql.jar file is taken from my previous mysql engine and i am not using mysql connector u provided under ireport 1.2.2 because it is doesn't work with my current database but i dont think its a problem since i am generate report from ireport 1.2.2 also using this jar file and the report works fine after i compile and view it under ireport 1.2.2 version. looks-2.0-rc.jar log4j-1.2.8.jar jxl.jar jta.jar jsmoothgen-ant-0.9.7.jar jr-bsh-compiler.jar jfreechart-1.0.0.jar jdt-compiler.jar jcommon-1.0.0.jar jcmdline-1.0.2.jar jasperreports-1.2.2.jar --> i have 2 jasperreports under my java runtime library folder. The first jasperreport is ver 0.4.6 as u can see above and the second is this jasperreport. I mixed it because i still need to view my old jasper report version done by ireport 0.1.0 and if i remove the old jasperreport version 0.4.6 i can not view my jasper report from my java application. itext-1.3.1.jar ireport.jar hsqldb-1.7.1.jar hibernate3.jar groovy-all-1.0-beta-10.jar ehcache-1.1.jar dom4j-1.6.jar commons-logging-api-1.0.2.jar commons-logging-1.0.2.jar commons-javaflow-20060411.jar commons-digester-1.7.jar commons-collections-2.1.jar commons-beanutils-1.5.jar cglib-2.1.jar bsh-1.3.0.jar barbecue-1.1.jar asm-attrs.jar asm.jar antlr-2.7.5H3.jar Thats all the jar files i put under J2RE1.4.2_07libext folder and i can view the old jasper report but can not view the new jasper report. If i delete the jaspperreport0.4.6.jar file and i put only the jasperreport1.2.2.jar file into my java runtime library folder it will generate error message for me and BOTH of the old jasper report ver 0.1.0 and jasper report ver 1.2.2 can not be seen...... The error message generated is: java.lang.NoClassDefFoundError : dori/jasper/engine/JRDataSource BUT IF I PUT BOTH THE JASPERREPORTS0.4.6.JAR AND JASPERREPORTS-1.2.2.JAR TOGETHER I CAN VIEW THE OLD JASPER REPORT GENERATE FROM IREPORT 0.1.0 PERFECTLY BUT I STILL CAN NOT SEE THE NEW JASPER REPORT GENERATE BY IREPORT 1.2.2 The error message given to me in this situation when i try to view the jasper report generated by ireport 1.2.2 is: java.lang.ClassCastException at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:288) at dori.jasper.engine.JasperManager.fillReport(JasperManager.java:810) Please help me.... is it possible to mix 2 jasperreports.jar into one java runtime library folder? what is the solution if i want to use both jasper report generated by ireport 0.1.0 and ireport 1.2.2 together in my java application? By: ts_chung - ts_chung RE: UNABLE TO VIEW REPORT IN MY JAVA APP (URGENT) 2006-07-14 18:40 i think it is not possible to use 2 jasperreports.jar library. however, i suggest that you recompile all your jasper report using ireport 1.2.2 and use only the jasperreport.jar library that in ireport 1.2.2. i hope this fix ur problem
  12. By: flavio - flavio_toledo Print values in Chart 2006-07-14 08:02 I made a Chart, but some values are printed on it (Oly big bars has the values, the small bars does't have), i need all values are printed on it. How i make this? Thanks. Flavio
  13. By: Vzern - vzern Subreport using XML datasource 2006-06-26 12:46 I need some help getting an XML datasource to work with subreports. or maybe I'm just trying to do a subreport incorrectly, but either way any help is welcomed. below are my source files. But what I'm trying to do is diplay the page number from the xml on the report (page is an xml tag, and number is an attribute), then from the subreport display all the rows of data from inside the page tag. Currently, all I am seeing is just the page numbers, but no rows of data. So what am I doing wrong? Oh and I'm doing all this inside of iReports 1.2.4 PS. After I get this stuff working. I'll try and write up a good example of the subreport with XML and submit it to both iReports and Jasperreports, so that other people won't have this problem. Thanks, Vzern MasterReport.jrxml <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="MasterReport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <parameter name="SUBREPORT_DIR" isForPrompting="false" class="java.lang.String"> <defaultValueExpression ><![CDATA["C:\Documents and Settings\dduffek\Desktop\Jasper\PR\Fresh\"]]></defaultValueExpression> </parameter> <queryString language="xPath"><![CDATA[/Report/page]]></queryString> <field name="pageNumber" class="java.lang.String"> <fieldDescription><![CDATA[@number]]></fieldDescription> </field> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="101" isSplitAllowed="true" > <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="23" y="2" width="162" height="46" key="textField-1"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{pageNumber}]]></textFieldExpression> </textField> <subreport isUsingCache="true"> <reportElement x="13" y="58" width="509" height="38" key="subreport-2" isPrintWhenDetailOverflows="true"/> <subreportParameter name="PageNumber"> <subreportParameterExpression><![CDATA[$F{pageNumber}]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression class="java.lang.String"><![CDATA["Subreport.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary> </jasperReport> Subreport.jrxml <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="Subreport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString language="xPath"><![CDATA[/Report/page[@number =1]/table/body/row]]></queryString> <field name="test" class="java.lang.String"> <fieldDescription><![CDATA[col[@cheadId =2]]]></fieldDescription> </field> <field name="LeaseNo" class="java.lang.String"> <fieldDescription><![CDATA[col[@cheadId =1]]]></fieldDescription> </field> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="27" isSplitAllowed="true" > <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="10" y="0" width="73" height="27" key="textField-2" isPrintWhenDetailOverflows="true"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font isPdfEmbedded ="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{test}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="90" y="0" width="113" height="27" key="textField-3" isPrintWhenDetailOverflows="true"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font isPdfEmbedded ="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{LeaseNo}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary> </jasperReport> data.xml <?xml version="1.0" encoding="utf-8" ?> <Report NAME="OFP3330"> <page pageId="1" number="1" type="summary" reportName="DET.S.NET.BBLS"> <number>1</number> <pageHeader> <headerData headerId="1" name="Date">Prepared date:</headerData> <headerData headerId="2" name="Date2">03/21/06</headerData> </pageHeader> <table> <header> <colName cheadId="1" name="name">name</colName> <colName cheadId="2" name="day">Date</colName> </header> <body> <row rowId="0"> <col cheadId="1" name="name">Acorn</col> <col cheadId="2" name="day">02/04/06</col> </row> <row rowId="1"> <col cheadId="1" name="name">Nergum</col> <col cheadId="2" name="day">02/05/06</col> </row> <row rowId="2"> <col cheadId="1" name="name">Nef</col> <col cheadId="2" name="day">02/01/06</col> </row> <row rowId="3"> <col cheadId="1" name="name">Joyous</col> <col cheadId="2" name="day">02/02/06</col> </row> </body> </table> </page> <page pageId="2" number="2" type="normal" reportName="DTC.NET.VALUE"> <number>2</number> <header> <headerData headerId="1" name="Date">Prepared date:</headerData> <headerData headerId="2" name="Date2">03/21/06</headerData> </header> <table> <header> <colName cheadId="1" name="ticket">Ticket</colName> <colName cheadId="2" name="number">Meter</colName> </header> <body> <row rowId="0"> <col cheadId="1" name="ticket">DYB_332</col> <col cheadId="2" name="number">33445</col> </row> <row rowId="2"> <col cheadId="1" name="ticket">DYB_6334</col> <col cheadId="2" name="number">99765</col> </row> </body> </table> </page> </Report> By: Wal Millard - walmillard RE: Subreport using XML datasource 2006-07-13 22:40 Vzern, If you had bothered to look you would have found many examples of using an xml datasource. Including in the distro of both Jasper and iReport. http://sourceforge.net/forum/message.php?msg_id=3154935 https://sourceforge.net/forum/message.php?msg_id=2838171 By: Wal Millard - walmillard RE: Subreport using XML datasource 2006-07-13 23:52 But alas no one can be bothered these days to even try to help themselves. Ur subreport object datasource is a datasource not a connection. And you need to pass the subreport the correct datasource expression for the xml structure. Also this is not a good example of using xml datasource. check prev post. set the Ex path to ur iReport datasource to //Report/page Here is some code : Master: <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="MasterReport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <parameter name="SUBREPORT_DIR" isForPrompting="false" class="java.lang.String"> <defaultValueExpression ><![CDATA["C:\Documents and Settings\dduffek\Desktop\Jasper\PR\Fresh\"]]></defaultValueExpression> </parameter> <queryString><![CDATA[/Report/page]]></queryString> <field name="pageNumber" class="java.lang.String"> <fieldDescription><![CDATA[@number]]></fieldDescription> </field> <group name="PageNumber" isStartNewColumn="false" isStartNewPage="false" isResetPageNumber="false" isReprintHeaderOnEachPage="false" minHeightToStartNewPage="0" > <groupExpression><![CDATA[$F{pageNumber}]]></groupExpression> <groupHeader> <band height="23" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="0" y="2" width="508" height="18" forecolor="#000000" backcolor="#66FF66" key="textField-1" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Master Report Page Number : " + $F{pageNumber}]]></textFieldExpression> </textField> </band> </groupHeader> <groupFooter> <band height="21" isSplitAllowed="true" > <subreport isUsingCache="true"> <reportElement mode="Opaque" x="0" y="0" width="509" height="20" forecolor="#000000" backcolor="#FFFFFF" key="subreport-2" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="true"/> <subreportParameter name="PageNumber"> <subreportParameterExpression><![CDATA[$F{pageNumber}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("//Report/page[@number = " + $F{pageNumber} +"]/table/body/row")]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["Subreport.jasper"]]></subreportExpression> </subreport> </band> </groupFooter> </group> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="0" isSplitAllowed="true" > </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary> </jasperReport> This is the subreport code. NOTE the Group and Group condition! <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="Subreport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString><![CDATA[/Report/page[@number =1]/table/body/row]]></queryString> <field name="test" class="java.lang.String"> <fieldDescription><![CDATA[col[@cheadId =2]]]></fieldDescription> </field> <field name="LeaseNo" class="java.lang.String"> <fieldDescription><![CDATA[col[@cheadId]]]></fieldDescription> </field> <field name="rowId" class="java.lang.String"> <fieldDescription><![CDATA[@rowId]]></fieldDescription> </field> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="20" isSplitAllowed="true" > <staticText> <reportElement mode="Opaque" x="0" y="2" width="100" height="14" forecolor="#000000" backcolor="#6666FF" key="staticText-1" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <text><![CDATA[Row ID]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="120" y="2" width="200" height="14" forecolor="#000000" backcolor="#FF66FF" key="staticText-2" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <text><![CDATA[Lease No]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="340" y="2" width="100" height="14" forecolor="#000000" backcolor="#FFFF66" key="staticText-3" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <text><![CDATA[Test Data]]></text> </staticText> </band> </columnHeader> <detail> <band height="19" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="340" y="2" width="100" height="15" forecolor="#000000" backcolor="#FFFFCC" key="textField-2" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="true"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="true" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{test}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="120" y="2" width="200" height="15" forecolor="#000000" backcolor="#FFCCFF" key="textField-3" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="true"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="true" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{LeaseNo}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="0" y="2" width="100" height="15" forecolor="#000000" backcolor="#CCCCFF" key="textField-4" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{rowId}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary> </jasperReport> enjoy! walmillard
  14. By: asumoto - asumoto UNABLE TO VIEW REPORT IN JAVA APP (CONTINUE) 2006-07-12 01:04 Sorry for the incomplete code i gave under the previous post. Below is my complete code for the ReportFilter class. The main problem is under run report button when user press run report button to view report. /* * ReportFilter.java * * Created on August 18, 2003, 12:12 AM */ /** * * @author ww */ package pos.PosReport; import mseries.Calendar.MDefaultPullDownConstraints; import mseries.Calendar.MDateSelector; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import java.sql.*; import java.text.SimpleDateFormat; import pos.PosBackOffice.GUI; import pos.PosBackOffice.Database; import pos.PosBackOffice.DbConfSet; import pos.PosBackOffice.ObjectStore; import pos.PosBackOffice.Components; import pos.PosBackOffice.Formula; import dori.jasper.engine.*; import dori.jasper.view.*; import dori.jasper.engine.export.*; public class ReportFilter implements ActionListener{ DbConfSet db = (DbConfSet)ObjectStore.getImportant("dbConnect"); Connection conn=db.getConnection(); private JFrame frame = GUI.mainGUI.mFrame; private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); private String cmpyName = db.getString("COMPANY"); private String imagePath = pos.PosApp.ObjectStore.getImagePath(); MDefaultPullDownConstraints cc; MDateSelector popup; SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); private boolean isloc = false; private boolean isdate = false; private boolean isdept = false; private boolean isreceipt = false; private boolean isitem = false; private boolean isprice = false; private boolean isstaff = false; private boolean isshift = false; private boolean istrans = false; private boolean isnumber = false; private boolean isspecial = false; private boolean ismch = false; // add by suhendy private JDialog fDialog; private JButton butRun,butCancel; private JLabel lblDisc,lblLoc,lblDate,lblDept,lblRec,lblItem,lblPrice,lblStaff,lblShift,lblTrans,lblNum,lblSup,lblTopSlowN,lblTopSlowBy, paymentTypeLbl, creditCardTypeLbl, serverLbl, lblMch; private JTextField LCODE,BNDATE1,BNDATE2,DCODE,TRANS,SUPCODE,TOPSLOWN,DISCOUNT1,DISCOUNT2; private JButton locButton,date1Button,date2Button,deptButton,transButton,supButton; private JComboBox RECEIPTNO1,RECEIPTNO2,ITEMCODE1,ITEMCODE2,PRICELEVEL,STAFF,SHIFT,NUMBER1,NUMBER2,TOPSLOWBY, paymentTypeJComboBox, creditCardTypeJComboBox, serverComBox, mchComBox; private ReportCheckBox cbLoc,cbDept,cbTrans,cbSup; private String[] strReceiptNo; private String[] strItemCode; private String[] strItemDesc; private String[] strItemString; private String[] strPriceLvl; private String[] strPriceDesc; private String[] strPriceString; private String[] strStaffCode; private String[] strStaffDesc; private String[] strStaffString; private String[] strShiftCode; private String[] strShiftDesc; private String[] strShiftString; private String[] strNumber; private String[] strTopSlow={"Quantity","Amount"}; private String[] strDiscount={"","0","5","10","15","20","25","30","35","40","45","50","55","60","65","70","75","80","85","90","95","100"}; private String[] returnLoc; private String[] returnDept; private String[] returnTrans; private String[] returnSup; private String[] paymentTypeStr; // add by suhendy private String[] creditCardTypeStr; // add by suhendy private String[] serverName; // add by suhendy private String[] serverCode; // add by suhendy private String[] serverNameNCode; // add by suhendy private String[] mchCode; // add by suhendy private String[] mchName; // add by suhendy private String[] mchCodeName; // add by suhendy private JasperPrint jasperPrint; private Map parameters; private String title; private String file; private String sql; private String tbl = "",tbl2 = ""; private JDialog dialog; private JButton exportPDF,exportHTML,exportXLS,exportCSV,cancel; private JFileChooser chooser; private ExampleFileFilter pdfFilter,htmlFilter,xlsFilter,csvFilter; private java.util.Date today; private String current = ""; private String filterName = ""; /** Creates a new instance of ReportFilter */ public ReportFilter() { } public ReportFilter(String fileTitle, String fileName, String sqlQuery, String tableName, String tableName2) { title = fileTitle; file = fileName; sql = sqlQuery; tbl = tableName; tbl2=tableName2; parameters = new HashMap(); parameters.put("CompanyName", cmpyName); try { String sql = "SELECT * FROM reportdetail WHERE REPNAME='"+title+"'"; Statement stmt = db.getStmt(); ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { current = rs.getString("REPCURRENT"); isloc = toBoolean(rs.getString("ISLOC")); isdate = toBoolean(rs.getString("ISDATE")); isdept = toBoolean(rs.getString("ISDEPT")); isreceipt = toBoolean(rs.getString("ISRECEIPT")); isitem = toBoolean(rs.getString("ISITEM")); isprice = toBoolean(rs.getString("ISPRICE")); isstaff = toBoolean(rs.getString("ISSTAFF")); isshift = toBoolean(rs.getString("ISSHIFT")); istrans = toBoolean(rs.getString("ISTRANS")); isnumber=toBoolean(rs.getString("ISNUMBER")); isspecial=toBoolean(rs.getString("ISSPECIAL")); ismch = toBoolean(rs.getString("ISMCH")); } } catch (SQLException e) { e.printStackTrace(); } if(!isloc && !isdate && !isdept && !isreceipt && !isitem && !isprice && !isstaff && !isshift && !istrans && !isnumber && !isspecial && !ismch) { goView(); } else { goFilter(); } } private boolean toBoolean(String tf) { if (tf.equals("T")) { return true; } else { return false; } } private void goFilter() { fDialog = new JDialog(frame,title,true); fDialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { fDialog.dispose(); } }); Container c = fDialog.getContentPane(); Font font = new Font("",Font.BOLD,12); //topPanel JPanel topPanel = new JPanel(); JLabel filterLabel = new JLabel("Filter Criteria",JLabel.CENTER); filterLabel.setOpaque(true); filterLabel.setBackground(new Color(127,157,232)); filterLabel.setFont(font); filterLabel.setPreferredSize(new Dimension(600,20)); topPanel.add(filterLabel); //middlePanel JPanel middlePanel = new JPanel(); middlePanel.setBorder(BorderFactory.createLoweredBevelBorder()); middlePanel.setLayout(null); int rh = 35; //location if (isloc) { lblLoc = Components.createLabel("","Location:",110,rh,150,20); LCODE = Components.createTextField("","",235,rh,200,23); locButton = Components.createButton("","L",440,rh,27,23); middlePanel.add(lblLoc); middlePanel.add(LCODE); middlePanel.add(locButton); rh = rh + 30; cbLoc = new ReportCheckBox("Location","location","LCODE","LNAME"); } if(ismch) // code add by suhendy { lblMch = Components.createLabel("", "Machine:", 110, rh, 150, 20); int countMch = Database.specificCount("machine"); mchCode = Database.specificRecords("machine", "MCH_NO", countMch); mchName = Database.specificRecords("machine", "MCH_DESC", countMch); mchCodeName = new String[countMch]; for(int imch=0; imch < countMch; imch++) { mchCodeName[imch] = mchCode[imch] + " - " + mchName[imch]; } countMch = countMch + 1; mchCode = Formula.reload(mchCode); mchName = Formula.reload(mchName); mchCodeName = Formula.reload(mchCodeName); mchComBox = Components.createSteppedComboBox("", mchCodeName, 235, rh, 200, 23); middlePanel.add(lblMch); middlePanel.add(mchComBox); rh = rh + 30; } //Date if (isdate) { lblDate = Components.createLabel("","Date:",110,rh,150,20); BNDATE1 = Components.createTextField("","",235,rh,75,23); BNDATE2 = Components.createTextField("","",385,rh,75,23); ImageIcon iconCal = new ImageIcon(imagePath + "calendar.gif"); iconCal.setImage(iconCal.getImage().getScaledInstance(27,20,1)); date1Button = Components.createButton("","",315,rh,27,23); date1Button.setIcon(iconCal); date2Button = Components.createButton("","",465,rh,27,23); date2Button.setIcon(iconCal); JLabel toLabel1 = Components.createLabel("","to",357,rh,27,23); cc = new MDefaultPullDownConstraints(); cc.firstDay = Calendar.SUNDAY; cc.background = Color.pink; popup = new MDateSelector(); popup.setConstraints(cc); middlePanel.add(lblDate); middlePanel.add(BNDATE1); middlePanel.add(BNDATE2); middlePanel.add(date1Button); middlePanel.add(date2Button); middlePanel.add(toLabel1); rh = rh + 30; } //department if (isdept) { lblDept = Components.createLabel("","Department:",110,rh,150,20); DCODE = Components.createTextField("","",235,rh,200,23); deptButton = Components.createButton("","D",440,rh,27,23); middlePanel.add(lblDept); middlePanel.add(DCODE); middlePanel.add(deptButton); rh = rh + 30; cbDept = new ReportCheckBox("Department","itemdepartment","DCODE","DDESC"); } //receipt no if (isreceipt) { lblRec = Components.createLabel("","Receipt No:",110,rh,150,20); String headertable = "theader"; if (current.equalsIgnoreCase("Sales")) { headertable = "atheader"; } int countReceipt = Database.specificCount(headertable); strReceiptNo = Database.specificRecords(headertable,"RECEIPTNO",countReceipt); countReceipt = countReceipt + 1; strReceiptNo = Formula.reload(strReceiptNo); RECEIPTNO1 = Components.createComboBox("",strReceiptNo,235,rh,105,23); RECEIPTNO2 = Components.createComboBox("",strReceiptNo,385,rh,105,23); JLabel toLabel2 = Components.createLabel("","to",357,rh,27,23); middlePanel.add(lblRec); middlePanel.add(RECEIPTNO1); middlePanel.add(RECEIPTNO2); middlePanel.add(toLabel2); rh = rh + 30; } //item code if (isitem) { lblItem = Components.createLabel("","Item Code:",110,rh,150,20); int countItem = Database.specificCount("itemmast1"); strItemCode = Database.specificRecords("itemmast1","PCODE",countItem); strItemDesc = Database.specificRecords("itemmast1","PDESC",countItem); strItemString = new String[countItem]; for (int i=0; i<countItem; i++) { strItemString = strItemCode + " - " + strItemDesc; } countItem = countItem + 1; strItemCode = Formula.reload(strItemCode); strItemDesc = Formula.reload(strItemDesc); strItemString = Formula.reload(strItemString); ITEMCODE1 = Components.createSteppedComboBox("",strItemString,235,rh,125,23); ITEMCODE2 = Components.createSteppedComboBox("",strItemString,405,rh,125,23); JLabel toLabel3 = Components.createLabel("","to",377,rh,27,23); middlePanel.add(lblItem); middlePanel.add(ITEMCODE1); middlePanel.add(ITEMCODE2); middlePanel.add(toLabel3); rh = rh + 30; } //price level if (isprice) { lblPrice = Components.createLabel("","Price Level:",110,rh,150,20); int countPrice = Database.specificCount("pricelvl"); strPriceLvl = Database.specificRecords("pricelvl","PRICE_LVL",countPrice); strPriceDesc = Database.specificRecords("pricelvl","PRICE_DESC",countPrice); strPriceString = new String[countPrice]; for (int i=0; i<countPrice; i++) { strPriceString = strPriceLvl + " - " + strPriceDesc; } countPrice = countPrice + 1; strPriceLvl = Formula.reload(strPriceLvl); strPriceDesc = Formula.reload(strPriceDesc); strPriceString = Formula.reload(strPriceString); PRICELEVEL = Components.createSteppedComboBox("",strPriceString,235,rh,180,23); middlePanel.add(lblPrice); middlePanel.add(PRICELEVEL); rh = rh + 30; } //staff if (isstaff) { lblStaff = Components.createLabel("","Staff:",110,rh,150,20); int countStaff = Database.specificCount("staff"); strStaffCode = Database.specificRecords("staff","STF_CODE",countStaff); strStaffDesc = Database.specificRecords("staff","STF_NAME",countStaff); strStaffString = new String[countStaff]; for (int i=0; i<countStaff; i++) { strStaffString = strStaffCode + " - " + strStaffDesc; } countStaff = countStaff + 1; strStaffCode = Formula.reload(strStaffCode); strStaffDesc = Formula.reload(strStaffDesc); strStaffString = Formula.reload(strStaffString); STAFF = Components.createSteppedComboBox("",strStaffString,235,rh,180,23); middlePanel.add(lblStaff); middlePanel.add(STAFF); rh = rh + 30; } //shift if (isshift) { lblShift = Components.createLabel("","Shift:",110,rh,150,20); int countShift = Database.specificCount("shift"); strShiftCode = Database.specificRecords("shift","SHF_CODE",countShift); strShiftDesc = Database.specificRecords("shift","SHF_DESC",countShift); strShiftString = new String[countShift]; for (int i=0; i<countShift; i++) { strShiftString = strShiftCode + " - " + strShiftDesc; } countShift = countShift + 1; strShiftCode = Formula.reload(strShiftCode); strShiftDesc = Formula.reload(strShiftDesc); strShiftString = Formula.reload(strShiftString); SHIFT = Components.createSteppedComboBox("",strShiftString,235,rh,180,23); middlePanel.add(lblShift); middlePanel.add(SHIFT); rh = rh + 30; } //inventory trans type if (istrans) { lblTrans = Components.createLabel("","Transaction Type:",110,rh,150,20); TRANS = Components.createTextField("","",235,rh,200,23); transButton = Components.createButton("","T",440,rh,27,23); middlePanel.add(lblTrans); middlePanel.add(TRANS); middlePanel.add(transButton); rh = rh + 30; cbTrans = new ReportCheckBox("Transaction Type","reference","REFCODE","REFDESC"); } //document number for audit list if (isnumber) { lblNum = Components.createLabel("","Number:",110,rh,150,20); int countNum = Database.specificCount(tbl); strNumber = Database.specificRecords(tbl,"REFNO",countNum); countNum = countNum+ 1; strNumber = Formula.reload(strNumber); NUMBER1 = Components.createComboBox("",strNumber,235,rh,105,23); NUMBER2 = Components.createComboBox("",strNumber,385,rh,105,23); JLabel toLabel2 = Components.createLabel("","to",357,rh,27,23); middlePanel.add(lblNum); middlePanel.add(NUMBER1); middlePanel.add(NUMBER2); middlePanel.add(toLabel2); rh = rh + 30; } //if any other special filter if(isspecial) { if((title.equals("Fast Moving Items")) || (title.equals("Slow Selling Items Report"))) { lblTopSlowN=Components.createLabel("","Top/Slow N:",110,rh,150,20); TOPSLOWN=Components.createTextField("","10",235,rh,100,23); middlePanel.add(lblTopSlowN); middlePanel.add(TOPSLOWN); lblTopSlowBy=Components.createLabel("","Top/Slow by:",375,rh,150,20); TOPSLOWBY=Components.createComboBox("",strTopSlow,450,rh,100,20); middlePanel.add(lblTopSlowBy); middlePanel.add(TOPSLOWBY); rh=rh+30; } else if(title.equals("Supplier History Report") || title.equals("Supplier Sales Report")||title.equals("Supplier Sales And Balance Report")||title.equals("Product List")){ lblSup = Components.createLabel("","Supplier:",110,rh,150,20); SUPCODE = Components.createTextField("","",235,rh,200,23); supButton = Components.createButton("","S",440,rh,27,23); middlePanel.add(lblSup); middlePanel.add(SUPCODE); middlePanel.add(supButton); rh = rh + 30; cbSup = new ReportCheckBox("Supplier","supplier","SUPCODE","SUPNAME"); } else if(title.equals("Discount Report") ) { lblSup = Components.createLabel("","Discount Rate:",110,rh,150,20); //DISCOUNT1 = Components.createComboBox("",strDiscount,235,rh,105,23); //DISCOUNT2 = Components.createComboBox("",strDiscount,385,rh,105,23); DISCOUNT1 = Components.createTextField("","",235,rh,105,23); DISCOUNT2 = Components.createTextField("","",385,rh,105,23); JLabel toLabel2 = Components.createLabel("","to",357,rh,27,23); middlePanel.add(DISCOUNT1); middlePanel.add(DISCOUNT2); middlePanel.add(toLabel2); middlePanel.add(lblSup); rh = rh + 30; } else if(title.equals("Summary Payment Media Collection")) // code add by suhendy to filter for payment type { int countPayment = Database.specificCount("payment"); paymentTypeStr = Database.specificRecords("payment", "PYCODE", countPayment); paymentTypeStr = Formula.reload(paymentTypeStr); paymentTypeLbl = Components.createLabel("", "Payment Type", 110, rh, 125, 20); paymentTypeJComboBox = Components.createComboBox("", paymentTypeStr, 235, rh, 130, 20); int countCardType = Database.specificCount("cardtype"); creditCardTypeStr = Database.specificRecords("cardtype", "CARD_DESC", countCardType); creditCardTypeStr = Formula.reload(creditCardTypeStr); creditCardTypeLbl = Components.createLabel("", "Card Type", 375, rh, 75, 20); creditCardTypeJComboBox = Components.createComboBox("", creditCardTypeStr, 450, rh, 130, 20); middlePanel.add(paymentTypeLbl); middlePanel.add(paymentTypeJComboBox); middlePanel.add(creditCardTypeLbl); middlePanel.add(creditCardTypeJComboBox); rh = rh + 30; } else if(title.equals("ServerReport")) // code by suhendy to filter the server name { int countServer = Database.specificCount("staff"); serverCode = Database.specificRecords("staff", "STF_CODE", countServer); serverName = Database.specificRecords("staff", "STF_NAME", countServer); serverNameNCode = new String[countServer]; for(int serverAt = 0; serverAt < countServer; serverAt++) { serverNameNCode[serverAt] = serverName[serverAt] + " - " + serverCode[serverAt]; } serverCode = Formula.reload(serverCode); serverName = Formula.reload(serverName); serverNameNCode = Formula.reload(serverNameNCode); serverLbl = Components.createLabel("", "Server", 110, rh, 125, 20); serverComBox = Components.createSteppedComboBox("", serverNameNCode, 235, rh, 180, 23); middlePanel.add(serverLbl); middlePanel.add(serverComBox); } } //bottomPanel JPanel bottomPanel = new JPanel(); butRun = new JButton("Run Report"); butCancel = new JButton("Cancel"); bottomPanel.add(butRun); bottomPanel.add(butCancel); //action Listener ButtonHandler handler = new ButtonHandler(); butRun.addActionListener(handler); butCancel.addActionListener(handler); if (isloc) locButton.addActionListener(handler); if (isdate) { date1Button.addActionListener(handler); date2Button.addActionListener(handler); } if (isdept) deptButton.addActionListener(handler); if (istrans) transButton.addActionListener(handler); if(isspecial && (title.equals("Supplier History Report") || title.equals("Supplier Sales Report")||title.equals("Supplier Sales And Balance Report")||title.equals("Product List"))){ supButton.addActionListener(handler); } c.add(topPanel,BorderLayout.NORTH); c.add(middlePanel,BorderLayout.CENTER); c.add(bottomPanel,BorderLayout.SOUTH); fDialog.setBounds(165,85,620,480); fDialog.setVisible(true); } private void goView() { dialog = new JDialog(frame,title,true); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dialog.dispose(); } }); JPanel topPanel = new JPanel(); topPanel.setBackground(Color.pink); dialog.getContentPane().add(topPanel,BorderLayout.NORTH); exportPDF = new JButton("Export PDF"); exportHTML = new JButton("Export HTML"); exportXLS = new JButton("Export Excel"); exportCSV = new JButton("Export CSV"); cancel = new JButton("Cancel"); topPanel.add(exportPDF); topPanel.add(exportHTML); topPanel.add(exportXLS); topPanel.add(exportCSV); topPanel.add(cancel); exportPDF.addActionListener(this); exportHTML.addActionListener(this); exportXLS.addActionListener(this); exportCSV.addActionListener(this); cancel.addActionListener(this); chooser = new JFileChooser(); chooser.setDialogType(JFileChooser.SAVE_DIALOG); pdfFilter = new ExampleFileFilter("pdf", "Portable Document File Files"); pdfFilter.setExtensionListInDescription(true); htmlFilter = new ExampleFileFilter("html", "Webpage Files"); htmlFilter.setExtensionListInDescription(true); xlsFilter = new ExampleFileFilter("xls", "Excel Files"); xlsFilter.setExtensionListInDescription(true); csvFilter = new ExampleFileFilter("csv", "Comma Separated Variable Files"); csvFilter.setExtensionListInDescription(true); try { //System.out.println("1 - "+new java.util.Date()); jasperPrint = JasperManager.fillReport(file, parameters, getDataSource()); //System.out.println("4 - "+new java.util.Date()); //jasperPrint = JasperManager.fillReport(file, parameters, conn); JRViewer jrv = new JRViewer(jasperPrint); //System.out.println("5 - "+new java.util.Date()); dialog.getContentPane().add(jrv,BorderLayout.CENTER); } catch (Exception ex) { ex.printStackTrace(); } dialog.setSize(screenSize.width,screenSize.height-30); //dialog.setLocationRelativeTo(frame); dialog.show(); } private JRResultSetDataSource getDataSource() { //System.out.println(sql); parameters.put("FilterName", filterName); Statement stmt = db.getStmt(); ResultSet rs = null; JRResultSetDataSource ds = null; //System.out.println("2 - "+new java.util.Date()); try { rs = stmt.executeQuery(sql); ds = new JRResultSetDataSource(rs); } catch (SQLException e) { e.printStackTrace(); } //System.out.println("3 - "+new java.util.Date()); return ds; } public void actionPerformed(java.awt.event.ActionEvent e) { if (e.getSource().equals(exportPDF)) { chooser.setAcceptAllFileFilterUsed(false); chooser.resetChoosableFileFilters(); chooser.addChoosableFileFilter(pdfFilter); int returnVal = chooser.showSaveDialog(dialog); String filePath=""; if(returnVal == JFileChooser.APPROVE_OPTION) { String fileName = chooser.getSelectedFile().getName(); boolean valid = false; if (fileName.indexOf(".pdf")!= -1) { valid = true; } filePath = chooser.getSelectedFile().getPath(); if (!valid) { filePath = filePath + ".pdf"; } try { JasperExportManager.exportReportToPdfFile(jasperPrint, filePath); } catch (Exception ee) { ee.printStackTrace(); } } } else if (e.getSource().equals(exportHTML)) { chooser.setAcceptAllFileFilterUsed(false); chooser.resetChoosableFileFilters(); chooser.addChoosableFileFilter(htmlFilter); int returnVal = chooser.showSaveDialog(dialog); String filePath=""; if(returnVal == JFileChooser.APPROVE_OPTION) { String fileName = chooser.getSelectedFile().getName(); boolean valid = false; if (fileName.indexOf(".html")!= -1 || fileName.indexOf(".htm")!=-1) { valid = true; } filePath = chooser.getSelectedFile().getPath(); if (!valid) { filePath = filePath + ".html"; } try { JasperExportManager.exportReportToHtmlFile(jasperPrint,filePath); } catch (Exception ee) { ee.printStackTrace(); } } } else if (e.getSource().equals(exportXLS)) { chooser.setAcceptAllFileFilterUsed(false); chooser.resetChoosableFileFilters(); chooser.addChoosableFileFilter(xlsFilter); int returnVal = chooser.showSaveDialog(dialog); String filePath=""; if(returnVal == JFileChooser.APPROVE_OPTION) { String fileName = chooser.getSelectedFile().getName(); boolean valid = false; if (fileName.indexOf(".xls")!= -1) { valid = true; } filePath = chooser.getSelectedFile().getPath(); if (!valid) { filePath = filePath + ".xls"; } try { JRXlsExporter exporter = new JRXlsExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filePath); exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE); exporter.exportReport(); } catch (Exception ee) { ee.printStackTrace(); } } } else if (e.getSource().equals(exportCSV)) { chooser.setAcceptAllFileFilterUsed(false); chooser.resetChoosableFileFilters(); chooser.addChoosableFileFilter(csvFilter); int returnVal = chooser.showSaveDialog(dialog); String filePath=""; if(returnVal == JFileChooser.APPROVE_OPTION) { String fileName = chooser.getSelectedFile().getName(); boolean valid = false; if (fileName.indexOf(".csv")!= -1) { valid = true; } filePath = chooser.getSelectedFile().getPath(); if (!valid) { filePath = filePath + ".csv"; } try { JRExporter exporter = new JRCsvExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,filePath); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.exportReport(); } catch (Exception ee) { ee.printStackTrace(); } } } else if (e.getSource().equals(cancel)) { dialog.setVisible(false); dialog.dispose(); } } public class ButtonHandler implements ActionListener { public void actionPerformed(java.awt.event.ActionEvent e) { if (e.getSource().equals(butRun)) { fDialog.setVisible(false); fDialog.dispose(); filterSQL(); goView(); } else if (e.getSource().equals(butCancel)) { fDialog.setVisible(false); fDialog.dispose(); } else if (e.getSource().equals(date1Button)) { Point p = new Point(80,60); popup.show(fDialog,p,null); if (popup.getValue()!= null) { BNDATE1.setText(df.format(popup.getValue())); } } else if (e.getSource().equals(date2Button)) { Point p = new Point(220,60); popup.show(fDialog,p,null); if (popup.getValue()!= null) { BNDATE2.setText(df.format(popup.getValue())); } } else if (e.getSource().equals(locButton)) { //cbLoc = new ReportCheckBox("Location","location","LCODE","LNAME"); cbLoc.show(); if (cbLoc.getOk()) { returnLoc = cbLoc.getValue(); goDisplay(returnLoc,LCODE); } } else if (e.getSource().equals(supButton)) { cbSup.show(); if (cbSup.getOk()) { returnSup = cbSup.getValue(); goDisplay(returnSup,SUPCODE); } } else if (e.getSource().equals(deptButton)) { //cbDept = new ReportCheckBox("Department","itemdepartment","DCODE","DDESC"); cbDept.show(); if (cbDept.getOk()) { returnDept = cbDept.getValue(); goDisplay(returnDept,DCODE); } } else if (e.getSource().equals(transButton)) { //cbTrans = new ReportCheckBox("Transaction Type","reference","REFCODE","REFDESC"); cbTrans.show(); if (cbTrans.getOk()) { returnTrans = cbTrans.getValue(); goDisplay(returnTrans,TRANS); } } } }; private void goDisplay(String[] answer, JTextField comp) { String newString = ""; for (int i=0; i<answer.length; i++) { if (i==0) { newString = "'"+answer+"'"; } else { newString = newString + ",'"+answer+"'"; } } comp.setText(newString); } private void filterSQL() { if (isspecial && (title.equals("Fast Moving Items")||title.equals("Slow Selling Items Report"))) { String n=TOPSLOWN.getText(); String viewby="",topslowSQL=""; int tsIndex = TOPSLOWBY.getSelectedIndex(); if(tsIndex==0) viewby="SUMQTY"; else if(tsIndex==1) viewby="SUMAMOUNT"; // the default sql from db is by SUMQTY desc, if view by Amount, change it to SUMAMOUNT desc sql=sql.replaceAll("SUMQTY desc",viewby+" desc"); // user input limit to show on report, pass as parameter to jasper parameters.put("LIMIT", new Double(n)); } String newSql = sql; char[] character = newSql.toCharArray(); int index = 0; for (int i=0; i<character.length; i++) { if (i+7<character.length) { if ("g".equalsIgnoreCase(String.valueOf(character)) && "r".equalsIgnoreCase(String.valueOf(character[i+1])) && "o".equalsIgnoreCase(String.valueOf(character[i+2])) && "u".equalsIgnoreCase(String.valueOf(character[i+3])) && "p".equalsIgnoreCase(String.valueOf(character[i+4])) && " ".equalsIgnoreCase(String.valueOf(character[i+5])) && "b".equalsIgnoreCase(String.valueOf(character[i+6])) && "y".equalsIgnoreCase(String.valueOf(character[i+7]))) { index = i; break; } else if ("o".equalsIgnoreCase(String.valueOf(character)) && "r".equalsIgnoreCase(String.valueOf(character[i+1])) && "d".equalsIgnoreCase(String.valueOf(character[i+2])) && "e".equalsIgnoreCase(String.valueOf(character[i+3])) && "r".equalsIgnoreCase(String.valueOf(character[i+4])) && " ".equalsIgnoreCase(String.valueOf(character[i+5])) && "b".equalsIgnoreCase(String.valueOf(character[i+6])) && "y".equalsIgnoreCase(String.valueOf(character[i+7]))) { index = i; break; } } } String part1 = ""; String part2 = ""; if (index != 0) { part1 = newSql.substring(0,index); part2 = newSql.substring(index,newSql.length()); } else { part1 = newSql; } if (isloc) { String myLoc = ""; if (!LCODE.getText().equals("")) { myLoc = cascadeMultiple(returnLoc,"LCODE") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myLoc; } else { part1 = part1 + " WHERE "+ myLoc; } } } // check by machine code if(ismch) { int mchCodeToFilterIndex = mchComBox.getSelectedIndex(); String mymch = ""; String paraMachine = "All"; if(mchCodeToFilterIndex != 0) { mymch = cascadeSelection(mchCode[mchCodeToFilterIndex], "MCH_NO") + " "; if(appearWhere(part1)) { part1 = part1 + " AND " + mymch; } else { part1 = part1 + " WHERE " + mymch; } paraMachine = mchName[mchCodeToFilterIndex]; } parameters.put("Machine", paraMachine); } // below filter add by suhendy if(isspecial && (title.equals("Summary Payment Media Collection"))) { String mypycode = ""; String mycardType = ""; if(paymentTypeJComboBox.getSelectedIndex() != 0) { mypycode = paymentTypeStr[paymentTypeJComboBox.getSelectedIndex()]; if(appearWhere(part1)) { part1 = part1 + " AND " + "atpayment.PYCODE = '" + mypycode + "' "; } else { part1 = part1 + " WHERE " + "atpayment.PYCODE = '" + mypycode + "' "; } if(creditCardTypeJComboBox.getSelectedIndex() != 0) { mycardType = creditCardTypeStr[creditCardTypeJComboBox.getSelectedIndex()]; if(appearWhere(part1)) { part1 = part1 + " AND " + "atpayment.CARD_TYPE = '" + mycardType + "' "; } else { part1 = part1 + " WHERE " + "atpayment.CARD_TYPE = '" + mycardType + "' "; } } } } // filter add by suhendy ends here // below code add by suhendy to filter for server name if(isspecial && (title.equals("ServerReport"))) { String serverNameToFilter = ""; String serverCodeToFilter = ""; if(serverComBox.getSelectedIndex() != 0) { serverNameToFilter = serverName[serverComBox.getSelectedIndex()]; serverCodeToFilter = serverCode[serverComBox.getSelectedIndex()]; if(appearWhere(part1)) { part1 = part1 + " AND " + "atdetail.SERVERNAME = '" + serverNameToFilter + "' AND atdetail.SERVERCODE = '" + serverCodeToFilter + "'"; } else { part1 = part1 + " WHERE " + "atdetail.SERVERNAME = '" + serverNameToFilter + "' AND atdetail.SERVERCODE = '" + serverCodeToFilter + "'"; } } } // filter server name ends here if (isspecial && (title.equals("Supplier History Report")||title.equals("Supplier Sales Report")||title.equals("Supplier Sales And Balance Report")||title.equals("Product List"))) { String mySup = ""; if (!SUPCODE.getText().equals("")) { mySup = cascadeMultiple(returnSup,"SUPCODE") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + mySup; } else { part1 = part1 + " WHERE "+ mySup; } } } if (isspecial && (title.equals("Discount Report"))) { //int discIndex1 = DISCOUNT1.getSelectedIndex(); //int discIndex2 = DISCOUNT2.getSelectedIndex(); boolean checkboolean1 = false; boolean checkboolean2 = false; String checking1 = DISCOUNT1.getText(); try { float chkflt1 = Float.parseFloat(checking1); checkboolean1 = true; } catch (NumberFormatException e) { checkboolean1 = false; } String checking2 = DISCOUNT2.getText(); try { float chkflt2 = Float.parseFloat(checking2); checkboolean2 = true; } catch (NumberFormatException e) { checkboolean2 = false; } if (checkboolean1 && checkboolean2) { String myDisc = ""; //if ((discIndex1 != 0) && (discIndex2 != 0)) { //myDisc = cascadeRange(strDiscount[discIndex1],(new Double(Double.parseDouble(strDiscount[discIndex2])+1)).toString(),"finalpct") + " "; //myDisc="("+"((tot_disc+frac_disc)/amount*100+0.5)"+">='"+strDiscount[discIndex1]+"' AND "+"((tot_disc+frac_disc)/amount*100+0.5)" +"<='"+ (new Double(Double.parseDouble(strDiscount[discIndex2])+1)).toString()+"')"; myDisc="("+"((tot_disc+frac_disc)/amount*100+0.5)"+">='"+checking1+"' AND "+"((tot_disc+frac_disc)/amount*100+0.5)" +"<='"+ (new Double(Double.parseDouble(checking2)+1)).toString()+"')"; if (appearWhere(part1)) { part1 = part1 + "AND " + myDisc; } else { part1 = part1 + " WHERE " + myDisc; } //} } } if (isdate) { String myDate = ""; if (!BNDATE1.getText().equals("") && !BNDATE2.getText().equals("")) { if (current.equalsIgnoreCase("Inventory")) { myDate = cascadeRange(BNDATE1.getText(),BNDATE2.getText(),"REFDATE") + " "; } else { myDate = cascadeRange(BNDATE1.getText(),BNDATE2.getText(),"BNDATE") + " "; } filterName = BNDATE1.getText() +" to " + BNDATE2.getText(); if (appearWhere(part1)) { part1 = part1 + "AND " + myDate; } else { part1 = part1 + " WHERE " + myDate; } } } if (isdept) { String myDept = ""; if (!DCODE.getText().equals("")) { myDept = cascadeMultiple(returnDept,"DCODE")+ " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myDept; } else { part1 = part1 + " WHERE " + myDept; } } } if (isreceipt) { int repIndex1 = RECEIPTNO1.getSelectedIndex(); int repIndex2 = RECEIPTNO2.getSelectedIndex(); String myReceipt = ""; if ((repIndex1 != 0) && (repIndex2 != 0)) { myReceipt = cascadeRange(strReceiptNo[repIndex1],strReceiptNo[repIndex2],"RECEIPTNO") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myReceipt; } else { part1 = part1 + " WHERE " + myReceipt; } } } if (isnumber) { int repIndex1 = NUMBER1.getSelectedIndex(); int repIndex2 = NUMBER2.getSelectedIndex(); String myNumber = ""; if ((repIndex1 != 0) && (repIndex2 != 0)) { myNumber = cascadeRange(strNumber[repIndex1],strNumber[repIndex2],"REFNO") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myNumber; } else { part1 = part1 + " WHERE " + myNumber; } } } if (isitem) { int itemIndex1 = ITEMCODE1.getSelectedIndex(); int itemIndex2 = ITEMCODE2.getSelectedIndex(); String myItem = ""; if ((itemIndex1 != 0) && (itemIndex2 != 0)) { myItem = cascadeRange(strItemCode[itemIndex1],strItemCode[itemIndex2],"PCODE") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myItem; } else { part1 = part1 + " WHERE " + myItem; } } } if (isprice) { int priceIndex = PRICELEVEL.getSelectedIndex(); String myPrice = ""; if (priceIndex!=0) { myPrice = cascadeSelection(strPriceLvl[priceIndex],"PRICE_LVL") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myPrice; } else { part1 = part1 + " WHERE " + myPrice; } } } if (isstaff) { int staffIndex = STAFF.getSelectedIndex(); String myStaff = ""; if (staffIndex!=0) { myStaff = cascadeSelection(strStaffCode[staffIndex],"STF_CODE") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myStaff; } else { part1 = part1 + " WHERE " + myStaff; } } } if (isshift) { int shiftIndex = SHIFT.getSelectedIndex(); String myShift = ""; String paraShift="All"; if (shiftIndex!=0) { myShift = cascadeSelection(strShiftCode[shiftIndex],"SHF_CODE") + " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myShift; } else { part1 = part1 + " WHERE " + myShift; } paraShift=strShiftCode[shiftIndex]; } parameters.put("Shift",paraShift); } if (istrans) { String myTrans = ""; if (!TRANS.getText().equals("")) { myTrans = cascadeMultiple(returnTrans,"REFCODE")+ " "; if (appearWhere(part1)) { part1 = part1 + "AND " + myTrans; } else { part1 = part1 + " WHERE " + myTrans; } } } sql = part1 + part2; System.out.println(sql); } private String cascadeMultiple(String[] array, String key) { String keytbl=checkField(key); String xx = ""; if (!keytbl.equals("")) { key = keytbl+"."+key; } for (int i=0; i<array.length; i++) { if (i==0) { xx = xx + key +"='"+array+"'"; } else { xx = xx + " OR " + key+"='"+array+"'"; } } return xx; } private String cascadeSelection(String value, String key) { String keytbl=checkField(key); String yy = ""; if (!keytbl.equals("")) { key = keytbl+"."+key; } yy = key + "='" + value + "'"; return yy; } private String cascadeRange(String value1, String value2, String key) { String keytbl=checkField(key); String zz = ""; if (!keytbl.equals("")) { key = keytbl+"."+key; } zz = "("+key+">='"+value1+"' AND "+key +"<='"+ value2+"')"; return zz; } private boolean appearWhere(String firstpart) { char[] character = firstpart.toCharArray(); boolean appear = false; for (int i=0; i<character.length; i++) { if (i+4<character.length) { if ("w".equalsIgnoreCase(String.valueOf(character)) && "h".equalsIgnoreCase(String.valueOf(character[i+1])) && "e".equalsIgnoreCase(String.valueOf(character[i+2])) && "r".equalsIgnoreCase(String.valueOf(character[i+3])) && "e".equalsIgnoreCase(String.valueOf(character[i+4]))) { appear = true; break; } } } return appear; } private String checkField(String key) { String keytbl; boolean exist=true; String sqltest=""; Statement stmt = db.getStmt(); ResultSet rs = null; try { sqltest="Select "+key+" from "+tbl; rs = stmt.executeQuery(sqltest); } catch (SQLException e) { e.printStackTrace(); exist=false; } if(exist) keytbl=tbl; else keytbl=tbl2; return keytbl; } } By: Giulio Toffoli - gt78 RE: UNABLE TO VIEW REPORT IN JAVA APP (CONTINUE) 2006-07-13 01:07 Does you report work with iReport? By: asumoto - asumoto RE: UNABLE TO VIEW REPORT IN JAVA APP (CONTINUE) 2006-07-13 19:41 Yes, my report works fine with IReport version 0.1.0 The source code above to do some filtering under my java application before I press "Run Report" button under my java GUI so I can filter few condition of my report. The jasper report generated by IReport 0.1.0 and its work perfectly and i am already using it for long time under this version 0.1.0. The source code above 100% compatible and works fine with IReport 0.1.0 The current coding i am using now to call the jasperreport engine is: import dori.jasper.engine.*; import dori.jasper.view.*; import dori.jasper.engine.export.*; private JasperPrint jasperPrint; private Map parameters; try { jasperPrint = JasperManager.fillReport(file, parameters, getDataSource()); // file is the jasper report file name for ex: customerDetail.jasper and parameters is the parameters i passed from my java program into the jasper report and getDataSource() method is written below JRViewer jrv = new JRViewer(jasperPrint); dialog.getContentPane().add(jrv,BorderLayout.CENTER); // this dialog window is the a dialog box contain the report } catch (Exception ex) { ex.printStackTrace(); } private JRResultSetDataSource getDataSource() { //System.out.println(sql); parameters.put("FilterName", filterName); Statement stmt = db.getStmt(); ResultSet rs = null; JRResultSetDataSource ds = null; //System.out.println("2 - "+new java.util.Date()); try { rs = stmt.executeQuery(sql); ds = new JRResultSetDataSource(rs); } catch (SQLException e) { e.printStackTrace(); } //System.out.println("3 - "+new java.util.Date()); return ds; }
×
×
  • Create New...