Thursday, December 3, 2009

GraniteDS/Tide examples

I made a quickstart application about GraniteDS - a remoting server for flex/flash. This application was inspired by graniteds-example. The application integrate with Spring, Hibernate and MySQL for backend communications with live data. The application is just roughly finish and you can checkout using subversion: svn co http://flex-graniteds.googlecode.com/svn/trunk/ gds .

Comments and suggestion is always appreciated.
Cheers.

Monday, February 2, 2009

JasperReport & Wicket

Good day. For this tutorial im going to discuss about wicket-jasper-core that i made build on top wicket-contrib-jasperreport. JasperReport is a popular java reorting tool and wicket is java framework for web application. You should familiar with wicket and jasperreport to accomplish this tutorial. There are many tutorials about wicket and jasper report in the web. google it :) . I used DataView of wicket to page the result from DB and export to it in jasper report only the page data retrieve by wicket DataProvider passed to DataView. It is a bit hack of wicket's DataView to display paged report in wicket pages. For source code, you can download from the above link 'wicket-jasper-core'. It is hosted in wicket's forum site. You can take a look on how I extends and used DataView to paged the result form DataProvider then display the result. for demo here is the code;


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.