Jump to content

lesoft

Members
  • Posts

    3
  • Joined

  • Last visited

 Content Type 

Forum

Downloads

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Events

Profiles

Everything posted by lesoft

  1. Hi - Does JasperSoft support a text file datasource? Thanks, Tuan
  2. Thanks! I found issue of initializing my index counter.
  3. Hi, I'm using iReport to design my report. The report is using a custom data source which implemnts JRDataSource. I noticed that the first record in the list is alway missing in the report display. When stepped through debugger, the next() method below got called before calling getFieldValue() method. How do I prevent the skipping of first record (index = 0)? I must have missed something very obvious here, but I couldn't figure out. Code: /** * JasperReport library */ public class LineItemDataSourceVo implements JRDataSource { /** * Class variables */ private List<LineItemVo> data = null; private int index = 0; /** * Default constructor */ public LineItemDataSourceVo(List<LineItemVo> items) { this.data = items; } public void add(LineItemVo item) { if (data == null) { data = new ArrayList(); } data.add(item); } /** * ===================================================== * Required JRDataSource implementation methods * ===================================================== */ public boolean next() throws JRException { index++; return (index < data.size()); } public Object getFieldValue(JRField field) throws JRException { LineItemVo lineItem = (LineItemVo)data.get(index); Object value = null; try { Object[] args = { }; Class[] paramTypes = { }; Class lineItemClass = lineItem.getClass(); Method getMethod = lineItemClass.getDeclaredMethod(field.getName(), paramTypes); value = "" + getMethod.invoke(lineItem, args); } catch (Exception e) { throw new JRException(e.getMessage()); } return value; } } // LineItemDataSourceVo Code:[code] LineItemDataSourceVo lineItemDS = new LineItemDataSourceVo(testData.getLineItems()); // ...some more code JasperRunManager.runReportToPdfStream(reportStream, response.getOutputStream(), parameters, lineItemDS); Thanks, Tuan
×
×
  • Create New...