public class TestReport extends WebPage
{
@SpringBean private EmployeeService employeeService;
public TestReport()
{
final ServletContext ctx = ((WebApplication) getApplication()).getServletContext();
final File reportFile = new File(ctx.getRealPath("/reports/employee.jasper"));
final Map parameters = new HashMap();
final QueryDataProvider qdp = new QueryDataProvider(employeeService)
{
public Iterator iterator(int first, int count)
{
return employeeService.loadAll(first, count).iterator();
}
public int size()
{
return employeeService.countAll();
}
};
final JRHtmlDataView<Employee> jrdv = new JRHtmlDataView
<Employee>
("jrdv", qdp, 10)
{
@Override
protected Map getParameter()
{
return parameters;
}
@Override
protected File getReportFile()
{
return reportFile;
}
@Override
protected JRDataSource getSource()
{
return new JRBeanCollectionDataSource(getDatas());
}
};
add(jrdv);
add(new PagingNavigator("navigation", jrdv));
}
}
and the html part is here:
TestReport.html
<span wicket:id="navigation"></span><br/>
<div wicket:id="jrdv">
<div wicket:id="report"></div>
</div>
...just that...wicket knowledge is essential here..the QueryDataProvider is the implementation of IDataProvider and has a paramater of a service injected by spring. The resulting output form the above code is an HTML report. Wicket-Jasper-Core can also export to PDF,XLS,CVS,TEXT and etc... Have a great day.