integrated report in ireport with jsf [closed]
hallo all..
i have a problem to create pdf format report with jasper report/ireport plugin in jsf ? i've made a report in jasper report, but i can't integrate it with jsf for create pdf format.. thank for your help..Could could do it this way. Add a h:commandLink
on a page pointing to an action method of your bean:
<h:commandLink value="download report" action="#{myBean.downloadReport}" />
In your bean you should generate your report and write it to the OutputStream
of the response:
public class MyBean {
public String downloadReport() {
// get HttpServletResponse
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response =
(HttpServletResponse) context.getExternalContext().getResponse();
// set correct content type
response.setContentType("application/pdf");
// get OutputStream
OutputStream stream = response.getOutputStream();
// TODO: generate PDF and write the report to this output stream
// mark response as completed
context.responseComplete();
return null;
}
}
精彩评论