Jump to content
Changes to the Jaspersoft community edition download ×

problems with generating my report


xwinta

Recommended Posts

I have a piece of code that passes parameter to a JRXML file,compiles the .jrxml file to a .jasper file which is created successfully but report image requured is not generated..When i use a report doesnt need parameters,it works fine and generates the image...I need to generate the report that accepts parameters ...Pls help..My code is below...

 

package com.vas.polaris.actions;

 

import org.hibernate.*;

import org.openxava.actions.*;

import org.openxava.model.*;

import org.openxava.polaris.model.*;

import org.openxava.util.*;

import org.openxava.hibernate.*;

import org.openxava.validators.*;

import java.util.*;

import javax.servlet.http.*;

import javax.servlet.*;

import org.openxava.controller.*;

import org.openxava.tab.*;

import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.engine.data.*;

import org.openxava.view.*;

 

public class DayTransactionAction extends VasReportBaseAction {

Map values = new HashMap();

 

public Map getParameters() {

 

Map parameters = new HashMap();

// Collection col = getAllTransactions();

try {

 

int exRealValue = 0;

int week = 7;

int day = week / 7;

int hour = day / 24;

int min = hour / 60;

int month = week * 4;

int year = month * 12;

// int realValue = getView().getValueInt("lastDays") * 5;

int realValue = getView().getValueInt("interval");

if (realValue == 14) {

exRealValue = 1;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 15) {

exRealValue = 5;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 16) {

exRealValue = week;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 17) {

exRealValue = week * 2;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 18) {

exRealValue = week * 3;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 19) {

exRealValue = month;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 20) {

exRealValue = month * 2;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 21) {

exRealValue = month * 3;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 22) {

exRealValue = month * 4;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 23) {

exRealValue = month * 5;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 24) {

exRealValue = month * 6;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 25) {

exRealValue = month * 7;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 26) {

exRealValue = month * 8;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 27) {

exRealValue = month * 9;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 28) {

exRealValue = month * 10;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 29) {

exRealValue = month * 11;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 30) {

exRealValue = year;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 31) {

exRealValue = year * 2;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 32) {

exRealValue = year * 3;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 33) {

exRealValue = year * 4;

parameters.put("dayNumber", new Double(exRealValue));

System.out.print("Real value OF " + exRealValue);

} else if (realValue == 34) {

exRealValue = year * 5;

parameters.put("dayNumber", new Double(exRealValue));

System.out.print("Real value OF " + exRealValue);

} else if (realValue == 35) {

exRealValue = year * 6;

parameters.put("dayNumber", new Double(exRealValue));

System.out.print("Real value OF " + exRealValue);

} else if (realValue == 36) {

exRealValue = year * 7;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 37) {

exRealValue = year * 8;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 38) {

exRealValue = year * 9;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 39) {

exRealValue = year * 10;

parameters.put("dayNumber", new Double(exRealValue));

System.out.print("Real value OF " + exRealValue);

} else if (realValue == 40) {

exRealValue = year * 15;

parameters.put("dayNumber", new Double(exRealValue));

System.out.print("Real value OF " + exRealValue);

} else if (realValue == 41) {

exRealValue = year * 20;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 42) {

exRealValue = year * 25;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 43) {

exRealValue = year * 30;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 1) {

exRealValue = min;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 2) {

exRealValue = min * 5;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 3) {

exRealValue = min * 10;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 4) {

exRealValue = min * 15;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 5) {

exRealValue = min * 20;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 6) {

exRealValue = min * 30;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 7) {

exRealValue = min * 40;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 8) {

exRealValue = min * 45;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 9) {

exRealValue = hour;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 10) {

exRealValue = hour * 5;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 11) {

exRealValue = hour * 10;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 12) {

exRealValue = hour * 15;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 13) {

exRealValue = hour * 20;

parameters.put("dayNumber", new Double(exRealValue));

} else if (realValue == 0) {

addError("No Time Interval was selected");

}

System.out.print("GETTING 1st DATE OF " + realValue);

System.out.print(".........execute 2");

this.compileReport();

// parameters.put("dayNumber", new Double(realValue));

 

} catch (Exception e) {

e.printStackTrace();

}

return parameters;

}

 

protected JRDataSource getDataSource() throws Exception {

// Collection transactions = getAllTransactions();

// transactions.add(getTransaction().getAdapter());

return null;

}

 

protected String getJRXML() {

System.out.print(".........execute 1");

return "reports/DayTransaction.jrxml";

}

 

public Collection getAllTransactions() {

 

Collection transactions = new ArrayList();

try {

 

Query query = null;

String queryString = "select t from Transaction as t";

query = XHibernate.getSession().createQuery(queryString);

transactions = query.list();

} catch (Exception e) {

e.printStackTrace();

}

return transactions;

}

 

public void compileReport() {

try{

ServletContext application = getView().getRequest().getSession()

.getServletContext();

String path = application.getRealPath("/WEB-INF/classes/");

String jasperPath = application.getRealPath("/");

System.out.println("The path found... " + path);

JasperCompileManager.compileReportToFile(path + "/" + "reports/DayTransaction.jrxml",

jasperPath + "/" + "DayTransaction.jasper");

System.out.println("Compiled...");

}

catch(Exception e)

{e.printStackTrace();}

}

 

public ITransaction transaction;

}

 

 

It seems the JASPER file been compiles doesnt get the required parameter..If i push the report directly from JRXML to PDF it works...but i need it from JRXML to .jasper and then report..

 

Thanks

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...