I' ve implemented the interface JRDATASOURCE in this way (the Vector
resultset is te result of my query and the columns[] is an array whit the
names of columns):



import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Iterator;
import java.util.Vector;

class JrVectorDataSource implements JRDataSource {


static Log log = LogFactory.getLog(JrVectorDataSource.class);
private Vector resultset = null;
private Iterator iterator = null;
private Object[] row = null;
private String[] columns = null;


protected JrVectorDataSource(Query_Contenitore contenitore) {
this.resultset = contenitore.getVector();
this.iterator = this.resultset.iterator();
this.columns = contenitore.getColumns_Label();
}

public Object getFieldValue(JRField jrField) throws JRException {
String name = jrField.getName();
int column = getColumn(name);
return row[column];
}

public boolean next() throws JRException {
if (iterator.hasNext()) {
row = (Object[]) iterator.next();
//log.warn("row:"+row[0]);
return true;
}
return false;
}

private int getColumn(String name) {
//log.error("row0:"+row[0]+" column name "+name);
int idx = -1;
for (int i = 0; i < columns.length; i++) {
if (columns.equalsIgnoreCase(name)) {
idx = i;
break;
}
}
if (idx < 0) {
log.error("column name " + name + " not found.");
throw new RuntimeException("column name " + name + " not found.");
}
return idx;
}

}
--------------------------------------------------------------------------------------------------

NOW MY PROBLEM IS......That in the method
JAsperFillManager.fillReport(JasperReport istance_jasperreport,HashMap
istance_hashmap,JRDataSource istance_jrdatasource) I can only pass an
istance of JRDataSource an so only one query.

some suggestion ?
I had thought to extend the JAsperFillManager class or to merge the Vectors
that are the results of mine queries 
-- 
View this message in context: 
http://www.nabble.com/JasperReports---More--of-one-query-tf2397118.html#a6684372
Sent from the jasperreports-questions mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions

Reply via email to