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

lesoft

Members
  • Posts

    3
  • Joined

  • Last visited

lesoft's Achievements

Newbie

Newbie (1/14)

  • First Post Rare
  • Conversation Starter Rare
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  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...