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

prezakis

Members
  • Posts

    4
  • 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 prezakis

  1. Hello, I am deploying reports using the iReport 2.0.5 and I am facing the following problem: I have added an element at the Report that may take null values. I do not want this element to be printed at the report when its value is null. So, I assigned the value "true" to the isBlankWhenNull and isRemoveLineWhenBlank properties. Nevertheless, the element is not printed at its specified position at the Report, a blank space with the same size as the size of the textField is reserved at the end of the page. See the attached image test1.tif (I marked the initial position of the element with a red line and the reserved space at the end of the page with a red window - I have added some black lines in order to distinguish the position of the elements at the Report -). I quote the specification of such an element extracted from the .jrxml file. <textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="560" width="535" height="15" key="textField-140" isPrintRepeatedValues="false" isRemoveLineWhenBlank="true"/> <box></box> <textElement verticalAlignment="Middle"> <font reportFont="Fields"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{FPersIns1}]]></textFieldExpression> </textField> Could you please give me a tip on how I could hide this field when it takes null values and save the space at the end of the page (no blank space will be reserved)? I have tested it with iReport 3.7.0, but I took the same results. I would really appreciate if you could help me.
  2. Hi everyone, I tried to send a report to printer using this sample. It works,but the result is not what I wanted. More specifically,I have a client-server web application and I want to send a report from a client to a printer that is connected with the client's local network. Using this sample I get the PRINT DIALOG at the server machine , but I want it at the client's pc. Can anyone help with this? Thank you in advance, Antonis.
  3. Sorry for the previous post.Iam using my cell phone.I will try it again from my pc when i will be at home.
  4. Hi everyone, I am new in iReport & JasperReports. I want to pass more than one lists in iReport. I have searched and realised that the best practise is using subreports. So, I have created a datasource (datasource2) for the master report and another one for my subreport (datasource1). I fill these datasource using the following code. " public void generateListReport(TestReport2 testReport2, List MyList, String parameter,String JasperPath,String JasperPath2) throws IOException, JRException{ ArrayList WholeList = new ArrayList(); ArrayList DTList = new ArrayList(); ArrayList myTestReport = new ArrayList(); Map parameters = new HashMap(); myTestReport.add(testReport2); facesContext = FacesContext.getCurrentInstance(); ExternalContext ctx = facesContext.getExternalContext(); HttpServletResponse response = (HttpServletResponse) ctx.getResponse(); response.setContentType("application/pdf"); System.out.println("MyList : "+MyList); System.out.println("testReport2 : "+testReport2); System.out.println("myTestReport : "+myTestReport); for (int i = 0; i < MyList.size(); i++) { myListArray myList = new myListArray( (String) ((List) MyList.get(i)).get(0), (String) ((List) MyList.get(i)).get(1), (String) ((List) MyList.get(i)).get(2)); DTList.add(myList); } WholeList.add(DTList); WholeList.add(myTestReport); System.out.println("datasource 1 filled with WholeList : " + WholeList); String reportFileName = ((ServletContext) ctx.getContext()).getRealPath(JasperPath); String reportFileName2 = ((ServletContext) ctx.getContext()).getRealPath(JasperPath2); JasperReport jasperReport,subReport; try { subReport = (JasperReport) JRLoader.loadObject(reportFileName2); JRDataSource dataSource1 = new myListArrayDatasource().create(subReport, DTList); parameters.put("dataSource1", dataSource1); parameters.put("subReport", subReport); JasperPrint jasperPrint = JasperFillManager.fillReport(subReport, parameters, dataSource1); System.out.println("SubReport is filled!"); } catch (JRException e) { System.out.println("SubReport is not filled!"); e.printStackTrace(); } try { jasperReport = (JasperReport) JRLoader.loadObject(reportFileName); JRDataSource dataSource2 = new TestReportDatasource().create(jasperReport, myTestReport); JasperPrint jasperPrint2 = JasperFillManager.fillReport(jasperReport, parameters, dataSource2); System.out.println("Report is filled!"); try { JasperExportManager.exportReportToPdfStream(jasperPrint2,response.getOutputStream()); } catch (Exception e1) { e1.printStackTrace(); } } catch (JRException e) { System.out.println("Report is not filled!"); e.printStackTrace(); } facesContext.responseComplete(); } " "TestReportDatasource.java": " package reports; import java.util.ArrayList; import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; import net.sf.jasperreports.engine.JRParameter; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.data.JRAbstractBeanDataSourceProvider; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; public class TestReportDatasource extends JRAbstractBeanDataSourceProvider { public TestReportDatasource() { super(TestReport.class); } public JRField[] getFields(JasperReport report) throws JRException { if (report != null) { System.out.println(report); JRParameter[] params = report.getParameters(); for (int i = 0; i < params.length; ++i) { System.out.println(params.getName() + " " + params.getDefaultValueExpression()); } String[] properties = report.getPropertyNames(); for (int i = 0; i < properties.length; ++i) { System.out.println(properties + " = " + report.getProperty(properties)); } } return super.getFields(report); } public JRDataSource create(JasperReport report) throws JRException { ArrayList list = new ArrayList(); return new JRBeanCollectionDataSource(list); } public JRDataSource create(JasperReport report, ArrayList list) throws JRException { return new JRBeanCollectionDataSource(list); } public void dispose(JRDataSource dataSource) throws JRException { // nothing to do } } " "myListArrayDatasource.java": " package reports; import java.util.ArrayList; import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; import net.sf.jasperreports.engine.JRParameter; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.data.JRAbstractBeanDataSourceProvider; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; public class myListArrayDatasource extends JRAbstractBeanDataSourceProvider { public myListArrayDatasource() { super(myListArray.class); } public JRField[] getFields(JasperReport report) throws JRException { if (report != null) { System.out.println(report); JRParameter[] params = report.getParameters(); for (int i = 0; i < params.length; ++i) { System.out.println(params.getName() + " " + params.getDefaultValueExpression()); } String[] properties = report.getPropertyNames(); for (int i = 0; i < properties.length; ++i) { System.out.println(properties + " = " + report.getProperty(properties)); } } return super.getFields(report); } public JRDataSource create(JasperReport report) throws JRException { ArrayList list = new ArrayList(); return new JRBeanCollectionDataSource(list); } public JRDataSource create(JasperReport report, ArrayList list) throws JRException { return new JRBeanCollectionDataSource(list); } public void dispose(JRDataSource dataSource) throws JRException { // nothing to do } } " I declare a parameter dataSource1 and subReport in iReport *.jrxml file and, using the iReport's subreport wizard I connect the subreport(two objects,one for testing the connection via parameter "dataSource1" and another for testing parameter "subReport") with the master report. I cannot successfully fill the subreport in the master report. I would appreciate any help! Thank you in advance.
×
×
  • Create New...