Results 1 to 2 of 2
  1. #1
    jambon is offline Member
    Join Date
    Nov 2009
    Posts
    9
    Rep Power
    0

    Default JSF with JasperSoft reports

    Hello,
    I don't know if this is the right forum for my question but it's the closest I could find.
    I'm trying to implememnt a repor from JasperSoft's IReports IDE and keep getting the error:
    Java Code:
     Caught JRException: Error evaluating expression : 
    	Source text : new java.lang.Integer(1)
    Here is my jrxml file:
    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <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="donationrules" language="groovy" pageWidth="1603" pageHeight="842" columnWidth="1563" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a95ce264-3559-482b-94de-839c6eb8471b">
    	<property name="ireport.zoom" value="1.0"/>
    	<property name="ireport.x" value="789"/>
    	<property name="ireport.y" value="0"/>
    	<style name="table">
    		<box>
    			<pen lineWidth="1.0" lineColor="#000000"/>
    		</box>
    	</style>
    	<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
    		<box>
    			<pen lineWidth="0.5" lineColor="#000000"/>
    		</box>
    	</style>
    	<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
    		<box>
    			<pen lineWidth="0.5" lineColor="#000000"/>
    		</box>
    	</style>
    	<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
    		<box>
    			<pen lineWidth="0.5" lineColor="#000000"/>
    		</box>
    	</style>
    	<subDataset name="Table Dataset 1" uuid="c2329b37-99a6-4b32-8deb-a5ee048f32b9"/>
    	<field name="donationRuleId" class="java.lang.String"/>
    	<field name="donationStatusTypeCode" class="java.lang.String"/>
    	<field name="donationTypeCode" class="java.lang.String"/>
    	<field name="countryCode" class="java.lang.String"/>
    	<field name="centerId" class="java.lang.Integer"/>
    	<field name="memberId" class="java.lang.Integer"/>
    	<field name="currencyCode" class="java.lang.String"/>
    	<field name="effectiveDate" class="java.lang.String"/>
    	<field name="endDate" class="java.lang.String"/>
    	<field name="value" class="java.lang.Double"/>
    	<field name="frequency" class="java.lang.String"/>
    	<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">
    			<staticText>
    				<reportElement uuid="c62b9242-a700-45a6-92ed-5fe23a1c19f6" mode="Opaque" x="410" y="3" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[DonationType]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="b5742c85-84f8-4b9b-9106-958f91daa120" mode="Opaque" x="1312" y="2" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[Value]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="412b3e02-50d9-4db4-82d1-6e74906f3625" mode="Opaque" x="1437" y="3" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[Frequency]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="8dc27395-36a7-427a-98ad-844b98afb535" mode="Opaque" x="225" y="2" width="151" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[Donation Category]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="92d94ed4-0ab4-4a3c-a1c5-7b89cfe7fcb0" mode="Opaque" x="553" y="0" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[Country]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="032bf4a2-0c8b-43d0-ba81-aa8d24f6ab9c" mode="Opaque" x="682" y="0" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[Center]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="57e192b1-0390-46ba-9e34-993e136c6da5" mode="Opaque" x="793" y="0" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<text><![CDATA[Member]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="0f9cfc29-9698-4abf-aae6-40867156c3f0" mode="Opaque" x="923" y="0" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[Currency]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="54a7d01c-56dd-4604-81b9-ce179fc70415" mode="Opaque" x="1059" y="0" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[Effective date]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="31f7c726-da65-4335-8f96-78c3f2beb3ae" mode="Opaque" x="1176" y="3" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="14"/>
    				</textElement>
    				<text><![CDATA[End Date]]></text>
    			</staticText>
    			<staticText>
    				<reportElement uuid="27f46788-5817-498d-92cf-be934bf4a617" mode="Opaque" x="54" y="3" width="100" height="20" backcolor="#FFCCCC"/>
    				<textElement>
    					<font size="10"/>
    				</textElement>
    				<text><![CDATA[donationruleid]]></text>
    			</staticText>
    		</band>
    	</columnHeader>
    	<detail>
    		<band height="125" splitType="Stretch">
    			<textField>
    				<reportElement uuid="72a8a3c3-6d69-4c8c-8b53-4d95852a97f8" x="1312" y="3" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="2fc383c5-f560-4016-ad9b-4af053732dac" x="1437" y="4" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{frequency}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="2ed007dc-b1f3-4a1e-907f-549afd1c4e3a" x="223" y="3" width="162" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{donationStatusTypeCode}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="f3e0b836-1df9-4163-b09a-1c7c5707a3e3" x="403" y="0" width="139" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{donationTypeCode}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="2c7951db-50aa-4c14-9323-1be057fe2f4e" x="553" y="5" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{countryCode}]]></textFieldExpression>
    			</textField>
    			<textField isBlankWhenNull="true">
    				<reportElement uuid="bca8cb06-0b8a-4f51-8f8e-e2fcd065f2fd" x="682" y="3" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{centerId}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="6a9f85cc-f500-4ca0-95c9-127850219d60" x="793" y="3" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{memberId}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="cf8e88fb-ecd1-466e-ba08-684af5d6174a" x="923" y="4" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{currencyCode}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="81f4c838-4165-48d2-bd05-0b81fc37beca" x="1059" y="3" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{effectiveDate}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="c4626ffa-fc83-42f0-90e5-defeee1f04c4" x="1176" y="5" width="100" height="20"/>
    				<textElement>
    					<font size="12"/>
    				</textElement>
    				<textFieldExpression><![CDATA[$F{endDate}]]></textFieldExpression>
    			</textField>
    			<textField>
    				<reportElement uuid="9b91108a-c2ba-4659-9199-360f9e6c1b23" x="54" y="5" width="100" height="20"/>
    				<textElement/>
    				<textFieldExpression><![CDATA[$F{donationRuleId}]]></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>
    I've tried Googling the error and get lot's of hits and tried a few suggestions but with no luck.
    The frustrating thing is that I was able to successfully create a report in another Java Server Faces project.
    Here is my Java code that generates the report based upon the current page.
    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package beans;
    
    import jpa.entities.SearchCriteria;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.List;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletResponse;
    import net.sf.jasperreports.engine.JRException;
    import net.sf.jasperreports.engine.JRExporterParameter;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
    import net.sf.jasperreports.engine.export.oasis.JROdtExporter;
    import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter;
    import net.sf.jasperreports.engine.export.ooxml.JRDocxExporterParameter;
    import net.sf.jasperreports.engine.export.ooxml.JRPptxExporter;
    import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter;
    import jpa.entities.DonationRule;
    import jsf.DonationRuleController;
    import jpa.controllers.DonationRuleJpaController;
    
    /**
     *
     * @author 
     */
    
    public class  DonationRuleBean{
        private List<DonationRule> listOfDonationRule;
        private SearchCriteria searchCriteria = new SearchCriteria();
        private DonationRuleJpaController jpaController = null;
        private DonationRuleController controller;
        public DonationRuleBean() {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            jpaController = (DonationRuleJpaController) facesContext.getApplication().getELResolver().getValue(facesContext.getELContext(), null, "DonationRuleJpa");
            controller =  (DonationRuleController)facesContext.getApplication().getELResolver().getValue(facesContext.getELContext(), null, "DonationRuleMB");
           searchCriteria = controller.getSearchCriteria();
        }
        
        public List<DonationRule> getListOfDonationRule() {
            listOfDonationRule=controller.getDonationRuleItems();
            if (listOfDonationRule == null) {
                if (searchCriteria.notEmpty()) {
                    //System.out.println("In getListOfDonationRule search criteria = "+searchCriteria.getDriver());
                    listOfDonationRule = jpaController.findDonationRuleEntities(searchCriteria, 25, 0,false);
                } else {
                    //System.out.println("2-In getListOfDonationRule search criteria = "+searchCriteria.getDriver());
                    listOfDonationRule = jpaController.findDonationRuleEntities( 25, 0,false);
                }
            for(int c=0;c<listOfDonationRule.size();c++){
                DonationRule ci=listOfDonationRule.get(c);
                String vn=ci.getFrequency();
                System.out.println("frequency.= "+vn);
            }
            }
    
            return listOfDonationRule;
        }
    
        public void setListOfDonationRule(List<DonationRule> listOfDonationRule) {
            this.listOfDonationRule = listOfDonationRule;
        }
        
        JasperPrint jasperPrint;
        public void init(String type) throws JRException{
            String  reportPath="";
            if(type.equals("XLS")){
              reportPath=  FacesContext.getCurrentInstance().getExternalContext().getRealPath("/donationrulesxls2.jasper");   
            }
            if(type.equals("PDF")){
            reportPath=  FacesContext.getCurrentInstance().getExternalContext().getRealPath("/donationrules.jasper"); 
    
            }
            if(type.equals("DOCX")){
            reportPath=  FacesContext.getCurrentInstance().getExternalContext().getRealPath("/donationrules.jasper"); 
            //reportPath = JasperCompileManager.compileReport(templatePath);
            }
            if(type.equals("ODT")){
            reportPath=  FacesContext.getCurrentInstance().getExternalContext().getRealPath("/donationrules.jasper"); 
            //reportPath = JasperCompileManager.compileReport(templatePath);
            }
            if(type.equals("PPT")){
            reportPath=  FacesContext.getCurrentInstance().getExternalContext().getRealPath("/donationrules.jasper"); 
            //reportPath = JasperCompileManager.compileReport(templatePath);
            }
            
            //JasperCompileManager.compileReportToFile(templatePath, reportPath);
            JRBeanCollectionDataSource beanCollectionDataSource=new JRBeanCollectionDataSource(getListOfDonationRule(),false);
            
            jasperPrint=JasperFillManager.fillReport(reportPath, new HashMap(),beanCollectionDataSource);
        }
        
       public void PDF(ActionEvent actionEvent) throws IOException{
     try{
           init("PDF");
           HttpServletResponse httpServletResponse=(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpServletResponse.addHeader("Content-disposition", "attachment; filename=donationrules.pdf");
           ServletOutputStream servletOutputStream=httpServletResponse.getOutputStream();
           JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
     }catch(JRException jrx){
         System.out.println("Caught JRException: "+jrx.getLocalizedMessage());
     }     
       }
        public void DOCX(ActionEvent actionEvent) throws JRException, IOException{
            init("DOCX");
          HttpServletResponse httpServletResponse=(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpServletResponse.addHeader("Content-disposition", "attachment; filename=donationrules.docx");
           ServletOutputStream servletOutputStream=httpServletResponse.getOutputStream();
           JRDocxExporter docxExporter=new JRDocxExporter();
           docxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
           docxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, servletOutputStream);
           docxExporter.setParameter(JRDocxExporterParameter.OUTPUT_STREAM, servletOutputStream);
           docxExporter.exportReport();
       }
         public void XLSX(ActionEvent actionEvent) throws JRException, IOException{
            init("XLS");
           HttpServletResponse httpServletResponse=(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpServletResponse.addHeader("Content-disposition", "attachment; filename=donationrules.xlsx");
           ServletOutputStream servletOutputStream=httpServletResponse.getOutputStream();
           JRXlsxExporter docxExporter=new JRXlsxExporter();
           docxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
           docxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, servletOutputStream);
           docxExporter.exportReport();
       }
          public void ODT(ActionEvent actionEvent) throws JRException, IOException{
           init("ODT");
           HttpServletResponse httpServletResponse=(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpServletResponse.addHeader("Content-disposition", "attachment; filename=donationrules.odt");
           ServletOutputStream servletOutputStream=httpServletResponse.getOutputStream();
           JROdtExporter docxExporter=new JROdtExporter();
           docxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
           docxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, servletOutputStream);
           docxExporter.exportReport();
       }
           public void PPT(ActionEvent actionEvent) throws JRException, IOException{
           init("PPT");
           HttpServletResponse httpServletResponse=(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpServletResponse.addHeader("Content-disposition", "attachment; filename=donationrules.pptx");
           ServletOutputStream servletOutputStream=httpServletResponse.getOutputStream();
           JRPptxExporter docxExporter=new JRPptxExporter();
           docxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
           docxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, servletOutputStream);
           docxExporter.exportReport();
       }
        
    }
    I would really appreciate any help because I have been puzzling over this for a month now and am getting very tired.
    Thanks for any efforts.

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,087
    Rep Power
    6

    Default Re: JSF with JasperSoft reports

    Hard to say, there isn't much to go on here. But my guess would be that one of those fields you define in your report is of type String and you are passing an Integer object to it. donationRuleId seems likely to be of the wrong type.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 0
    Last Post: 04-09-2012, 07:22 PM
  2. jasper reports
    By rekhab in forum New To Java
    Replies: 0
    Last Post: 09-10-2011, 09:08 AM
  3. Java Reports
    By greatmajestics@yahoo.com in forum JDBC
    Replies: 7
    Last Post: 07-12-2011, 08:29 AM
  4. What to use for Pdf reports?
    By hari.kr in forum Advanced Java
    Replies: 2
    Last Post: 04-29-2010, 11:15 AM
  5. JasperSoft iReport
    By imitch in forum Other IDEs
    Replies: 1
    Last Post: 12-22-2008, 01:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •