I ha开发者_JAVA百科ve a service class that creates reports in xls using dynamicjasper, I wonder how I can include a button in my flex app to execute this method.
@Service("downloadService")
@Transactional
public class DownServiceRelTemp {
private static Logger logger = Logger.getLogger("service");
@Resource(name="sessionFactory")
private SessionFactory sessionFactory;
public void downloadXLS(HttpServletResponse response) throws ColumnBuilderException,
ClassNotFoundException, JRException {
logger.debug("Downloading Excel report");
DynamicReport dr = LayouteRelTemp.buildReportLayout();
JRDataSource ds = getDataSource();
JasperReport jr = DynamicJasperHelper.generateJasperReport(dr, new ClassicLayoutManager(), null);
JasperPrint jp = JasperFillManager.fillReport(jr, null, ds);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Exporter.exportToXLS(jp, baos);
String fileName = "MyReport.xls";
response.setHeader("Content-Disposition", "inline; filename=" + fileName);
response.setContentType("application/vnd.ms-excel");
response.setContentLength(baos.size());
Writer.write(response, baos);
}
Any suggestions, do not have much experience with adobe flex and would like a simple help.
There's some ways to interactive flex with java
- Using Web Services
- Using servlets
- By Remoting objects. By AMF thecnology.
I recommend this tutorial of the evangelist James Ward, in this tutorial him explains the differents ways to connect flex and java with code example. That's how I learned to comunicate flex and Java
Notes that you need to check blazeDs Library
精彩评论